Solution (source code)

= Solution

Enforce the fixed <arc length> with a multiplier. Apart from an irrelevant common factor, the augmented integrand is
$$
f=(gz+\lambda)\sqrt{1+z'^2}.
$$
The <Beltrami identity> gives
$$
\frac{gz+\lambda}{\sqrt{1+z'^2}}=\text{constant}.
$$
After absorbing constants into $z_0$ and a positive scale $B$, integration yields the <catenary>
$$
\boxed{z-z_0=-B\cosh(x/B)}.
$$
The endpoint conditions and prescribed length give
$$
\boxed{z_0=B\cosh(a/B),
\qquad L=2B\sinh(a/B)}.
$$
The second equation determines $B>0$ implicitly because $L>2a$, and the first then determines $z_0$.