---
title: Ray-transfer matrices
heading: Paraxial rays as a height and an angle, the 2 × 2 matrices of free space, thin lenses, refracting surfaces and mirrors, cascading them into a system matrix, reading off focal length, imaging and magnification, and the stability of periodic systems and resonators
eyebrow: S13 · Lesson 1 · Ray-transfer matrices
xp: 50
---

::: hook
B8 traced rays through one lens at a time with the lens equation. Real optical systems, a camera objective, a microscope, a laser cavity, have many elements, and tracing rays through them one surface at a time gets tedious. In the paraxial approximation every element is linear in a ray's height and angle, so each is a 2 × 2 matrix and a whole system is their product. One matrix then tells you the system's focal length, where it images, how much it magnifies, and whether a ray bouncing between two mirrors stays trapped.
:::

::: play
- Rays leaving an on-axis point at several angles, passing through a thin lens of focal length f placed a distance a away, and converging to an image.
- When a is larger than f the rays cross at the image distance $1/(1/f - 1/a)$. At a = f they leave parallel; inside f they diverge, forming a virtual image.
- Paraxial means small angles: here up to 0.1 rad, where $\sin\theta \approx \theta$ to within 0.2%.
:::

```sim plot
view: graph
x: z = 0..600 mm
y: y = -40..40 mm
slider: a = 60..300 step 5 = 200 mm
slider: f = 30..150 step 5 = 50 mm
plot: 0.1*z + step(z - a)*(-0.1*a/f)*(z - a) | samples: 400 | label: θ = 0.1
plot: 0.05*z + step(z - a)*(-0.05*a/f)*(z - a) | samples: 400 | color: ch2 | label: θ = 0.05
plot: -0.05*z + step(z - a)*(0.05*a/f)*(z - a) | samples: 400 | color: ch3 | label: θ = −0.05
plot: -0.1*z + step(z - a)*(0.1*a/f)*(z - a) | samples: 400 | color: ch4 | label: θ = −0.1
marker: x = a | label: lens
readout: image distance from the lens, mm = 1/(1/f - 1/a) | digits: 4
readout: magnification = -1/(1/f - 1/a)/a | digits: 3
```

::: predict
## Two thin lenses, f₁ = 100 mm and f₂ = 50 mm, sit 30 mm apart. What's the focal length of the pair?

- [ ] 150 mm
- [ ] 33.3 mm
- [x] 41.7 mm
- [ ] 70 mm

::: reveal
Multiply the matrices: lens 1, 30 mm of free space, lens 2. The system's C element is −0.024 mm⁻¹, so f = −1/C = 41.7 mm, the same as $f_1f_2/(f_1 + f_2 - d)$. In contact (d = 0) the powers would simply add, to 33.3 mm; separating the lenses weakens the combination.
:::
:::

::: nameit
## Rays as vectors

In a medium of index n, a paraxial ray at position z is described by its height y and angle θ to the axis. Each optical element maps $(y_1, \theta_1)$ linearly to $(y_2, \theta_2)$ through its **ray-transfer matrix** $\begin{bmatrix} A & B \\ C & D \end{bmatrix}$:

- free space of length d: $\begin{bmatrix} 1 & d \\ 0 & 1 \end{bmatrix}$
- thin lens of focal length f: $\begin{bmatrix} 1 & 0 \\ -1/f & 1 \end{bmatrix}$
- planar boundary from $n_1$ to $n_2$: $\begin{bmatrix} 1 & 0 \\ 0 & n_1/n_2 \end{bmatrix}$
- spherical boundary of radius R (center to the right positive): $\begin{bmatrix} 1 & 0 \\ -\frac{n_2 - n_1}{n_2R} & \frac{n_1}{n_2} \end{bmatrix}$
- concave mirror of radius R (unfolded): $\begin{bmatrix} 1 & 0 \\ -2/R & 1 \end{bmatrix}$

## Systems

A ray passing elements 1, 2, …, N meets the product $M = M_N \cdots M_2M_1$, with the first element on the right. The determinant is $n_1/n_2$ (1 when the system begins and ends in the same medium).

- **Effective focal length:** $f = -1/C$. For two thin lenses a distance d apart, $f = f_1f_2/(f_1 + f_2 - d)$.
- **Imaging:** a system images when B = 0; then A is the magnification.

## Periodic systems and resonators

A ray bouncing between two mirrors of radii $R_1$ and $R_2$ a distance d apart stays confined if

$$0 \le g_1g_2 \le 1, \qquad g_i = 1 - \frac{d}{R_i}$$

(R positive for concave mirrors). Plane–plane ($g_1 = g_2 = 1$) and concentric ($g_1 = g_2 = -1$) cavities sit on the edge of stability; confocal ($g_1 = g_2 = 0$) sits in the middle.
:::

::: example
## Find the system matrix of the two-lens pair (100 mm and 50 mm, 30 mm apart), its focal length and its back focal distance.

::: solution
1. **Free space after lens 1.** Lens 1 followed by 30 mm of free space gives
   $$\begin{bmatrix} 0.7 & 30 \\ -0.01 & 1 \end{bmatrix}$$
2. **Then lens 2.**
   $$M = \begin{bmatrix} 0.7 & 30 \\ -0.024 & 0.4 \end{bmatrix}$$
3. **Check the determinant.**
   $$\begin{aligned} \det M &= 0.7 \times 0.4 + 30 \times 0.024 \\ &= 1 \end{aligned}$$
4. **Focal length.**
   $$\begin{aligned} f &= \frac{1}{0.024} \\ &= 41.7\ \text{mm} \end{aligned}$$
5. **Back focal distance.** A ray entering parallel at height $y_0$ leaves at $0.7y_0$ with angle $-0.024y_0$, so it crosses the axis
   $$\frac{0.7}{0.024} = 29.2\ \text{mm}$$
   after lens 2. That's the back focal distance, $f_2(f_1 - d)/(f_1 + f_2 - d)$.

**Answer:** $M = \begin{bmatrix} 0.7 & 30 \\ -0.024 & 0.4 \end{bmatrix}$, with a focal length of 41.7 mm and a back focal distance of 29.2 mm.
:::
:::

::: example
## Is a cavity with two concave mirrors of 1 m radius stable at 0.5 m, 1 m and 1.5 m spacing?

::: solution
1. **The g parameters.** With $g = 1 - d/R$ and R = 1 m, the three spacings give
   $$g = 0.5,\ 0,\ -0.5$$
2. **The stability products.**
   $$g_1g_2 = 0.25,\ 0,\ 0.25$$
   All three are stable, and the middle one (confocal) sits exactly at the center of the range.
3. **The concentric limit.** At 2 m, g = −1 and $g_1g_2$ = 1.
4. **A flat mirror.** A flat mirror facing a 1 m mirror at 0.5 m gives
   $$\begin{aligned} g_1g_2 &= 1 \times 0.5 \\ &= 0.5 \end{aligned}$$
   also stable.

**Answer:** all three are stable, with $g_1g_2$ = 0.25, 0 and 0.25; the 1 m (confocal) spacing sits at the center of the range.
:::
:::

::: example
## An object stands 150 mm in front of a 100 mm thin lens. Use the system matrix to find where it images, and the magnification.

::: solution
1. **System matrix.** From the object to a plane $d_2$ beyond the lens,
   $$\begin{aligned} M &= \begin{bmatrix} 1 & d_2 \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ -1/f & 1 \end{bmatrix} \\ &\quad \times \begin{bmatrix} 1 & d_1 \\ 0 & 1 \end{bmatrix} \end{aligned}$$
   whose B element is
   $$B = d_1 + d_2 - \frac{d_1d_2}{f}$$
2. **Set B to zero.** Imaging needs B = 0:
   $$\begin{aligned} d_2 &= \frac{d_1f}{d_1 - f} \\ &= \frac{150 \times 100}{50} \\ &= 300\ \text{mm} \end{aligned}$$
3. **Magnification.**
   $$\begin{aligned} A &= 1 - \frac{d_2}{f} \\ &= -2 \end{aligned}$$
   The image is inverted and twice the size.
4. **Check.** The unit determinant requires D = 1/A, and it is:
   $$\begin{aligned} D &= 1 - \frac{d_1}{f} \\ &= -0.5 \\ &= 1/A \end{aligned}$$

**Answer:** the object images 300 mm beyond the lens, inverted and twice the size (A = −2).
:::
:::

::: check
given: f = 25 | 50 | 100; a = 150 | 300 | 600
answer: 1/(1/f - 1/a)
unit: mm
tolerance: 0.5%

## An object sits {a} mm in front of a thin lens of focal length {f} mm. Where is its image?

::: right
Right. $1/(1/f - 1/a)$ = {answer} mm behind the lens.
:::

::: misses
- [1/(1/f + 1/a)] With the object outside the focal length, the image distance is $1/(1/f - 1/a)$.
- [any] Not yet. B = 0 for free space, lens, free space.
:::
:::

::: check
given: a = 50 | 100 | 200; b = 25 | 75; d = 10 | 40
answer: a*b/(a + b - d)
unit: mm
tolerance: 0.5%

## Two thin lenses of {a} mm and {b} mm focal length are {d} mm apart. What's the effective focal length?

::: right
Right. $f_1f_2/(f_1 + f_2 - d)$ = {answer} mm.
:::

::: misses
- [a*b/(a + b)] That's the lenses in contact; the spacing changes it.
- [any] Not yet. $f = -1/C$ of the product matrix.
:::
:::

::: check
given: a = 50 | 100 | 200; b = 25 | 75; d = 10 | 40
answer: b*(a - d)/(a + b - d)
unit: mm
tolerance: 0.5%

## For the same pair ({a} mm, then {b} mm, {d} mm apart), how far behind the second lens does a parallel beam focus?

::: right
Right. $f_2(f_1 - d)/(f_1 + f_2 - d)$ = {answer} mm.
:::

::: misses
- [a*b/(a + b - d)] That's the effective focal length, measured from a principal plane, not from the second lens.
- [any] Not yet. Trace a parallel ray: −A/C.
:::
:::

::: check
given: d = 0.3 | 0.8 | 1.2; R = 0.5 | 1 | 2; S = 1 | 3
answer: (1 - d/R)*(1 - d/S)
tolerance: 0.5%

## A laser cavity has concave mirrors of radius {R} m and {S} m, {d} m apart. What's $g_1g_2$?

::: right
Right. $(1 - d/R_1)(1 - d/R_2)$ = {answer}; stable if between 0 and 1.
:::

::: misses
- [any] Not yet. $g = 1 - d/R$ for each mirror.
:::
:::

::: check
given: y = 1 | 3 | 5; t = -0.02 | 0.01 | 0.03; d = 20 | 100; f = 40 | 150
answer: t - (y + d*t)/f
unit: rad
tolerance: 0.5%

## A ray at height {y} mm and angle {t} rad travels {d} mm and then passes a thin lens of {f} mm. What angle does it leave at?

::: right
Right. Height at the lens $y + d\theta$, then $\theta - y_\text{lens}/f$ = {answer} rad.
:::

::: misses
- [t - y/f] Use the ray's height at the lens, after the free-space step.
- [any] Not yet. Free space, then the lens.
:::
:::

::: check
given: f = 25 | 50 | 100; a = 150 | 300 | 600
answer: -1/(1/f - 1/a)/a
tolerance: 0.5%

## An object {a} mm in front of a {f} mm lens: what's the magnification of its image?

::: right
Right. $-b/a$ = {answer}.
:::

::: misses
- [1/(1/f - 1/a)/a] The image is inverted: the magnification is negative.
- [any] Not yet. Image distance over object distance, with a sign.
:::
:::

::: check
kind: parts
given: f = 50 | 100 | 200; k = 1.5 | 2.5 | 4

## An object stands {k} focal lengths in front of a {f} mm thin lens.

::: part
answer: k*f*f/(k*f - f)
unit: mm
tolerance: 0.5%

### How far behind the lens is its image?

::: misses
- [any] Set B = 0: $d_2 = d_1f/(d_1 - f)$.
:::
:::

::: part
answer: -1/(k - 1)
tolerance: 0.5%

### What is the magnification (A)?

::: misses
- [1/(k - 1)] A real image is inverted.
- [any] $A = 1 - d_2/f$.
:::
:::
:::

::: check
kind: derivation
vars: d = 0.01..3, a = 0.05..10, b = 0.05..10

## A resonator has mirrors of radii a and b (concave positive) a distance d apart.

::: step
answer: 1 - d/a

### What is $g_1$?
:::

::: step
answer: (1 - d/a)*(1 - d/b)

### What is $g_1g_2$, which must lie between 0 and 1 for stability?
:::

::: right
Right. The stability product depends only on the spacing relative to each mirror's radius.
:::
:::

::: explain
## Why does a ray-transfer matrix's determinant equal 1 when the system starts and ends in the same medium?

::: model
The determinant measures how the area of a bundle of rays in the plane of height and angle changes from input to output. Free space only shears that area, adding $d\theta$ to every height, and a thin lens only shears it the other way, changing angles in proportion to height; shears preserve area, so both have determinant 1. Refraction into a denser medium compresses angles by $n_1/n_2$, but leaving it again expands them by the inverse. The product of any sequence that ends in the starting medium therefore has determinant 1. It's the optical form of conservation of étendue: no passive system can concentrate a bundle of rays into less height–angle area.
:::
:::

::: practice

::: check
given: f = 10 | 200; a = 300 | 2000
answer: 1/(1/f - 1/a)
unit: mm
tolerance: 0.5%

## Image distance: f = {f} mm, object at {a} mm?

::: misses
- [any] $1/(1/f - 1/a)$.
:::
:::

::: check
given: a = 30 | 300; b = 20 | 150; d = 5 | 15
answer: a*b/(a + b - d)
unit: mm
tolerance: 0.5%

## Focal length of a pair: {a} and {b} mm, {d} mm apart?

::: misses
- [any] $f_1f_2/(f_1 + f_2 - d)$.
:::
:::

::: check
given: d = 0.1 | 1.5; R = 0.8 | 3; S = 0.8 | 3
answer: (1 - d/R)*(1 - d/S)
tolerance: 0.5%

## $g_1g_2$: d = {d} m, $R_1$ = {R} m, $R_2$ = {S} m?

::: misses
- [any] $(1 - d/R_1)(1 - d/R_2)$.
:::
:::
:::
