+
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 := 


vnaught= 300;

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

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

Input := 


sol = Solve[y[t,a] == 0,t];

-
From a plot of xrange[a,theta] we see that there appears to be a maximum range around a = 4,000 and theta = .6 or so.

Input := 


ContourPlot[xrange[a,theta],{a,0,4000},{theta,0,Pi/3}]

-
We proceed to optimize this function of two variables a and theta, using the calculus approach of setting the respective partial derivatives with respect to a and theta equal to 0 and solving for values of a and theta which make these partial derivatives equal to 0. We use our contour plot to obtain an initial starting point for our root finding algorithm.

-
Thus we see that if we move the catapult up the hill to the new position (-1623.81, 2812.5), about 0.61 miles along the hill we could hit the target when it is as far out as 3,247.6 feet. This is the farthest we can expect to go with our catapult as this approach allows us to vary the angle of elevation from the horizontal at which we shoot AND the position along the hill.