I stumbled upon an interesting problem in Kleppner's An Introduction to Mechanics â€” chapter 1, problem 21. The problem states:

A boy stands at the peak of a hill which slopes downward uniformly at angle $\phi$. At what angle from the horizontal should he throw a rock so that it has the greatest range?

This problem is particularly tickling in its simplicity. Let us first develop an expectation of the problem. We already know that when $\phi = 0$, $\theta = \frac{\pi}{4}$. We also expect that $\phi$ and $\theta$ should vary inversely.

The rock is initially thrown in the $xz$ plane with velocity $v$, and the rock eventually travels a distance of $\ell$. We can break its movement and initial velocity into component vectors via trigonometry, which we will use as follows. The rock travels $\ell\cos\phi$. Via kinematics, this equals $vt\cos\theta$. Finally, the rock travels a vertical distance of $\ell\sin\phi$ via trigonometry, or $vt\sin\theta - \frac{gt^2}{2}$ via kinematics.

We proceed to use the $x$-direction to solve for time, and the $y$ direction to optimize distance in terms of $\theta$. (We will condense some algebraic manipulations for brevity's sake.)

\begin{align} t &= \frac {\ell\cos\phi} {v\cos\theta} \\
\ell\sin\phi &= \ell\tan\theta \cos\phi - \frac{g\ell^2 \cos^2\phi}{2v^2 \cos^2\theta} \\ 1 &= \frac{\tan\theta}{\tan\phi} - \frac{g\ell\cos\phi}{2v^2\cos^2\theta\tan\phi} \\
\ell &= \frac{v^2}{g\cos\phi} \left( \sin(2\theta) - 2\cos^2\theta\tan\phi \right) \\ \frac{d\ell}{d\theta} &= \frac{2v^2}{g\cos\phi} \left( \cos(2\theta) + 2\sin\theta\cos\theta\tan\phi \right) \\ 0 &= \cos(2\theta) + \frac{\sin(2\theta)\sin\phi}{\cos\phi} \\
&= \frac {\cos(2\theta)\cos\phi + \sin(2\theta)\sin\phi } {\cos\phi} \\ &= \cos(\phi - 2\theta) \\ \theta &= \frac{\phi}{2} - \frac{\pi}{4} \\ \end{align}

Notice that this gives the negative of the angle that we want since we chose the positive $z$-direction to be up instead of down.