Brachistochrone to a vertical line Just for fun, I am working through some problems in Mathematics of Classical and Quantum Physics by Byron and Fuller.  Problem 2.13 reads:

Prove that a particle moving under gravity in a plane from a fixed point $P$ to a vertical line $L$ will reach the line in minimum time by following the cycloid from $P$ to $L$ that intersects $L$ at right angles.

Solving the Brachistochrone is more or less straightforward calculus of variations, taking $P$ to be the origin wlog.  The action to be minimized is given by (ignoring the optimization irrelevant leading factor of $\frac{1}{\sqrt{2g}}$):
$$
  f(x, y, y') = \sqrt{\frac{1 + {\left(\frac{dy}{dx}\right)}^2}{y}}
$$
And the derivation of the resulting cycloid, which can be found literally everywhere, gives the parametric function:
\begin{align*}
  x &= a(\theta - \sin \theta) \\
  y &= a(1 - \cos \theta)
\end{align*}
Where $a$ is a free parameter allowed to vary. (Note: gravity is taken to be in the y-positive direction to eliminate a pair of redundant minus signs.) If $L$ is taken to be the line $x = x_b$, then in theory it ought to be possible to minimize the cost function with respect to $a$.
If the cycloid intersects the line at a right angle, then it follows that
$\frac{dy}{d\theta} = 0$ and $\frac{dx}{d\theta} \ne 0$ at the point of intersection.
\begin{align*}
  \frac{dy}{d\theta} = 0 &= a \sin(\theta) \\
  \theta &= n\pi : n \in \mathbb{Z} \\
  \frac{dx}{d\theta} \ne 0 &= a(1 - \cos \theta) \\
  \theta &\ne 2n\pi : n \in \mathbb{Z}
\end{align*}
Because only the first solution could possibly be the curve of fastest descent,
the value of $\theta$ must be $\pi$, which gives $a = x_b / \pi$. So, if we take the derivative of the cost function with respect to $a$ and set it equal to zero, it ought to be the case that we find the equal yields this value.  Unfortunately, this is not what I find.  Instead, I think I might be being too careless with what is a function of what.
The cost function is given by:
$$
  I = \int_0^{x_b} \sqrt{\frac{x'^2 + y'^2}{y}} dx
$$
Where $x$ and $y$ are functions of $\theta$, and their primed derivatives are with respect to $\theta$.
The most problematic part is going to be finding the upper limit ($\theta_b$),
which we only know implicitly:
$$
  x_b = a(\theta_b - \sin \theta_b)
$$
Because $\theta_b$ is also a function of $a$, it is necessarily to make this
explicit.  So let $\theta_b(a)$ be the unique solution to the aforementioned
implicit equation.  With some algebraic manipulation $I$ becomes:
\begin{align*}
  I &= \int_0^{x_b} \sqrt{\frac{{x'(\theta)}^2 + {y'(\theta)}^2}{y(\theta)}} dx \\
  &= \int_0^{\theta_b(a)} a(1 - \cos \theta) \sqrt{\frac{a^2{(1 - \cos \theta)}^2 + a^2{(\sin \theta)}^2}{a(1-\cos \theta)}} d\theta \\
  &= \int_0^{\theta_b(a)} a(1 - \cos \theta) \sqrt{2a} d\theta \\
  &= {\left[\sqrt{2} a^{3/2} (\theta - \sin \theta)\right]}_{0}^{\theta_b(a)} \\
  &= \sqrt{2} a^{3/2} (\theta_b(a) - \sin \theta_b(a)) \\
\end{align*}
Next, take the derivative and set to 0.
\begin{align*}
 \frac{dI}{da} = 0 &= \frac1{\sqrt{2a}} (3a(\theta_b(a) - \sin \theta_b(a)) + 2a^2 \theta_b'(a) (1 - \cos \theta_b(a))) \\
  &= \frac1{\sqrt{2a}}(3x_b + 2a^2 \theta_b'(a) (1 - \cos \theta_b(a)))
\end{align*}
From here, we have to take care to find $\theta_b'(a)$.
\begin{align*}
  x_b &= a(\theta_b(a) - \sin \theta_b(a)) \\
  \frac{d}{da} x_b &= \frac{d}{da} (a(\theta_b(a) - \sin \theta_b(a))) \\
  0 &= \theta_b(a) - \sin \theta_b(a) + a \theta_b'(a) (1 - \cos \theta_b(a)) \\
  \theta_b'(a) &= - \frac{\theta_b(a) - \sin \theta_b(a)}{a (1 - \cos \theta_b(a))} \\
\end{align*}
Now to continue solving:
\begin{align*}
  0 &= \frac1{\sqrt{2a}}(3x_b + 2a^2 \theta_b'(a) (1 - \cos \theta_b(a))) \\
  &= \frac1{\sqrt{2a}}(3x_b - 2x_b) \\
  &= \frac{x_b}{\sqrt{2a}}
\end{align*}
Which seems to imply that the critical point lies at $a = +\infty$, which is clearly wrong (given this would imply an infinite distance to travel), and also not equal to the previously found value $a = x_b/\pi$.  Which begs the question, where is my error?  And is there a better approach for this problem?
 A: Hint :
You must start from the time to travel between $\theta_1$ and $\theta_2$ on a cycloid :
\begin{equation}
t_{2}-t_{1}=\sqrt{\dfrac{\,R\,}{g}}\, \int\limits_{\theta_{1}}^{\theta_{2}}\mathrm{d}\theta=\sqrt{\dfrac{\,R\,}{g}}\, \left(\theta_{2}-\theta_{1}\right)
\tag{01}\label{01}
\end{equation}
If the motion of the particle starts at $\left(x_{1},y_{1}\right)=\left(0,0\right)$, so $\:\theta_{1}=0\:$, then the time $\:t\:$ needed to reach at $\left(x_{2},y_{2}\right)=\left(x,y\right)$, with $\:\theta_{2}=\theta \:$, is
\begin{equation}
t=\sqrt{\dfrac{\,R\,}{g}}\, \theta = \dfrac{\theta}{\omega}
\tag{02}\label{02}
\end{equation}
where
\begin{equation}
 \omega = \dfrac{\,\theta \,}{t}=\dfrac{\mathrm{d}\theta }{\mathrm{d} t}=\sqrt{\dfrac{\,g\,}{R}}=\text{constant}
\tag{03}\label{03}
\end{equation}
Note : The variable $\,R\,$ is yours $\,a$.
Then think of a $\,R-$parametric family of cycloids intersecting the vertical line with $\theta(R)$. The time for the $\,R-$cycloid would be
\begin{equation}
t(R)=\sqrt{\dfrac{\,R\,}{g}}\, \theta(R) 
\tag{04}\label{04}
\end{equation}
and for the minimum $\,t(R)\,$  find the roots of
\begin{equation}
\dfrac{\mathrm d t(R)}{\mathrm d R}=0
\tag{05}\label{05}
\end{equation}
The angle $\theta(R)$ is the following  implicit function of $\,R$(1)
\begin{equation}
\theta(R)-\sin\left[\theta(R)\right]=L/R
\tag{06}\label{06}
\end{equation}
where $\,L\,$ the horizontal distance of the vertical line from point $\texttt P$.
We must remind that the slope $\,\mathrm d y(\theta)/\mathrm d x(\theta)\,$ on a cycloid and the angle $\,\theta\,$ are related as follows
\begin{equation}
\dfrac{\mathrm d y}{\mathrm d x}=\dfrac{\sin\theta}{1-\cos\theta}=\cot\left(\dfrac{\theta}{2}\right)
\tag{07}\label{07}
\end{equation}

$=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!$
(1)
The angle $\,\theta(L/R)\,$ as function of the dimensionless variable $\,L/R\,$ would have a graph like that in Figure-02 below. Note that for $\,L/R=k\pi\,(k=1,2,3\cdots)\,$ we have $\,\theta\left(L/R\right)=k\pi\,$ while the graph is repeat of a segment of width  $\,2\pi$ : $\,\theta\left(L/R+2\pi\right)=\theta\left(L/R\right)+2\pi\,$.


$=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!=\!$
\begin{equation}
\sqrt{g}\,\dfrac{\mathrm d t(R)}{\mathrm d R}\boldsymbol{=}\dfrac{\mathrm d }{\mathrm d R}\left(\sqrt{R}\,\theta\right)\boldsymbol{=}\dfrac{1}{2\sqrt{R}}\,\theta\boldsymbol{+}\sqrt{R}\,\dfrac{\mathrm d \theta}{\mathrm d R}
\tag{08}\label{08}
\end{equation}
\begin{equation}
\theta\boldsymbol{=}\sin\theta\boldsymbol{+}\dfrac{L}{R} \boldsymbol{\implies} 
\tag{09}\label{09}
\end{equation}
\begin{equation}
\dfrac{\mathrm d \theta}{\mathrm d R}\boldsymbol{=}\cos\theta\dfrac{\mathrm d \theta}{\mathrm d R}\boldsymbol{-}\dfrac{L}{R^2} \boldsymbol{\implies} 
\nonumber
\end{equation}
\begin{equation}
\dfrac{\mathrm d \theta}{\mathrm d R}\boldsymbol{=}\boldsymbol{-}\dfrac{L}{(1\boldsymbol{-}\cos\theta)R^2}
\tag{10}\label{10}
\end{equation}
\eqref{08},\eqref{09},\eqref{10} $\:\boldsymbol{\implies}$
\begin{equation}
\sqrt{g}\,\dfrac{\mathrm d t(R)}{\mathrm d R}\boldsymbol{=}\dfrac{1}{2\sqrt{R}}\left(\sin\theta\boldsymbol{+}\dfrac{L}{R}\right)\boldsymbol{-}\sqrt{R}\dfrac{L}{(1\boldsymbol{-}\cos\theta)R^2}
\tag{11}\label{11} 
\end{equation}
\begin{equation}
\dfrac{\mathrm d t(R)}{\mathrm d R}\boldsymbol{=}0 \quad \boldsymbol{\implies}\quad \cos\left(\dfrac{\theta}{2}\right)\cdot \left[\sin^3\left(\dfrac{\theta}{2}\right)\boldsymbol{-}\dfrac{L}{2R}\cos\left(\dfrac{\theta}{2}\right)\right]\boldsymbol{=}0 
\tag{12}\label{12} 
\end{equation}
etc
A: Hints:

*

*To have a well-defined variational problem, we have to impose adequate boundary conditions (BC). Recall in particular that BCs are necessary$^1$ for the proof of the Euler-Lagrange (EL) equation.


*The initial BC is an essential/Dirichlet BC  $y(x\!=\!x_i)=y_i$. However, the final BC is clearly not an essential/Dirichlet BC. It must then for consistency reasons be a natural BC $p(x\!=\!x_f)=0$. This turns out to be a Neumann BC $y^{\prime}(x\!=\!x_f)=0$, i.e. the final tangent is horizontal/forms a right angle with the vertical line.


*Since the EL equation of the modified brachistochrone problem is unchanged, the solution is still a cycloid.
--
$^1$ Conversely, if we haven't fixed the BCs, we cannot assume the EL equation.
