If you specify a complex-valued refractive index and are solving for ray intensity or power (see the section Intensity, Polarization, and Power), you can make the intensity and power vary along the ray path. If the medium properties are uniform, the intensity and power usually follow exponential decay (for an absorbing medium) or growth (for a gain medium). You can switch between absorbing and gain media by changing the sign of the imaginary part of the refractive index.