Solution (source code)

= Solution

Represent a paraxial ray by its height and forward slope $(x,\theta)^{\mathsf T}$, with $\theta=dx/dz$. Free-space propagation leaves the slope unchanged and increases height by $L\theta$, giving
$$
\boxed{P(L)=\begin{pmatrix}1&L\\0&1\end{pmatrix}.}
$$
A <thin lens> leaves the ray height unchanged. A parallel incident ray at height $x$ must emerge toward the focal point, so its slope changes by $-x/f$. By linearity, the same increment applies to any paraxial incident slope:
$$
\boxed{F(f)=\begin{pmatrix}1&0\\-1/f&1\end{pmatrix}.}
$$
These <ray transfer matrices> have determinant one in air and compose in reverse <matrix> order to the physical order of traversal.