Newton rootfinder

(always read the entire Lab before you start working on it...)

1. Implement Newton's method to find a root of a given function F(x), i.e. solve F(x)=0.

The main program should read in:

and should call the Newton rootfinder (see below).

Your program should output the input values, and then the iterates (neatly, in columns):

n xn F(xn)

and, upon convergence, the root.

The values of F(x) and F'(x) should be computed in a subprogram FCN( xn, Fn, DFn ) called by the rootfinder.

[ A good way to code Newton rootfinder and decide convergence is something like this (pseudocode):

subprogram Newton1D( x0, TOL, maxIT ) xn = x0 dx = 1000.0 [something big] print '# n xn Fn' [labels for values] for n=1:maxIT call FCN( xn, Fn, DFn ) [returns Fn=F(xn), DFn=F'(xn)] print: n xn Fn [use formated printing, in columns] if( ABS(dx) < TOL ) then if( ABS(Fn) < TOL ) then print: 'DONE: root=',xn,' F=',Fn,' in ',n,' iters' break out of the loop [how depends on the language...] else print: 'STUCK: dx < TOL BUT residual =', Fn,' > TOL' break out of the loop endif endif dx = −Fn/DFn [take Newton step] xn = xn + dx endfor print: 'BAD: reached maxIT' END subprogram ]2. Debug your code by finding SQRT(3) as root of F(x) = x

Try a couple of different x0's, with maxIT=10, TOL=1.e-6.

3. Create a PLAIN TEXT file "lab2.txt" containing:

M475 Lab2: Name, Date ======================================== (separation line) the input and output of ONE run of your code. ======================================== (separation line) your code (may copy with the mouse, but indent appropriately)Email it to alexiades@utk.edu and Cc: to yourself, with Subject: