= Solution
Take the launch point as $(x,y)=(0,0)$ and ignore air <drag>. In <projectile motion> with constant <gravitational acceleration> $g$, a launch at <angle> $\theta$ above the horizontal gives
$$
x=v_0t\cos\theta,\qquad y=v_0t\sin\theta-\frac12gt^2.
$$
At the wall $x=l$, the height is
$$
y(l)=l\tan\theta-\frac{gl^2}{2v_0^2}\sec^2\theta
=lq-\frac{gl^2}{2v_0^2}(1+q^2),\qquad q=\tan\theta.
$$
This is a concave <quadratic polynomial> in $q$, so its unique maximum satisfies $l-gl^2q/v_0^2=0$. Hence
$$
\boxed{\theta_{\max}=\arctan\frac{v_0^2}{gl},\qquad y_{\max}(l)=\frac{v_0^2}{2g}-\frac{gl^2}{2v_0^2}.}
$$
For $l=v_0^2/g$, the best trajectory has $\theta=45^\circ$ and reaches the wall at launch height. For $l>v_0^2/g$, the mathematical maximum height is negative. If the ball must stay above level ground, it lands before reaching the wall: $v_0^2/g$ is the maximum same-level <projectile range>. If there is no intervening ground and the wall extends below the launch height, the same optimum still applies, but its impact point is below that height.
Back to article page