If a projectile is launched at a speed $u$ from a height $H$ above the horizontal axis, and air resistance is ignored, the maximum range of the projectile is $R_{\max }=\frac ug\sqrt{u^2+2gH}$, where $g$ is the acceleration due to gravity.
The angle of projection to achieve $R_{\max }$ is $θ = \arctan \left(\frac u{\sqrt{u^2+2gH}} \right)$.
Can someone help me derive $R_{\max }$ as given above?
I have tried substituting $y=0$ and $x=R$ into the trajectory equation
$$y=H+x \tan θ -x^2\frac g{2u^2}\left(1+\tan ^2\theta\right),$$
then differentiating with respect to $\theta$ so that we can let $\frac {dR}{d\theta}=0$ (so that $R=R_{\max }$), but this would eliminate the $H$, so it won't lead to the expression for $R_{\max }$ that I want to derive.
Here's a scan of where I got the problem from: