Show that the full Euler-Lagrange equation of the Brachistochrone is $2y(x)y''(x)+y'(x)^2+1=0$ This question I have is related to this previous question I asked regarding the Brachistochrone problem, so here are some background details from the previous link:


If a point-like mass is rolling down a hill from a point $A$ to a point $B$, the time it takes the mass to get from $A$ to $B$ depends on the profile of the hill. The Brachistochrone Curve is the profile that minimizes the time and we can find this profile using a Lagrangian extremization procedure. You can easily convince yourself that one can always find profiles which would make the time taken arbitrarily long, so if one finds a finite curve that extremizes the time taken, that curve should necessarily be a minimum.
Before jumping to the core of this problem, let us first look at the ‘cycloid’ curve, which can be thought of as the curve a fixed point on a circle of radius $R$ draws as the circle ‘rolls’ along a straight line (see left of Fig. 4). With $\theta$ as the angle parameterizing the circle’s rotation, the coordinates on the curve are
$$x=R(\theta-\sin\theta)\quad\text{and}\quad y=R(1-\cos\theta)$$
The derivatives along that curve are $x'(\theta) = R(1-\cos\theta)$ and $y'(\theta)=R \sin\theta$ and bearing in mind that $\cos\theta=1-y/R$, ie $x'(\theta)=y$, we have
$$\left(x'(y)\right)^{-1}=y'(x)=\frac{\mathrm{d}y}{\mathrm{d}x}=\frac{y'(\theta)}{x'(\theta)}=\sqrt\frac{2R-y}{y}\tag{1}$$


Start of new question:

Instead of parameterizing the trajectory as a function $x(y)$ we could have decided to parameterize the trajectory as a function $y(x)$. Show that finding the trajectory $y(x)$ that leads to the quickest descent between the origin and the point B can also be formulated as a Lagrangian problem. Determine the relevant action, Lagrangian and coordinates. What are the resulting equations of motions.


The author's solution (shown directly below) makes no attempt to derive the equation in the title (which is what I am trying to show):

We have $$T=\int dt=\int\sqrt{\frac{\mathrm{d}x^2+\mathrm{d}y^2}{2gy(x)}}=\int_0^{x_B}\sqrt{\frac{y'(x)^2+1}{2gy(x)}}\mathrm{d}x$$
Now we can see the total time $T$ as a functional of the path $y(x)$ chosen to connect both points with fixed boundary conditions, the problem therefore reduces to one of Lagrangian mechanics where $T[y(x)]$ plays the role of the action, $L = \sqrt{\frac{y'(x)^2+1}{2gy(x)}}$ plays the role of the Lagrangian. In this language, the generalized coordinate is $y$ which is a function of $x$ (so $x$ plays the role of the ‘time’ $t$ is the standard Lagrangian formulation. The Euler Lagrange equations are
$$\frac{\partial L}{\partial y(x)}-\frac{\mathrm{d}}{\mathrm{d}x}\frac{\partial L}{\partial y'(x)}=0\tag{A}$$
In the previous formulation, the Lagrangian did not depend on the coordinate itself (only on its derivative). This is no longer the case here as we see that this new Lagrangian depends both on $y(x)$ and $y' (x)$. Note however that the Lagrangian does not depend explicitly on $x$ so the Hamiltonian is conserved in this formulation. Unsurprisingly, the number of conserved quantities s the same in both formulation. The full Euler-Lagrange equation is
$$2y(x)y''(x)+y'(x)^2+1=0\tag{B}$$

I am trying to reach eqn $(\mathrm{B})$.
So starting with the leftmost term of $(\mathrm{A})$:
$$\begin{align}\frac{\partial L}{\partial y(x)}&=\frac{\partial}{\partial y(x)}\left({\frac{y'(x)^2+1}{2gy(x)}}\right)^{1/2}\\&=\sqrt{\frac{y'(x)^2+1}{2g}}\frac{\partial}{\partial y(x)}\left(y(x)^{-1/2}\right)\\&=-\frac12y(x)^{-3/2}\sqrt{\frac{y'(x)^2+1}{2g}}\end{align}$$
Now moving on the right hand term of $(\mathrm{A})$:
$$\begin{align}\frac{\partial L}{\partial y'(x)}&=\frac{\partial}{\partial y'(x)}\left({\frac{y'(x)^2+1}{2gy(x)}}\right)^{1/2}\\&=\frac{1}{2}\times 2y'(x)\left(y'(x)^2+1\right)^{-1/2}\times \frac{1}{\sqrt{2gy(x)}}\\&=\frac{y'(x)}{\sqrt{2gy(x)}\sqrt{1+y'(x)^2}}\end{align}$$
and so
$$\begin{align}-\frac{\mathrm{d}}{\mathrm{d}x}\frac{\partial L}{\partial y'(x)}&=-\frac{1}{\sqrt{2g}}\frac{\mathrm{d}}{\mathrm{d}x}\left(y'(x)\left(y(x)\left[1+y'(x)^2\right]\right)^{-1/2}\right)\\&=-\frac{1}{\sqrt{2g}}\left(y''(x)\left(y(x)\left[1+y'(x)^2\right]\right)^{-1/2}-\frac12y'(x)^{-3/2}y'(x)\left[1+y'(x)^2\right]^{-1/2}-\frac12\times 2y''(x)y'(x)y(x)^{-1/2}\left[1+y'(x)^2\right]^{-3/2}\right)\\&=-\frac{1}{\sqrt{2g}}\left(y''(x)\left(y(x)\left[1+y'(x)^2\right]\right)^{-1/2}-\frac12y'(x)^{-1/2}\left[1+y'(x)^2\right]^{-1/2}-y''(x)y'(x)y(x)^{-1/2}\left[1+y'(x)^2\right]^{-3/2}\right)\tag{C}\end{align}$$
Now putting it all together eqn $(\mathrm{A})$ implies
$$\frac{\partial L}{\partial y(x)}-\frac{\mathrm{d}}{\mathrm{d}x}\frac{\partial L}{\partial y'(x)}=0$$
$$\implies-\frac12y(x)^{-3/2}\sqrt{\frac{y'(x)^2+1}{2g}}+\frac{1}{\sqrt{2g}}\left(y''(x)\left(y(x)\left[1+y'(x)^2\right]\right)^{-1/2}-\frac12y'(x)^{-1/2}\left[1+y'(x)^2\right]^{-1/2}-y''(x)y'(x)y(x)^{-1/2}\left[1+y'(x)^2\right]^{-3/2}\right)=0$$
I know this can be simplified a little, but I'm getting the impression that I have made a mistake or used the wrong approach (by using the triple product rule) to get $(\mathrm{C})$ for the $-\frac{\mathrm{d}}{\mathrm{d}x}\frac{\partial L}{\partial y'(x)}$ part of $(\mathrm{A})$.
Any hints or tips that will lead me closer to $2y(x)y''(x)+y'(x)^2+1=0\tag{B}$ please?
 A: $\newcommand{\d}{\mathrm{d}}\newcommand{\p}{\partial}$I don't blame you for being daunted by the awful product rule expressions! It's possible you made a mistake, I didn't check super closely, but in the following derivations you find the differentiation goes from bad, to worse, to cancelling very nicely.
I will interchange index notation with square root notation whenever one form is more revealing than the other, for my own sake really, as I type this.
We have:
$$\frac{\p L}{\p y(x)}=\frac{\d}{\d x}\frac{\p L}{\p y'(x)},\quad L(y,y')=\sqrt{\frac{(y')^2+1}{2g\cdot y}}$$
The LHS is:
$$\begin{align}\frac{1}{2}\frac{\p}{\p y}\left(\frac{(y')^2+1}{2g\cdot y}\right)\left(\frac{(y')^2+1}{2g\cdot y}\right)^{-1/2}&=-g\cdot((y')^2+1)(2g\cdot y)^{-2}\left(\frac{(y')^2+1}{2g\cdot y}\right)^{-1/2}\\&=-\frac{1}{4g}\cdot\frac{(y')^2+1}{y^2}\cdot\sqrt{\frac{2g\cdot y}{(y')^2+1}}\\&=-\frac{1}{4g\cdot y^2}\cdot\sqrt{2g\cdot y((y')^2+1)}\end{align}$$
And the RHS is:
$$\begin{align}\frac{\d}{\d x}\left[\frac{1}{2}\cdot\left(\frac{2y'}{2g\cdot y}\right)\left(\frac{(y')^2+1}{2g\cdot y}\right)^{-1/2}\right]&=\frac{\d}{\d x}\left[\frac{y'}{2g\cdot y}\cdot\sqrt{\frac{2g\cdot y}{(y')^2+1}}\right]\\&=\frac{\d}{\d x}\left[y'\cdot(2g\cdot y((y')^2+1))^{-1/2}\right]\\&=y''\cdot[2g\cdot y((y')^2+1)]^{-1/2}\\&\hspace{10pt}+y'\color{red}{\frac{\d}{\d x}[2g\cdot y((y')^2+1)]^{-1/2}}\end{align}$$
I will evaluate the red part separately:
$$\begin{align}\color{red}{\text{red}}&=\frac{\d}{\d x}[(2g\cdot y)^{-1/2}\cdot((y')^2+1)^{-1/2}]\\&=-g\cdot y'(2g\cdot y)^{-3/2}((y')^2+1)^{-1/2}-y'\cdot y''((y')^2+1)^{-3/2}(2g\cdot y)^{-1/2}\end{align}$$
So the RHS becomes:
$$y''(2g\cdot y((y')^2+1))^{-1/2}-g\cdot(y')^2(2g\cdot y)^{-3/2}((y')^2+1)^{-1/2}\\-(y')^2\cdot y''((y')^2+1)^{-3/2}(2g\cdot y)^{-1/2}$$
Ugly, but it can be regrouped to:
$$y''\left[\frac{1}{\sqrt{2g\cdot y((y')^2+1)}}-(y')^2\cdot\frac{1}{((y')^2+1)\sqrt{2g\cdot y((y')^2+1)}}\right]\\-g\cdot(y')^2\cdot\frac{1}{2g\cdot y\sqrt{2g\cdot y((y')^2+1)}}$$
Which equals, if I add some fractions:
$$\frac{2g\cdot y\cdot y''}{(2g\cdot y)((y')^2+1)\sqrt{2g\cdot y((y')^2+1)}}-\frac{g\cdot(y')^2\cdot((y')^2+1)}{(2g\cdot y)((y')^2+1)\sqrt{2g\cdot y((y')^2+1)}}\\\overset{\text{LHS}}{=}-\frac{1}{4g\cdot y^2}\sqrt{2g\cdot y((y')^2+1)}$$
This quantity $2g\cdot y((y')^2+1)$ keeps cropping up. I'll call it $u$ for brevity.
Clearing denominators, we find (being careful with the negative sign on the RHS - that tripped me up on the first time I tried typing this!):
$$u^2=-8g^2y^3y''+4g^2(y\cdot y')^2((y')^2+1)=-\frac{4gy^2y''}{(y')^2+1}u+2gy(y')^2u$$
Dividing by $u$:
$$2gy((y')^2+1)=u=-\frac{4gy^2y''}{(y')^2+1}+2gy(y')^2$$
Some more algebra:
$$1=-\frac{2yy''}{(y')^2+1},\quad (y')^2+1=-2yy'',\quad 2\cdot y(x)y''(x)+y'(x)^2+1=0\quad\blacksquare$$
A: I haven't checked your computations yet, but there are two simpler methods we can use.

Method 1: Your approach.
Since the RHS of the Euler-Lagrange equation is zero we can omit the constant $\sqrt{2g}$.
Define $\displaystyle L=\sqrt{\frac{y'^2+1}y}$ so $\displaystyle\frac{\partial L}{\partial y}=-\frac{y'^2+1}{2y^2L}=-\frac L{2y}$ and $\displaystyle\frac{\partial L}{\partial y'}=\frac{y'}{yL}$.
As $\displaystyle L'=\frac{2yy'y''-y'(y'^2+1)}{2y^2L}=\frac{2y'y''-y'L^2}{2yL}$, the Euler-Lagrange equation becomes \begin{align}0&=\frac L{2y}+\left(\frac{y'}{yL}\right)'=\frac L{2y}+\frac{y''yL-y'\left(y'L+y\cdot\frac{2y'y''-y'L^2}{2yL}\right)}{y^2L^2}\\&=\frac L{2y}+\frac{(yy''-y'^2)L-y'^2\cdot\frac{2y''-L^2}{2L}}{y^2L^2}.\end{align} Multiplying both sides by $2(yL)^3$ yields \begin{align}0&=y(yL^4+2(y''y-y'^2)L^2-y'^2(2y''-L^2))\\&=y(yL^4+(2yy''-y'^2)L^2-2y'^2y'')\\&=(y'^2+1)^2+(2yy''-y'^2)(y'^2+1)-2yy'^2y''\\&=y'^2+1+2yy''\end{align} as desired.

Method 2: Beltrami Identity.
The Beltrami identity states that if the functional at hand is independent of $x$ then the Euler-Lagrange equation becomes $$0=\left(L-y'\frac{\partial L'}{\partial y'}\right)'=\left(\frac{yL^2-y'^2}{yL}\right)'=\left(\frac1{yL}\right)'=-\frac{y'L+yL'}{y^2L^2}$$ or that $$0=y'L^2+yLL'=y'L^2+\frac{2y'y''-y'L^2}2=y'y''+\frac{y'}2\frac{y'^2+1}y$$ which immediately gives $2yy''+y'^2+1=0$ on dividing by $y'$.
Note that we can solve the equation directly from here by writing $yL=c$ for some constant $c$ and using separation by variables.
