A new identity is derived which relates the gain and the field distrib
ution (or confinement factor) in a dielectric waveguide with complex r
efractive indices, This identity is valid for any guided mode of waveg
uides with an arbitrary cross section, It provides a new check of the
accuracy of mode solvers, Also, it can be used in a variational approa
ch to predict the gain or loss of a guided mode based on knowledge of
confinement factors, It is shown that a previous analysis that is ofte
n used, is not correct, In addition, approximate expressions for the g
ain in slab waveguides are presented.