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: As you described, we substitute $y=0$ and $x=R$ into the trajectory equation:
$$0=H+R\tan{\theta}-R^2\frac{g}{2u^2}\sec^2\theta.\tag{1}$$
Then, differentiating with respect to $\theta$ and setting $\frac{dR}{d\theta}=0$:
$$0=R_{max}\sec^2\theta-R_{max}^2\frac{g}{2u^2}2\sec^2\theta\tan\theta,$$
which simplifies to
$$R_{max}=\frac{u^2}{g}\cot\theta.\tag{2}$$
Solving $(1)$ and $(2)$ will yield the desired expressions for $\theta$ and $R_{max}$.
A: Adapting concepts from the question and solutions here, we have
$$R_\text{max}=\frac {uw}g=\color{red}{\frac ug\sqrt{u^2+2gH}}$$
and
$$\tan\theta^*=\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.  
Addendum:
Here $\tan\theta^*$ was derived using $\theta^*=\frac \pi 4+\frac\alpha 2$, which leads to 
$$\tan\theta^*=\frac {1+\sin\alpha}{\cos\alpha}=\frac {\ell (1+\sin\alpha)}{\ell\cos\alpha}=\frac{\ell -H}{R_{\text{max}}}$$
as $\alpha$ is negative in this case.
