Source: Principles of Physics
Problem
A projectile is launched with an initial speed $v_0$ from a height $h$ above the ground. The launch angle is $\theta$ with respect to the horizontal.
The projectile's motion is described by its horizontal and vertical components. Let the launch point be at coordinates $(0, h)$. The horizontal position is $x(t) = (v_0 \cos\theta) t$. The vertical position is $y(t) = h + (v_0 \sin\theta) t - \frac{1}{2}gt^2$.
The projectile hits the ground when $y(T) = 0$, where $T$ is the time of flight. This gives a quadratic equation for $T$:
$$\frac{1}{2}gT^2 - (v_0 \sin\theta)T - h = 0$$Solving for $T$ using the quadratic formula and taking the positive root for time:
$$T = \frac{v_0 \sin\theta + \sqrt{(-v_0 \sin\theta)^2 - 4(\frac{1}{2}g)(-h)}}{g}$$ $$T = \frac{v_0 \sin\theta + \sqrt{v_0^2 \sin^2\theta + 2gh}}{g}$$The horizontal range $R$ is the horizontal distance traveled during the time of flight $T$:
$$R = x(T) = (v_0 \cos\theta) T$$Substituting the expression for $T$:
$$R = (v_0 \cos\theta) \left( \frac{v_0 \sin\theta + \sqrt{v_0^2 \sin^2\theta + 2gh}}{g} \right)$$