Due Thursday, April 7, 11:59 P.M.
- Overview
- Assignment
- Hints
The purpose of this lab is to give you additional practice using
functions in in Fortran, and to introduce you to using modules.
Top
Write a program called newtmeth that
implements Newton's method. Your program should be structured as
follows:
- You should implement Newton's method in a function
called newt that takes as its arguments an initial guess for the
root, the name of the function to which Newton's method should be applied,
and the name of its derivative. The return value of the function should
be the approximated root.
- You should test your function by using it to approximate pi and the
square root of two by solving for zeros of the appropriate functions.
- You should return from your function when two successive
approximations to a root differ by less than a specified cutoff value
stored in a parameter variable called tol. You will need to
experiment with various values for tol to determine the smallest
value that for which convergence still occurs.
- The tol variable and all your functions should be contained
inside a module used by your main program.
Top
- When passing the names of functions contained in a module used by
your main program, you should not redeclare the functions using the
EXTERNAL keyword. This is redundant with the definition you
have given in the module.
- When passing the names of Fortran intrinsic functions, you should
declare the function names using INTRINSIC rather than
EXTERNAL.
Top
Back to the course information page