A problem in navigation Consider a river with straight, parallel banks a distance $a$ apart, and boat that can travel with constant speed $c$ in still water. The problem is to cross the river in the shortest time, starting and landing at given points, when there is a current.
We choose the $y$ -axis to be the left bank, the line $x=a$ to be the right bank, and the starting point to be the origin. The water is assumed to be moving parallel to the banks with speed $v(x)$, a known function of the distance from the left bank. Then the time of passage along the path $y(x)$ from the point $(0,0)$ on the left bank to the point $(a, A)$ on the right bank, assuming that $c>\max (v(x))$, can be shown to be
$$
T[y]=\int_{0}^{a} \frac{\sqrt{c^{2}\left(1+\left(y^{\prime}\right)^{2}\right)-v(x)^{2}}-v(x) y^{\prime}}{c^{2}-v(x)^{2}} d x, \quad y(0)=0, y(a)=A
$$
The map $T$ is a functional: it maps paths $y(x)$ to the times to cross the river, and the problem is to find paths that minimise $T[y]$. Notice that $T$ also depends explicitly on the speed profile $v(x)$.

Question: I try to use knowlegde of relative speed to derive the formula illustrated above, but I failed. Who can help me? Thanks very much!
 A: Let's start with the components of the velocity of the boat $\vec{V}$
$$  \begin{align} V_x&=c \cos \theta \\ V_y&=r + c \sin \theta \text{ }\end{align} $$
where $\theta$ is the steering angle and $r(x)$ is the river speed you called $v(x)$. Clearly, we have that the time it takes to cross the river is given by
$$ T = \int \text{d}t = \int \frac{\text{d}x}{\|V_x\|} = \int \frac{\text{d}x}{ c \cos \theta } = \int \frac{1}{c}\sec \theta \: \text{d}x \text{ .}$$
$ \:$
$ \:$
By the chain rule, if we say that $y=y(x)$ then
$$ \dfrac{\text{d}y}{\text{d}t} = \dfrac{\text{d}y}{\text{d}x} \: \dfrac{\text{d}x}{\text{d}t} $$
and so we get
$$\begin{align} &\dfrac{\text{d}y}{\text{d}x} = \frac{\dot{y}}{\dot{x}} = \frac{V_y}{V_x} = \frac{r + c \sin \theta}{c \cos \theta}\\\\ \implies &\dfrac{\text{d}y}{\text{d}x} =\frac{r}{c}\sec \theta \: + \tan \theta  \\\\ \implies &\dfrac{\text{d}y}{\text{d}x} = \frac{r}{c}\sec \theta \: + \sqrt{\sec^2 \theta - 1}\end{align}$$
just by using a neat trig identity. This is now a quadratic for $\sec \theta$ so we rearrange as
$$ \bigg(  \frac{r^2}{c^2} - 1 \bigg)\sec^2 \theta \: - \frac{2ry'}{c}\sec{\theta} \: + (y')^2 + 1 = 0 $$
where $\dfrac{dy}{dx}=y'$. We use quadratic formula to obtain
$$ \sec{\theta} = \frac{\frac{2ry'}{c} \pm \sqrt{ 4(y'^2 - \frac{r^2}{c^2} + 1) }}{ 2\bigg(\frac{r^2}{c^2} - 1\bigg) } \text{ .} $$
I'm simplifying a tad because I'm too lazy to write it all out. What we get is that the $b^2$ term in $b^2 - 4ac$ cancels with part of the $4ac$.
We can rewrite the denominator as
$$ 2\bigg(\frac{r^2}{c^2} - 1\bigg) = 2\bigg(\frac{r^2 - c^2}{c^2}\bigg) = -2\bigg(\frac{c^2 - r^2}{c^2}\bigg) $$
which gives us that
$$ \begin{align} &\frac{1}{c}\sec{\theta} = \frac{-ry' \mp c\sqrt{ y'^2 - \frac{r^2}{c^2} + 1 }}{ \bigg(c^2 - r^2\bigg) } \\\\ \implies 
&\frac{1}{c}\sec{\theta} = \frac{-ry' \mp \sqrt{ c^2(y'^2+1) - {r^2} }}{ \bigg(c^2 - r^2\bigg) }  \text{ .} \end{align} $$
Take the appropriate root for $\sec\theta$ and substitute it into our functional for $T$.
If I skipped over too much and you can't seem to fill in the details just let me know and I'll make the appropriate edits.
