Question: Using the Matlab code provided please fill out the table for equations a,b,c and d. Thank you in advance! function [root, ea, iter] = newtraph(func,

Using the Matlab code provided please fill out the table for equations a,b,c and d. Thank you in advance!

Using the Matlab code provided please fill out the table for equationsa,b,c and d. Thank you in advance! function [root, ea, iter] =

function [root, ea, iter] = newtraph(func, dfunc, xr, es, maxit) % newtraph: Newton-Raphson root finding method % [root, ea, iter] = newtraph(func, dfunc, xr, es, maxit) % input: % func = name of function % dfunc = name of derivative of function % xr = initial guess % es = desired relative error (default = 0.0001%) % maxit = maximum allowable iterations (default = 20) % output: % root = real root % ea = approximate relative error (%) % iter = number of iterations % a text file 'newtraph_out.txt' is generated to store iterations if nargin Type in the following code, fill in the blank, and create a function m-file named newtraph.m function [root, ea, iter] = newt raph (func, drunc, xr, es, maxit) % newt rap: Newton-Raphson root finding method % [root, ea, iter] = newtraph (func, drunc, xr, es, maxit) % input: % func = name of function % dfunc name of derivative of function 8 xrinitial guess % es - desired relative error (default 0.0001%) % maxit = maximum allowable iterations (default 20) output: root = real root % ea approximate relative error (%) % iter number of iterations % a text file 'newtraph-out.txt' is generated to store iterations if nargin>f-e (x) exp (-x) +x-2; >> df- e (x) -exp (x) +1; >>fplot(f, [-2 10]); grid on; >>root, ea, iter] newtraph (f, df, 0.5) 3. Solve the following problems with Newton-Raphson method function (a) cos(x)-x-0 (b) x*-x-2-0 (find both roots by trying different initial guesses) (c) x*-2x +1-0 (notice this is a double root, and it takes unusually large number of iterations.) (d) 2x -2-0 (notice this is a derivative of equation (c), giving the same root but much faster.) Type in the following code, fill in the blank, and create a function m-file named newtraph.m function [root, ea, iter] = newt raph (func, drunc, xr, es, maxit) % newt rap: Newton-Raphson root finding method % [root, ea, iter] = newtraph (func, drunc, xr, es, maxit) % input: % func = name of function % dfunc name of derivative of function 8 xrinitial guess % es - desired relative error (default 0.0001%) % maxit = maximum allowable iterations (default 20) output: root = real root % ea approximate relative error (%) % iter number of iterations % a text file 'newtraph-out.txt' is generated to store iterations if nargin>f-e (x) exp (-x) +x-2; >> df- e (x) -exp (x) +1; >>fplot(f, [-2 10]); grid on; >>root, ea, iter] newtraph (f, df, 0.5) 3. Solve the following problems with Newton-Raphson method function (a) cos(x)-x-0 (b) x*-x-2-0 (find both roots by trying different initial guesses) (c) x*-2x +1-0 (notice this is a double root, and it takes unusually large number of iterations.) (d) 2x -2-0 (notice this is a derivative of equation (c), giving the same root but much faster.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!