We present a method that formally calculates \emph{exact} frequency shifts of
an electromagnetic field for arbitrary changes in the refractive index. The
possible refractive index changes include both anisotropic changes and boundary
shifts. Degenerate eigenmode frequencies pose no problems in the presented
method. The approach relies on operator algebra to derive an equation for the
frequency shifts, which eventually turn out in a simple and physically sound
form. Numerically the equations are well-behaved, easy implementable, and can
be solved very fast. Like in perturbation theory a reference system is first
considered, which then subsequently is used to solve another related, but
different system. For our method precision is only limited by the reference
system basis functions and the error induced in frequency is of second order
for first-order basis set error. As an example we apply our method to the
problem of variations in the air-hole diameter in a photonic crystal fiber.Comment: Accepted for Opt. Commu