Maximum range of a projectile (launched from an elevation) 
If a projectile is launched at a speed $u$ from a height $H$ above
the horizontal axis, $g$ is the acceleration due to gravity, and air
resistance is ignored, its trajectory is
$$y=H+x \tan θ-x^2\frac g{2u^2}\left(1+\tan ^2\theta\right),$$
and its maximum range is
$$R_{\max }=\frac ug\sqrt{u^2+2gH}.$$

I would like to derive the above $R_{\max},$ and here's what I've done:

*

*substitute $(x,y)=(R,0)$ into the trajectory equation;

*differentiate the result with respect to $\theta;$

*substitute $\left(R,\frac {\mathrm dR}{\mathrm
    d\theta}\right)=\left(R_{\max},0\right).$
However, this eliminates $H$ and fails to lead to the desired expression for $R_{\max }.$ How to actually derive the above $R_{\max }?$
P.S. This is the context; in the above, I've replaced all occurrences of $L$ below with $\frac{u^2}g$.

 A: We are given the trajectory of a projectile: 
$$
y = H + x\tan(\theta) - \frac{g}{2u^2}x^2(1+\tan^2(\theta)),
$$
where $H$ is the initial height, $g$ is the (positive) gravitational constant and $u$ is the initial speed. Since we are looking for the maximum range we set $y=0$ (i.e. the projectile is on the ground). If we let $L=u^2/g$, then
$$
H + x\tan(\theta) - \frac1{2L}x^2(1+\tan^2(\theta)) = 0
$$ 
Differentiate both sides with respect to $\theta$.
$$
\frac{dx}{d\theta}\tan(\theta) + x\;\sec^2(\theta) - \left[\frac1L x \frac{dx}{d\theta}(1+\tan^2(\theta)) + \frac{1}{2L}x^2(2\tan(\theta)\sec^2(\theta))\right] = 0
$$
Solving for $\frac{dx}{d\theta}$ yields
$$
\frac{dx}{d\theta} = \frac{x \sec^2(\theta)[\frac{x}{L}\tan(\theta)-1]}{\tan(\theta)-\frac{x}{L}(1+\tan^2(\theta))}
$$
This derivative is $0$ when $\tan(\theta) = \frac{L}{x}$ and hence this corresponds to a critical number $\theta$ for the range of the projectile. We should now show that the $x$ value it corresponds to is a maximum, but I'll just assume that's the case. It pretty obvious in the setting of the problem. Finally, we replace $\tan(\theta)$ with $\frac{L}{x}$ in the second equation from the top and solve for $x$.
$$
H + L - \frac{1}{2L}x^2 - \frac{L}2 = 0.
$$
This leads immediately to $x = \sqrt{L^2 + 2LH}$. The angle $\theta$ can now be found easily.
A: 

its trajectory is $$y=H+x \tan θ-x^2\frac g{2u^2}\left(1+\tan ^2\theta\right)$$

I would like to derive the above $R_{\max},$ and here's what I've
done:

*

*substitute $(x,y)=(R,0)$ into the trajectory equation;

*differentiate the result with respect to $\theta;$

*substitute $\left(R,\frac {\mathrm dR}{\mathrm d\theta}\right)=\left(R_{\max},0\right).$

This is correct, and gives $$0=R_{\max}\sec^2\theta-R_{\max}^2\frac{g}{2u^2}2\tan\theta\sec^2\theta$$$$\tan\theta=\frac{u^2}{gR_{\max}}.\tag A$$
Step 1 also directly gives $$0=H+R_{\max}\tan θ-R_{\max}^2\frac g{2u^2}\left(1+\tan ^2\theta\right)$$$$\frac {gR_{\max}^2}{2u^2}\left(1+\tan ^2\theta\right)=H+R_{\max}\tan θ.\tag B$$
Substituting $(A)$ into $(B)$ then gives \begin{align}\frac{gR_{\max}^2}{2u^2}\left(1+\frac{u^4}{g^2R_{\max}^2}\right)&=H+\frac{u^2}g\\
\frac{gR_{\max}^2}{2u^2}+\frac{u^2}{2g}&=H+\frac{u^2}g\\
R_{\max}&=\sqrt{\frac{2u^2}g\left(H+\frac{u^2}{2g}\right)}\\
&=\sqrt{\frac{u^2}{g^2}\left(2gH+u^2\right)}\\
&=\frac ug\sqrt{u^2+2gH},\end{align} as desired.
A: There. is actually a much "classier, old school solution"  to this problem. I came across it as a question in an older A level M2 textbook by a remarkably inventive author  D. Quadling . I confess that I used the brute force  differentiation method to get through it but realised that Quadling had laid out the problem with a strong hint that a rather lovely simple solution was possible without calculus. 
Here are some hints, do shout if you need more( one needs to unravel this oneself to really appreciate its elegance.   
Take the standard cartesian  trajectory equation but with the emuzzle speed, u,written as  u= sqrt(ag).Now complete the square eg form ( xtan(theta)-a)^2 etc
Iam sure you will agree the result is stunning . 
Chris 
A: Adapting concepts from the question and solutions here, we have
$$R_\text{max}=\frac {uw}g=\frac {u\sqrt{u^2+2gH}}g=\color{red}{\frac ug\sqrt{u^2+2gH}}$$
and
$$\tan\phi=\frac {\ell-H}{\sqrt{\ell^2-H^2}}
=\frac {\frac {u^2}g}{\frac ug \sqrt{u^2+2gH}}=\color{red}{\frac u{\sqrt{u^2+2gH}}}$$
where $\ell$ is the linear distance between the launch and end points of the projectile. 
