Question: Exercise 1 Write two functions chord method.m and Newton method.m implementing, respectively, the chord and the Newton methods to find the zeros of nonlinear (scalar)

Exercise 1 Write two functions chord method.m and Newton method.m implementing, respectively, the chord and the Newton methods to find the zeros of nonlinear (scalar) equations. The functions should be of the following form function [z0,iter,res, his] = chord method (fun,a,b,tol, Nmax) function [z0,iter ,res, his] = Newton_method (fun, dfun, x0, tol, Nmax) Inputs: fun: function handle representing f(x) a, b: interval [a, b] in which we believe there is a zero tol: maximum tolerance allowed for the increment |x(k+1) xlk| Nmax: maximum number of iterations allowed dfun: function handle representing df (x)/dx (Newton method) xo: initial guess for the zero (Newton method) Outputs: z0: approximation of the zero 20 iter: number of iterations to obtain 20 res: residual at z0 (i.e., |f(zo)) his: vector collecting all the elements of the sequence {x{k}k=0,1,.. (convergence history) Both functions should return the numerical approximation of the zero when the increment at iteration k+1 is such that |x(k+1) rk)|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
