This is a rerun of Homework 8, but this time you must solve the problem with a Secant iteration. The real valued function giving the horizontal distance traveled by the shell must be named again named "dist", and take 3 real arguments. The first argument is the angle of inclination of a cannon's barrel from horizontal, in radians. The second argument is the cannon's muzzle velocity in meters per second. The third is the name of an array containing coefficients for a cubic fit to the ground elevation relative to the cannon. The value returned by the function is the range of the cannon shell (in meters) subject to the following assumptions:
elevation = c(1)*x + c(2)*x**2 + c(3)*x**3where x is the distance from the cannon along a flat line at the cannon's elevation, and "c" is the array passed as the third dummy argument.
As one check on your results, your range at 45 degrees should be close to 8303 meters, using the values of "c" in dcannon.f.
Use a Secant iteration to solve for the value of x at which the shell hits the ground. Use a standard DO loop for the Secant iteration, and use your previous flat terrain distance calculation to provide an initial guess for the iteration. Include an error message, if the iteration method fails to converge within a maximum of 10 iterations.
I have provided an old Newton solution scannon.f as a starting point.
This homework will be graded as follows:
Leave your modified version of scannon.f (don't change the file name) in your "homework" subdirectory. We will pick it up after the due date and test it.
Maintained by John Mahaffy : firstname.lastname@example.org