# Ray transfer matrix analysis

Ray transfer matrix analysis (also known as ABCD matrix analysis) is a mathematical form for performing ray tracing calculations in sufficiently simple problems which can be solved considering only paraxial rays. Each optical element (surface, interface, mirror, or beam travel) is described by a 2 × 2 ray transfer matrix which operates on a vector describing an incoming light ray to calculate the outgoing ray. Multiplication of the successive matrices thus yields a concise ray transfer matrix describing the entire optical system. The same mathematics is also used in accelerator physics to track particles through the magnet installations of a particle accelerator, see electron optics.
This technique, as described below, is derived using the paraxial approximation, which requires that all ray directions (directions normal to the wavefronts) are at small angles θ relative to the optical axis of the system, such that the approximation sin θ ≈ θ remains valid. A small θ further implies that the transverse extent of the ray bundles (x and y) is small compared to the length of the optical system (thus "paraxial"). Since a decent imaging system where this is not the case for all rays must still focus the paraxial rays correctly, this matrix method will properly describe the positions of focal planes and magnifications, however aberrations still need to be evaluated using full ray-tracing techniques.

## Matrix definition

The ray tracing technique is based on two reference planes, called the input and output planes, each perpendicular to the optical axis of the system. At any point along the optical train an optical axis is defined corresponding to a central ray; that central ray is propagated to define the optical axis further in the optical train which need not be in the same physical direction (such as when bent by a prism or mirror). The transverse directions x and y (below we only consider the x direction) are then defined to be orthogonal to the optical axes applying. A light ray enters a component crossing its input plane at a distance x$_1$ from the optical axis, traveling in a direction that makes an angle θ$_1$ with the optical axis. After propagation to the output plane that ray is found at a distance x$_2$ from the optical axis and at an angle θ$_2$ with respect to it. n$_1$ and n$_2$ are the indices of refraction of the media in the input and output plane, respectively.
The ABCD matrix representing a component or system relates the output ray to the input according to ${\begin{bmatrix}x_{2}\\\theta _{2}\end{bmatrix}}={\begin{bmatrix}A&B\\C&D\end{bmatrix}}{\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}},$ where the values of the 4 matrix elements are thus given by $A=\left.{\frac {x_{2}}{x_{1}}}\right|_{\theta _{1}=0}\qquad B=\left.{\frac {x_{2}}{\theta _{1}}}\right|_{x_{1}=0},$ and $C=\left.{\frac {\theta _{2}}{x_{1}}}\right|_{\theta _{1}=0}\qquad D=\left.{\frac {\theta _{2}}{\theta _{1}}}\right|_{x_{1}=0}.$
This relates the ray vectors at the input and output planes by the ray transfer matrix (RTM) M, which represents the optical component or system present between the two reference planes. A thermodynamics argument based on the blackbody radiation can be used to show that the determinant of a RTM is the ratio of the indices of refraction: $\det(\mathbf {M} )=AD-BC={\frac {n_{1}}{n_{2}}}.$
As a result, if the input and output planes are located within the same medium, or within two different media which happen to have identical indices of refraction, then the determinant of M is simply equal to 1.
A different convention for the ray vectors can be employed. Instead of using θ ≈ sin θ, the second element of the ray vector is n sin θ, which is proportional not to the ray angle per se but to the transverse component of the wave vector. This alters the ABCD matrices given in the table below where refraction at an interface is involved.
The use of transfer matrices in this manner parallels the 2 × 2 matrices describing electronic two-port networks, particularly various so-called ABCD matrices which can similarly be multiplied to solve for cascaded systems.

## Some examples
### Free space example

As one example, if there is free space between the two planes, the ray transfer matrix is given by: $\mathbf {S} ={\begin{bmatrix}1&d\\0&1\end{bmatrix}},$ where d is the separation distance (measured along the optical axis) between the two reference planes. The ray transfer equation thus becomes: ${\begin{bmatrix}x_{2}\\\theta _{2}\end{bmatrix}}=\mathbf {S} {\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}},$ and this relates the parameters of the two rays as: ${\begin{aligned}x_{2}&=x_{1}+d\theta _{1}\\\theta _{2}&={\hphantom {x_{1}+d}}\theta _{1}\end{aligned}}$

### Thin lens example

Another simple example is that of a thin lens. Its RTM is given by: $\mathbf {L} ={\begin{bmatrix}1&0\\-{\frac {1}{f}}&1\end{bmatrix}},$ where f is the focal length of the lens. To describe combinations of optical components, ray transfer matrices may be multiplied together to obtain an overall RTM for the compound optical system. For the example of free space of length d followed by a lens of focal length f: $\mathbf {L} \mathbf {S} ={\begin{bmatrix}1&0\\-{\frac {1}{f}}&1\end{bmatrix}}{\begin{bmatrix}1&d\\0&1\end{bmatrix}}={\begin{bmatrix}1&d\\-{\frac {1}{f}}&1-{\frac {d}{f}}\end{bmatrix}}.$
Note that, since the multiplication of matrices is non-commutative, this is not the same RTM as that for a lens followed by free space: $\mathbf {SL} ={\begin{bmatrix}1&d\\0&1\end{bmatrix}}{\begin{bmatrix}1&0\\-{\frac {1}{f}}&1\end{bmatrix}}={\begin{bmatrix}1-{\frac {d}{f}}&d\\-{\frac {1}{f}}&1\end{bmatrix}}.$
Thus the matrices must be ordered appropriately, with the last matrix premultiplying the second last, and so on until the first matrix is premultiplied by the second. Other matrices can be constructed to represent interfaces with media of different refractive indices, reflection from mirrors, etc.

## Eigenvalues

A ray transfer matrix can be regarded as a linear canonical transformation. According to the eigenvalues of the optical system, the system can be classified into several classes. Assume the ABCD matrix representing a system relates the output ray to the input according to ${\begin{bmatrix}x_{2}\\\theta _{2}\end{bmatrix}}={\begin{bmatrix}A&B\\C&D\end{bmatrix}}{\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}}=\mathbf {T} \mathbf {v} .$
We compute the eigenvalues of the matrix $\mathbf {T}$ that satisfy eigenequation $[{\boldsymbol {T}}-\lambda I]\mathbf {v} ={\begin{bmatrix}A-\lambda &B\\C&D-\lambda \end{bmatrix}}\mathbf {v} =0,$ by calculating the determinant ${\begin{vmatrix}A-\lambda &B\\C&D-\lambda \end{vmatrix}}=\lambda ^{2}-(A+D)\lambda +1=0.$
Let $m={\frac {(A+D)}{2}}$, and we have eigenvalues $\lambda _{1},\lambda _{2}=m\pm {\sqrt {m^{2}-1}}$.
According to the values of $\lambda _{1}$ and $\lambda _{2}$, there are several possible cases. For example:
* A pair of real eigenvalues: $r$ and $r^{-1}$, where $r\neq 1$. This case represents a magnifier ${\begin{bmatrix}r&0\\0&r^{-1}\end{bmatrix}}$
* $\lambda _{1}=\lambda _{2}=1$ or $\lambda _{1}=\lambda _{2}=-1$. This case represents unity matrix (or with an additional coordinate reverter) ${\begin{bmatrix}1&0\\0&1\end{bmatrix}}$.
* $\lambda _{1},\lambda _{2}=\pm 1$. This case occurs if but not only if the system is either a unity operator, a section of free space, or a lens
* A pair of two unimodular, complex conjugated eigenvalues $e^{i\theta }$ and $e^{-i\theta }$. This case is similar to a separable Fractional Fourier Transform.

## Matrices for simple optical components

| Element | Matrix | Remarks |
| Propagation in free space or in a medium of constant refractive index | ${\begin{pmatrix}1&d\\0&1\end{pmatrix}}$ | d = distance |
| Refraction at a flat interface | ${\begin{pmatrix}1&0\\0&{\frac {n_{1}}{n_{2}}}\end{pmatrix}}$ | n$_1$ = initial refractive index n$_2$ = final refractive index. |
| Refraction at a curved interface | ${\begin{pmatrix}1&0\\{\frac {n_{1}-n_{2}}{R\cdot n_{2}}}&{\frac {n_{1}}{n_{2}}}\end{pmatrix}}$ | R = radius of curvature, R > 0 for convex (center of curvature after interface) n$_1$ = initial refractive index n$_2$ = final refractive index. |
| Reflection from a flat mirror | ${\begin{pmatrix}1&0\\0&1\end{pmatrix}}$ | Valid for flat mirrors oriented at any angle to the incoming beam. Both the ray and the optic axis are reflected equally, so there is no net change in slope or position. |
| Reflection from a curved mirror | ${\begin{pmatrix}1&0\\-{\frac {2}{R_{e}}}&1\end{pmatrix}}$ | $R_{e}=R\cos \theta$ effective radius of curvature in tangential plane (horizontal direction) $R_{e}=R/\cos \theta$ effective radius of curvature in the sagittal plane (vertical direction) R = radius of curvature, R > 0 for concave, valid in the paraxial approximation θ is the mirror angle of incidence in the horizontal plane. |
| Thin lens | ${\begin{pmatrix}1&0\\-{\frac {1}{f}}&1\end{pmatrix}}$ | f = focal length of lens where f > 0 for convex/positive (converging) lens. Only valid if the focal length is much greater than the thickness of the lens. |
| Thick lens | ${\begin{pmatrix}1&0\\{\frac {n_{2}-n_{1}}{R_{2}n_{1}}}&{\frac {n_{2}}{n_{1}}}\end{pmatrix}}{\begin{pmatrix}1&t\\0&1\end{pmatrix}}{\begin{pmatrix}1&0\\{\frac {n_{1}-n_{2}}{R_{1}n_{2}}}&{\frac {n_{1}}{n_{2}}}\end{pmatrix}}$ | n$_1$ = refractive index outside of the lens. n$_2$ = refractive index of the lens itself (inside the lens). R$_1$ = Radius of curvature of First surface. R$_2$ = Radius of curvature of Second surface. t = center thickness of lens. |
| Single prism | ${\begin{pmatrix}k&{\frac {d}{nk}}\\0&{\frac {1}{k}}\end{pmatrix}}$ | $k=(\cos \psi /\cos \phi )$ is the beam expansion factor, where ϕ is the angle of incidence, ψ is the angle of refraction, d = prism path length, n = refractive index of the prism material. This matrix applies for orthogonal beam exit. |
| Multiple prism beam expander using r prisms | ${\begin{pmatrix}M&B\\0&{\frac {1}{M}}\end{pmatrix}}$ | M is the total beam magnification given by M = k$_1$k$_2$k$_3$···k$_r$, where k is defined in the previous entry and B is the total optical propagation distance of the multiple prism expander. |

## Relation between geometrical ray optics and wave optics

The theory of Linear canonical transformation implies the relation between ray transfer matrix (geometrical optics) and wave optics.
| Element | Matrix in geometrical optics | Operator in wave optics | Remarks |
| Scaling | ${\begin{pmatrix}b^{-1}&0\\0&b\end{pmatrix}}$ | ${\mathcal {V}}[b]u(x)=u(bx)$ | |
| Quadratic phase factor | ${\begin{pmatrix}1&0\\c&1\end{pmatrix}}$ | $Q[c]=\exp i{\frac {k_{0}}{2}}cx^{2}$ | $k_{0}$: wave number |
| Fresnel free-space-propagation operator | ${\begin{pmatrix}1&d\\0&1\end{pmatrix}}$ | ${\mathcal {R}}[d]\left\{U\left(x_{1}\right)\right\}={\frac {1}{\sqrt {i\lambda d}}}\int _{-\infty }^{\infty }U\left(x_{1}\right)e^{i{\frac {k}{2d}}\left(x_{2}-x_{1}\right)^{2}}dx_{1}$ | $x_{1}$: coordinate of the source $x_{2}$: coordinate of the goal |
| Normalized Fourier-transform operator | ${\begin{pmatrix}0&1\\-1&0\end{pmatrix}}$ | ${\mathcal {F}}=\left(i\lambda _{0}\right)^{-1/2}\int _{-\infty }^{\infty }dx\left[\exp \left(ik_{0}px\right)\right]\ldots$ | |

## Common decomposition

There exist infinite ways to decompose a ray transfer matrix $\mathbf {T} ={\begin{bmatrix}A&B\\C&D\end{bmatrix}}$ into a concatenation of multiple transfer matrices. For example in the special case when $n_{1}=n_{2}$:
* ${\begin{bmatrix}A&B\\C&D\end{bmatrix}}=\left[{\begin{array}{ll}1&0\\D/B&1\end{array}}\right]\left[{\begin{array}{rr}B&0\\0&1/B\end{array}}\right]\left[{\begin{array}{ll}0&1\\-1&0\end{array}}\right]\left[{\begin{array}{ll}1&0\\A/B&1\end{array}}\right]$.
* ${\begin{bmatrix}A&B\\C&D\end{bmatrix}}=\left[{\begin{array}{ll}1&0\\C/A&1\end{array}}\right]\left[{\begin{array}{rr}A&0\\0&A^{-1}\end{array}}\right]\left[{\begin{array}{ll}1&B/A\\0&1\end{array}}\right]$
* ${\begin{bmatrix}A&B\\C&D\end{bmatrix}}=\left[{\begin{array}{ll}1&A/C\\0&1\end{array}}\right]\left[{\begin{array}{lr}-C^{-1}&0\\0&-C\end{array}}\right]\left[{\begin{array}{ll}0&1\\-1&0\end{array}}\right]\left[{\begin{array}{ll}1&D/C\\0&1\end{array}}\right]$
* ${\begin{bmatrix}A&B\\C&D\end{bmatrix}}=\left[{\begin{array}{ll}1&B/D\\0&1\end{array}}\right]\left[{\begin{array}{ll}D^{-1}&0\\0&D\end{array}}\right]\left[{\begin{array}{ll}1&0\\C/D&1\end{array}}\right]$

## Resonator stability

RTM analysis is particularly useful when modeling the behavior of light in optical resonators, such as those used in lasers. At its simplest, an optical resonator consists of two identical facing mirrors of 100% reflectivity and radius of curvature R, separated by some distance d. For the purposes of ray tracing, this is equivalent to a series of identical thin lenses of focal length f = R/2, each separated from the next by length d. This construction is known as a lens equivalent duct or lens equivalent waveguide. The RTM of each section of the waveguide is, as above, $\mathbf {M} =\mathbf {L} \mathbf {S} ={\begin{pmatrix}1&d\\{\frac {-1}{f}}&1-{\frac {d}{f}}\end{pmatrix}}.$
RTM analysis can now be used to determine the stability of the waveguide (and equivalently, the resonator). That is, it can be determined under what conditions light traveling down the waveguide will be periodically refocused and stay within the waveguide. To do so, we can find all the "eigenrays" of the system: the input ray vector at each of the mentioned sections of the waveguide times a real or complex factor λ is equal to the output one. This gives: $\mathbf {M} {\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}}={\begin{bmatrix}x_{2}\\\theta _{2}\end{bmatrix}}=\lambda {\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}}.$ which is an eigenvalue equation: $\left[\mathbf {M} -\lambda \mathbf {I} \right]{\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}}=0,$ where I=[1001]{\textstyle \mathbf {I} =\left[{\begin{smallmatrix}1&0\\0&1\end{smallmatrix}}\right]} is the 2 × 2 identity matrix.
We proceed to calculate the eigenvalues of the transfer matrix: $\det \left[\mathbf {M} -\lambda \mathbf {I} \right]=0,$ leading to the characteristic equation $\lambda ^{2}-\operatorname {tr} (\mathbf {M} )\lambda +\det(\mathbf {M} )=0,$ where $\operatorname {tr} (\mathbf {M} )=A+D=2-{\frac {d}{f}}$ is the trace of the RTM, and $\det(\mathbf {M} )=AD-BC=1$ is the determinant of the RTM. After one common substitution we have: $\lambda ^{2}-2g\lambda +1=0,$ where $g{\overset {\mathrm {def} }{=}}{\frac {\operatorname {tr} (\mathbf {M} )}{2}}=1-{\frac {d}{2f}}$ is the stability parameter. The eigenvalues are the solutions of the characteristic equation. From the quadratic formula we find $\lambda _{\pm }=g\pm {\sqrt {g^{2}-1}}.$
Now, consider a ray after N passes through the system: ${\begin{bmatrix}x_{N}\\\theta _{N}\end{bmatrix}}=\lambda ^{N}{\begin{bmatrix}x_{1}\\\theta _{1}\end{bmatrix}}.$
If the waveguide is stable, no ray should stray arbitrarily far from the main axis, that is, λ$^N$ must not grow without limit. Suppose $g^{2}>1$. Then both eigenvalues are real. Since $\lambda _{+}\lambda _{-}=1$, one of them has to be bigger than 1 (in absolute value), which implies that the ray which corresponds to this eigenvector would not converge. Therefore, in a stable waveguide, $g^{2}\leq 1$, and the eigenvalues can be represented by complex numbers: $\lambda _{\pm }=g\pm i{\sqrt {1-g^{2}}}=\cos(\phi )\pm i\sin(\phi )=e^{\pm i\phi },$ with the substitution g = cos(ϕ).
For $g^{2}<1$ let $r_{+}$ and $r_{-}$ be the eigenvectors with respect to the eigenvalues $\lambda _{+}$ and $\lambda _{-}$ respectively, which span all the vector space because they are orthogonal, the latter due to $\lambda _{+}\neq \lambda _{-}$. The input vector can therefore be written as $c_{+}r_{+}+c_{-}r_{-},$ for some constants $c_{+}$ and $c_{-}$.
After N waveguide sectors, the output reads $\mathbf {M} ^{N}(c_{+}r_{+}+c_{-}r_{-})=\lambda _{+}^{N}c_{+}r_{+}+\lambda _{-}^{N}c_{-}r_{-}=e^{iN\phi }c_{+}r_{+}+e^{-iN\phi }c_{-}r_{-},$ which represents a periodic function.

## Gaussian beams

The same matrices can also be used to calculate the evolution of Gaussian beams propagating through optical components described by the same transmission matrices. If we have a Gaussian beam of wavelength $\lambda _{0}$, radius of curvature R (positive for diverging, negative for converging), beam spot size w and refractive index n, it is possible to define a complex beam parameter q by: ${\frac {1}{q}}={\frac {1}{R}}-{\frac {i\lambda _{0}}{\pi nw^{2}}}.$
(R, w, and q are functions of position.) If the beam axis is in the z direction, with waist at z$_0$ and Rayleigh range z$_R$, this can be equivalently written as $q=(z-z_{0})+iz_{R}.$
This beam can be propagated through an optical system with a given ray transfer matrix by using the equation: ${\begin{bmatrix}q_{2}\\1\end{bmatrix}}=k{\begin{bmatrix}A&B\\C&D\end{bmatrix}}{\begin{bmatrix}q_{1}\\1\end{bmatrix}},$ where k is a normalization constant chosen to keep the second component of the ray vector equal to 1. Using matrix multiplication, this equation expands as ${\begin{aligned}q_{2}&=k(Aq_{1}+B)\\1&=k(Cq_{1}+D)\,.\end{aligned}}$
Dividing the first equation by the second eliminates the normalization constant: $q_{2}={\frac {Aq_{1}+B}{Cq_{1}+D}},$
It is often convenient to express this last equation in reciprocal form: ${\frac {1}{q_{2}}}={\frac {C+D/q_{1}}{A+B/q_{1}}}.$

### Example: Free space

Consider a beam traveling a distance d through free space, the ray transfer matrix is ${\begin{bmatrix}A&B\\C&D\end{bmatrix}}={\begin{bmatrix}1&d\\0&1\end{bmatrix}}.$ and so $q_{2}={\frac {Aq_{1}+B}{Cq_{1}+D}}={\frac {q_{1}+d}{1}}=q_{1}+d$ consistent with the expression above for ordinary Gaussian beam propagation, i.e. $q=(z-z_{0})+iz_{R}$. As the beam propagates, both the radius and waist change.

### Example: Thin lens

Consider a beam traveling through a thin lens with focal length f. The ray transfer matrix is ${\begin{bmatrix}A&B\\C&D\end{bmatrix}}={\begin{bmatrix}1&0\\-1/f&1\end{bmatrix}}.$ and so $q_{2}={\frac {Aq_{1}+B}{Cq_{1}+D}}={\frac {q_{1}}{-{\frac {q_{1}}{f}}+1}}$ ${\frac {1}{q_{2}}}={\frac {-{\frac {q_{1}}{f}}+1}{q_{1}}}={\frac {1}{q_{1}}}-{\frac {1}{f}}.$ Only the real part of 1/q is affected: the wavefront curvature 1/R is reduced by the power of the lens 1/f, while the lateral beam size w remains unchanged upon exiting the thin lens.

## Higher rank matrices

Methods using transfer matrices of higher dimensionality, that is 3 × 3, 4 × 4, and 6 × 6, are also used in optical analysis. In particular, 4 × 4 propagation matrices are used in the design and analysis of prism sequences for pulse compression in femtosecond lasers.