Finding the optimal angle of a projectile motion I am trying to solve a task in which I need to calculate the optimal angle($\alpha$) with which the projectile will land the furthest from a height ($h$), so what I basically have is the equations for the projectile's movement:
$$
x = v_0 \cos\alpha  t
$$
$$
y = h + v_0\ \sin\alpha t - \frac{gt^2}{2}
$$
$$
t_{y=0} = \frac{v_0\sin\alpha+\sqrt{(v_0\sin\alpha)^2 + 2gh}}{g}
$$
I know that at height $h=0$ the optimal angle is $\alpha = 45^\circ$ and I can calculate the range $x$, but I don't know how to calculate the angle.
 A: Substitute $t$ into $x(t)$ to get the throw distance and maximize this expression with respect to angle $\alpha$, i.e. set its derivative zero and solve for optimal the angle.
A: It will help to scale the problem by defining  the dimensionless variable 
$$
\delta=\frac{2gh}{v_0^2}.
$$
Notice that we can take the limit $\delta\rightarrow0$ to recover the solution when $h=0$ in which case we expect to get $\alpha=\tfrac{\pi}{4}$.
With this substitution your expression for the time at which the projectile hits the ground becomes
$$
t_{y=0}=\frac{v_0}{g}\left(\sqrt{\sin^2\alpha+\delta}+\sin\alpha\right).
$$
Substituting this into the expression for $x(t)$ gives
$$
x(t_{y=0})=\frac{v_0^2}{g}\cos\alpha\left(\sqrt{\sin^2\alpha+\delta}+\sin\alpha\right).
$$
It is this expression that we want to maximize with respect to $\alpha$.  Taking the first derivative gives
$$
\frac{d}{d\alpha}x(t_{y=0})=
   \frac{v_0^2}{g}\left(\cos^2\alpha\left(\frac{\sin\alpha}
   {\sqrt{\sin^2\alpha+\delta}}+1\right)
   -\sin\alpha\left(\sqrt{\sin^2\alpha+\delta}+\sin\alpha\right)
   \right).
$$
Now we set this equal to zero and solve for $\alpha$.  At the outset, I honestly didn't think the problem would have a closed form solution, but Mathematica had no trouble inverting this equation.  The final result (choosing the physical result) is
$$
\alpha=\arccos\left(\frac{\sqrt{\delta+1}}{\sqrt{\delta+2}}\right)
$$
We can check this solution at the usual limits; at $\delta=0$ we get $\alpha=\tfrac{\pi}{4}$ and at $\delta=\infty$ (the platform is very high) we get $\alpha=0$ both of which sound good.  Notice that for $\delta<-1$ the solution gives imaginary results which are unphysical.  This is because when $\delta<-1$ the launch platform is so far underground that the initial speed $v_0$ is not even enough to get it to the surface.  With this in mind, we can check one final limit of the problem; if $\delta=-1$, then the initial velocity is just enough to get the projectile to $y=0$ and the launch angle we find is $\alpha=\tfrac{\pi}{2}$ which is pointing the gun straight up.
