A guide to the principles & detailed mathematics of the Fourier modal method of optical analysis. It takes readers through the implementation of MATLAB[registered] codes for practical modeling of well-known & promising nanophotonic structures. It also addresses the limitations of the Fourier modal method.