You did such a great job with your ballistic trajectory program, that your former boss is willing to hire you as a consultant to upgrade the work. Then again, maybe you were confused with another ex-employee, but the money is good, so you're taking a shot at it. The real valued function must be named again named "dist", but this time it takes 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 Newton iteration to solve for the value of x at which the shell hits the ground. Use your original range calculations for flat ground to generate an initial guess. Use a standard DO loop for the Newton iteration, and use your previous flat terrain distance calculation to provide an initial guess for the iteration. Include an error message, if the Newton method fails to converge within a maximum of 10 iterations.
As before, The function will be audited by the DOD program monitor, and placed in the company software library, so must be generously commented, including a statement of the function's purpose, definitions for all variables, and a line giving your name and the creation date.
I have provided a driver program dcannon.f to test your function. .
This homework will be graded as follows:
Leave your modified version of dcannon.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 : email@example.com