Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB exercise Halley's method can be used to solve the root finding problem f(x)=0. This is an open method, so it starts with a single

MATLAB exercise

image text in transcribed

image text in transcribed

Halley's method can be used to solve the root finding problem f(x)=0. This is an open method, so it starts with a single initial estimate for the root without using the derivative of f. The formula for the next estimate of the root is given by xn+1=xna(xn)1 where a(xn)=f(xn)f(xn)21f(xn)f(xn). This iteration process repeats until the root is found to within a given tolerance. However, because this is an open method, the iteration is not guaranteed to converge. Write a function halley that implements Halley's method. Your function should accept the following inputs: - f= anonymous MATLAB function that represents f. - f1 = anonymous MATLAB function that represents f. - +2= anonymous MATLAB function that represents f ". - x= initial guess for the root - TolX = desired bound on the relative error for the root, which is given by xixi+1xi - itmax = maximum number of iterations Your function should return the following output: - root = computed root estimate - hn= the list of the prior estimates to root of length equal to the number of iterations performed. So include root in the list, but do not include x0. Your solution should do the following: 1. Implement Halley's method to find a root of f(x)=0 and return the iteration history. Do not use the MATLAB solver functions like fze ro, solve, roots, etc. 2. Terminate the search when the relative error tolerance is reached or when the iteration limit is reached (whichever occurs first). 3. Use the MATLAB function error with a msg to detect if the iteration does not converge before the iteration limit is reached: msg = 'Iterat ionLimitExceeded ' A test case has been provided in the 'Code to call your function' box. If the solution seems reasonable, submit your function for assessment. Code to call your function (? 1234567f=a(x)x22;f1=a(x)2x;f2=a(x)2;x=1;Tolx=1e12;itmax=20;[root,hn]=halley(f,f1,f2,x,Tolx,itmax)

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

More Books

Students also viewed these Databases questions