Answer
We show that the total distance traveled before hitting the ground is
$\left( {\frac{{{v_0}^2}}{g}} \right)\sin 2\theta $
So, the maximum distance is attained if $\theta = 45^\circ $.
Work Step by Step
We have the initial velocity ${\bf{v}}\left( 0 \right) = \left( {{v_0}\cos \theta ,{v_0}\sin \theta } \right)$. Let the initial position be ${\bf{r}}\left( 0 \right) = \left( {0,0} \right)$.
The only force that acts on the projectile is the gravitational force. So, the acceleration due to gravity is ${\bf{a}}\left( t \right) = - g{\bf{j}}$ $m/{s^2}$.
1. Find the velocity vector
We have
${\bf{v}}\left( t \right) = \smallint {\bf{a}}\left( t \right){\rm{d}}t = \smallint \left( {0, - g} \right){\rm{d}}t = \left( {0, - gt} \right) + {{\bf{c}}_0}$
The initial condition ${\bf{v}}\left( 0 \right) = \left( {{v_0}\cos \theta ,{v_0}\sin \theta } \right)$ gives
$\left( {{v_0}\cos \theta ,{v_0}\sin \theta } \right) = \left( {0,0} \right) + {{\bf{c}}_0}$
${{\bf{c}}_0} = \left( {{v_0}\cos \theta ,{v_0}\sin \theta } \right)$
Thus,
${\bf{v}}\left( t \right) = \left( {0, - gt} \right) + \left( {{v_0}\cos \theta ,{v_0}\sin \theta } \right)$
${\bf{v}}\left( t \right) = \left( {{v_0}\cos \theta ,{v_0}\sin \theta - gt} \right)$
2. Find the position vector
We have
${\bf{r}}\left( t \right) = \smallint {\bf{v}}\left( t \right){\rm{d}}t = \smallint \left( {{v_0}\cos \theta ,{v_0}\sin \theta - gt} \right){\rm{d}}t$
${\bf{r}}\left( t \right) = \left( {{v_0}t\cos \theta ,{v_0}t\sin \theta - \frac{1}{2}g{t^2}} \right) + {{\bf{c}}_1}$
The initial condition ${\bf{r}}\left( 0 \right) = \left( {0,0} \right)$ gives
$\left( {0,0} \right) = \left( {0,0} \right) + {{\bf{c}}_1}$
${{\bf{c}}_1} = \left( {0,0} \right)$
Thus,
${\bf{r}}\left( t \right) = \left( {{v_0}t\cos \theta ,{v_0}t\sin \theta - \frac{1}{2}g{t^2}} \right)$
3. Solve for $\theta$
From previous result, we obtain the position vector:
${\bf{r}}\left( t \right) = \left( {{v_0}t\cos \theta ,{v_0}t\sin \theta - \frac{1}{2}g{t^2}} \right)$
The projectile hits the ground if the $y$-component of ${\bf{r}}\left( t \right)$ is zero. Thus,
${v_0}t\sin \theta - \frac{1}{2}g{t^2} = 0$
$t\left( {{v_0}\sin \theta - \frac{1}{2}gt} \right) = 0$
The solutions are $t=0$ and $t = \frac{{2{v_0}\sin \theta }}{g}$. The first solution corresponds to the time when the projectile is fired. So, we take the second solution. Substituting it in the $x$-component of ${\bf{r}}\left( t \right)$ we get the total distance:
total distance $ = {v_0}\left( {\frac{{2{v_0}\sin \theta }}{g}} \right)\cos \theta $
total distance $ = \left( {\frac{{{v_0}^2}}{g}} \right)2\sin \theta \cos \theta $
total distance $ = \left( {\frac{{{v_0}^2}}{g}} \right)\sin 2\theta $
Since $\sin 2\theta \le 1$, the maximum distance is attained if $2\theta = 90^\circ $, that is if $\theta = 45^\circ $.