# Integrating real and ìmaginary part separately

Greetings! I am working in a problem with complex-valued functions over a \mathbb R^2 domain. I would like to know if there is a direct way in Dolfinx of computing the L^2 norm of some function real and imaginary parts separately.

As suggested in the tutorials, I am actually computing the error between some exact solution `uex` and a calculated `us` as follows

``````error = us - uex
l2error = dolfinx.fem.form(ufl.inner(error,error) * ufl.ds)
squareerror = dolfinx.fem.assemble_scalar(l2error)
l2normerror = np.sqrt(squareerror)
``````

In this case, `error` is a complex function valued function. But, this computes the error of the whole function parts together. My question is if is there some way similar to the above for integrating the split `error` real and imaginary parts.

For now, I am proceeding with this alternative:

``````error = us.x.array - uex.x.array
error_bdr = error[boundary_dofs_index_array]
err_array_real[i] = np.linalg.norm(error_bdr.real)
err_array_imag[i] = np.linalg.norm(error_bdr.imag)
``````

However, this calculates the R^n norm instead of the L^2, which I’d wish to compute. If is there a direct way or an alternative, I’m thankful for knowing.

It is somewhat difficult to answer without a full reproducible code, but you may want to try with

``````l2error_real = dolfinx.fem.form(ufl.inner(ufl.real(error), ufl.real(error)) * ufl.ds)
l2error_imag = dolfinx.fem.form(ufl.inner(ufl.imag(error), ufl.imag(error)) * ufl.ds)
``````
1 Like