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?