Solution (source code)

= Solution

For <maximum projectile range from an elevated launch>, let $X$ be horizontal <projectile range> from the tower and $\alpha$ the launch angle above horizontal. The <projectile motion> trajectory is
$$
y=h+X\tan\alpha-\frac{gX^2}{2u^2}(1+\tan^2\alpha).
$$
Put $z=\tan\alpha$. For a fixed $X$, its largest possible $y$ occurs at $z=u^2/(gX)$; the envelope is $y_{\max}=h+u^2/(2g)-gX^2/(2u^2)$. The furthest attainable ground point satisfies $y_{\max}=0$, so
$$
\boxed{X_{\max}=\frac ug\sqrt{u^2+2gh},\qquad \tan\alpha_{\rm opt}=\frac{u}{\sqrt{u^2+2gh}}.}
$$
The optimum angle is less than $45^\circ$ for $h>0$ and approaches $45^\circ$ as $h\to0$. The result is the maximum horizontal distance, using uniform gravity and no <drag>.