  We present a method for calculating the transmission spectra, dispersion, and
time delay characteristics of optical-waveguide gratings based on Green's
functions and Dyson's equation. Starting from the wave equation for transverse
electric modes we show that the method can solve exactly both the problems of
coupling of counter-propagating waves (Bragg gratings) and co-propagating waves
(long-period gratings). In both cases the method applies for gratings with
arbitrary dielectric modulation, including all kinds of chirp and apodisation
and possibly also imperfections in the dielectric modulation profile of the
grating. Numerically, the method scales as O(N) where N is the number of points
used to discretize the grating along the propagation axis. We consider optical
fiber gratings although the method applies to all 1D optical waveguide gratings
including high-index contrast gratings and 1D photonic crystals.
