  The scattering matrix, which quantifies the optical reflection and
transmission of a photonic structure, is pivotal for understanding the
performance of the structure. In many photonic design tasks, it is also desired
to know how the structure's optical performance changes with respect to design
parameters, that is, the scattering matrix's derivatives (or gradient). Here we
address this need. We present a new algorithm for computing scattering matrix
derivatives accurately and robustly. In particular, we focus on the computation
in semi-analytical methods (such as rigorous coupled-wave analysis). To compute
the scattering matrix of a structure, these methods must solve an
eigen-decomposition problem. However, when it comes to computing scattering
matrix derivatives, differentiating the eigen-decomposition poses significant
numerical difficulties. We show that the differentiation of the
eigen-decomposition problem can be completely sidestepped, and thereby propose
a robust algorithm. To demonstrate its efficacy, we use our algorithm to
optimize metasurface structures and reach various optical design goals.

Optics