Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago