HW3 - Note: You may have to use the diff command to...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Math98 HW3 Suppose f : R R and that x 0 is a given real number. Halley’s method 1 for finding a root of f starting at x 0 is given by the sequence x n +1 = x n - 2 f ( x n ) f 0 ( x n ) 2 f 0 ( x n ) 2 - f ( x n ) f 00 ( x n ) , n 0 . This method is obtained by applying Newton’s method on the function f/ p | f 0 | , which of course has the same roots of f . Although this method requires evaluation of f 00 (which is a limitation), when it converges it does so at a rate faster than that of Newton’s method. a. Implement a MATLAB function of the form function [Approx, Success]=HalleysMethod(f, x 0 , maxIter, Tol) . Here f is an inline function and x 0 is an initial guess for a root of f . This method terminates when either it has performed maxIter iterations or | f (Approx) | < Tol, where Approx is the numerical approximation to a root of f computed by Halley’s method. Success is a logical variable that returns 1 if | f (Approx) | < Tol and 0 otherwise.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Note: You may have to use the diff command to dierentiate MATLAB inline functions. b. With Tol=10-5 and MaxIter=10, use Halleys method to approximate the roots of the following functions with given initial guesses. Also indicate if the method was successful or not. ( i ) f ( x ) = x-cos( x ) , x = 4. ( ii ) f ( x ) = x 3-x, x = 1 / 3. ( iii ) f ( x ) = 1 3 x 3-1 2 x 2-6 x + 1 , x =-3. ( iv ) f ( x ) = 5 6-1 2 x 2-cos( x ) , x = 3. ( v ) f ( x ) = xe-x , x = 3 / 2. For part a , your solution should consist of MATLAB code for the function HalleysMethod ; for part b , submit your numerical results from running HalleysMethod in the command window. 1 See Wikipedia for more on Halleys method....
View Full Document

Ask a homework question - tutors are online