+
We now consider the more general case of moving the catapult up the hill AND changing the angle of elevation in order to reach the target. Perhaps we can determine a different angle which will still permit us to hit the target AND move the catapult up the hill less than when we fire at an angle of elevation of Pi/4 radians or 45 degrees.

Input := 


Remove[theta,x,y,xrange,dist1,dist2,vnaught]

Input := 


vnaught= 300;

x[t_, a_]=vnaught * Cos[theta] t - a; 

y[t_, a_]=-16t^2 + vnaught* Sin[theta] t+ Sqrt[3]*a  

-a + 300 t Cos[theta];

Output =


                2

Sqrt[3] a - 16 t  + 300 t Sin[theta]

-
We determine the time at which the projectile strikes the ground.

-
And we find the range as a function of a and theta, eliminating t.

Input := 


xrange[a_,theta_] = x[t,a]/.sol[[2]];

-
We now determine when the range is 3000 ft and use this to write the distance a as a function of the one variable theta.

Input := 


sol = Solve[xrange[a,theta]==3000,a];

Input := 


dist1[theta_] =  a/.sol[[1]];

Input := 


dist2[theta_] =  a/.sol[[2]];

-
We plot these distances to see what they look like.

-
And we see that many combintations of angle theta and distance a along the above curve would give a path such that the projectile would hit the target at (3000,0). But could we select an angle which would minimize the distance we have to move the catapult and still hit the target at (3000, 0)?

-
In the case where we presume that theta = Pi/4 we got a minimum distance to move the catapult of 918.716 ft if we move to the location (-459.358, Sqrt[3] 459.358) - and we can hit the target from there.

-
But we seek a smaller distance through which we have to move the catapult and still hit the target.

-
We use the calculus to minimize d[theta].

-
And we determine the distance the catapult must move in this case.

-
Thus we see that if we pick theta to be 0.703091 (less then Pi/4) and distance a =415.039 ft we only have to move the catapult 718.869 feet up the hill and still be able to hit the target.