Currently I'm coding a transfer matrix approach in C#. Hence, I come up with certain electric fields $E$. At each position I have a propagating field to the right $E_{\text{right}}$ and one to the left $E_{\text{leftt}}$. Now I want to determine the insentiy at a certain position. My idea was to calculate the intensity of both waves and add them up afterwards.
Now the point is, that I use this formula:
$I = \hat n \cdot \frac{\varepsilon_0 \, c}{2} \cdot |E|^2$
Reference: Wikipedia - Intensity
The problem here is, that the refractive index $\hat n$ is indeed a complex number and hence my intensity will get complex.
What is the physically correct way to determine the intensity of an electric field for a complex refractive index?
Is it the magnitude $|\hat n|$ or just the real part $\mathcal {Re}(\hat n)$ or something completely different?