Solution (source code)

= Solution

Use transverse coordinates $(x,x')$ and a signed focusing strength $K$ in <Hill's equation>, $x''+Kx=0$. A drift of length $\ell$ has <beam transfer matrix>
$$
D(\ell)=\begin{pmatrix}1&\ell\\0&1\end{pmatrix}.
$$
For a uniform focusing <quadrupole magnet> with $K=\kappa^2>0$, and a defocusing one with $K=-\kappa^2$,
$$
\boxed{Q_F(\ell)=\begin{pmatrix}\cos\kappa\ell&\sin(\kappa\ell)/\kappa\\-\kappa\sin\kappa\ell&\cos\kappa\ell\end{pmatrix},\quad
Q_D(\ell)=\begin{pmatrix}\cosh\kappa\ell&\sinh(\kappa\ell)/\kappa\\\kappa\sinh\kappa\ell&\cosh\kappa\ell\end{pmatrix}.}
$$
The focusing plane has oscillatory trajectories, while the defocusing plane has hyperbolic growth and decay. A magnetic quadrupole focuses one transverse plane and defocuses the other; reversing its gradient interchanges their roles.

If $|K|\ell^2\ll1$ and the element's internal drift can be neglected or assigned separately, its kick may be concentrated at one position. With $1/f=|K|\ell$,
$$
\boxed{F=\begin{pmatrix}1&0\\-1/f&1\end{pmatrix},\qquad G=\begin{pmatrix}1&0\\1/f&1\end{pmatrix}.}
$$
Both kicks preserve position and change the slope linearly with displacement. All these ideal uncoupled maps have determinant one.