//========================================================================= #define PROGRAMMER "SOLUTIONS, NoFrills" #define PROG_CODE "soln" #define COURSE "ECE-1021" #define YEAR (2003) #define TERM "Fall" #define SECTION (0) #define ASSIGNMENT "HW #1B" #define REVISION (0) #define TITLE "Newton's Method" #define SUBTITLE "" #define EMAIL "ece1021@eas.uccs.edu" #define FILENAME "01b0soln.txt" //========================================================================= 1) TASK: Get data from the user 1.1) GET: x_guess (initial guess) 1.2) GET: n_max (maximum number of iterations to perform) 1.3) GET: h (width of derivative secant) 1.4) GET: tol (tolerance of function zero) 2) TASK: Compute Estimate of Function Zero 2.1) SET: n = 0 2.2) SET: x = x_guess 2.3) SET: f_x = FUNCTION 2.4) WHILE: ( (abs(f_x) > tol) AND (n < n_max) ) 2.4.1) SET: x = x_guess - (h/2.0); 2.4.2) SET: f_xlower = FUNCTION; 2.4.3) SET: x = x_guess + (h/2.0); 2.4.4) SET: f_xupper = FUNCTION; 2.4.5) SET: x_guess = x_guess - [ (h*f_x) / (f_xupper - f_xlower) ] 2.4.6) SET: x = x_guess; 2.4.7) SET: f_x = FUNCTION; 2.4.8) SET: n = n+1 3) TASK: Report Results 3.1) PUT: "Iterations Performed: " n 3.2) PUT: "Last estimate of function zero = " x_guess 3.3) PUT: "Function evaluated at nominal zero = " f_x