Mathematical models for diffractive optics have been developed, and implemented as numerical codes, both for the “direct” problem and for the “inverse” problem. In problems of the “direct” class, the diffractive optic is specified, and the full set of Maxwell’s equations is cast in a variational form and solved numerically by a finite element approach. This approach is well-posed in the sense that existence and uniqueness of the solution can be proved and specific convergence conditions can be derived. As an example, we consider a low order metallic grating, where other approaches are known to have convergence problems, and show the variational method yields exceptionally good convergence. In problems of the “inverse” class, some information about the diffracted field (e.g., the far-field intensity) is given, and the problem is to find the periodic structure in some optimal sense. A new approach is described that applies relaxed optimal design methods to give entirely new grating structures; wave propagation is based on the Helmholtz equation. An example of an angle-optimized antireflective structure and of an ideal array generator are presented.