Learning Scientific Programming with Python (2nd edition)

P2.7.5: Range and height of a projectile

Question P2.7.5

The range of a projectile launched at an angle $\alpha$ and speed $v$ on flat terrain is: $$ R = \frac{v^2\sin2\alpha}{g}, $$ where $g$ is the acceleration due to gravity which may be taken to be $9.81\;\mathrm{m\,s^{-2}}$ for Earth. The maximum height attained by the projectile is given by: $$ H = \frac{v^2\sin^2\alpha}{2g}. $$ (We neglect air resistance and the curvature and rotation of the Earth.) Write a function to calculate and return the range and maximum height of a projectile, taking $\alpha$ and $v$ as arguments. Test it with the values $v = 10\;\mathrm{m\,s^{-1}}$ and $\alpha = 30^\circ$.