You want to throw a rock far, as far as you can possibly throw. Using all your energy, you throw the rock into the sky, and it lands some distance away a few seconds later. But at what angle should you throw it?

It is easy to see that the optimal angle to throw a rock when you are on flat ground is . That is, to make the rock travel as far as possible, one should throw the rock halfway between vertical and horizontal. Any other angle and you do worse than throwing it at a angle.

But what about throwing a rock off a cliff into, say, the ocean? Is still the optimal angle, or is it different? Perhaps it varies?

Suppose you are standing on the edge of a cliff overlooking the sea. It is meters above the sea, and you can throw a rock with a velocity , at an angle between and . You are trying to maximize , the distance thrown.

We assume that there is no friction or air resistance, and we let be the gravitational constant, .

When throwing a rock at angle , the velocity of the rock is a vector with a horizontal component of and a vertical component of .

Then the distance traveled can be expressed partially in terms of :

.

The next equation we can get by substituting our values into one of the motion equations:

The unknown in the two equations is , or the total time traveled. From the first equation we have

.

Substituting into the second equation, we get

From here we want to find the maximum for , or when . To solve for , we first differentiate both sides of the equation with respect to :

As , we can isolate :

Since , we eliminate the denominator and are left with

Ignoring the trivial case where , we get

We have the optimal distance; we can substitute this back into a previous equation:

Finally we solve for :

This is the final formula for in terms of , , and .