Solution (source code)

= Solution

For fixed endpoints and a regular integral constraint, <Lagrange multipliers> replace the constrained stationarity problem by stationarity of $I-\lambda J$, with constant $\lambda$. Writing $H=F-\lambda G$, the <Euler-Lagrange equation> is $H_y-(d/dx)H_{y'}=0$. Regularity here means the <first variation> of $J$ is not identically zero; abnormal constraint extrema otherwise need separate consideration.

If $H$ has no explicit $x$ dependence, then
$$
\frac d{dx}(y'H_{y'}-H)=y'\left(\frac d{dx}H_{y'}-H_y\right)=0.
$$
This is the <Beltrami identity>, giving the required constant of integration.

For the chain, $ds=\sqrt{1+y'^2}\,dx$, so its fixed <arc length> is exactly $J[y]=L$, and its gravitational <energy> is $\rho g\int_{-a}^a y\sqrt{1+y'^2}\,dx$. The positive constant $\rho g$ can be suppressed in minimization. Use
$$
H=(y-\lambda)\sqrt{1+y'^2}.
$$
The equation, with a consistent sign convention for the multiplier, is
$$
\boxed{\sqrt{1+y'^2}-\frac d{dx}\left(\frac{(y-\lambda)y'}{\sqrt{1+y'^2}}\right)=0}.
$$
The first integral becomes $(y-\lambda)/\sqrt{1+y'^2}=c$. It implies $y''=(1+y'^2)/(y-\lambda)$; solving gives
$$
y=\lambda+c\cosh((x-x_0)/c).
$$
The equal endpoint heights force $x_0=0$, by evenness and strict increase of $\cosh$ on the positive half-line. Thus the extrema have the asserted <catenary> form. The length and height conditions give
$$
\boxed{L=2c\sinh(a/c),\qquad\lambda=b-c\cosh(a/c)}.
$$
For the hanging minimum choose $c>0$, the upward-convex branch lying below its endpoints. For $L>2a$ this positive $c$ is unique: writing $t=a/c$, the ratio $L/(2a)=\sinh(t)/t$ increases continuously from one to infinity. The negative-$c$ branch describes an upward arch, not the hanging minimum. If $L=2a$, only the horizontal straight chain is admissible and is the limiting degenerate case; $L<2a$ is impossible.