Question: Write a user-defined function with function call [r, k] = rootfinder (f, x0, kmax, tol) where f is an anonymous function, x0 is a specified

 Write a user-defined function with function call [r, k] = rootfinder

Write a user-defined function with function call [r, k] = rootfinder (f, x0, kmax, tol) where f is an anonymous function, x0 is a specified value, kmax is the maximum number of iterations, and tol is a specified tolerance. The function sets x -X, calculates fx), and if it is less than the tolerance, then x, approximates the root r. If not, it will increment x, by 0.01 to obtain x, repeat the procedure, and so on. The process terminates as soon as If%)k tol for some k. The outputs of the function are the approximate root and the number of iteration:s it took to find it. Execute the function for f(x) = x2-33x + 2.1, x,-0.5, kmax = 50 tol = 10-2. Repeat Problem forf(r) = 3 + In(2-1)-ex, xo = 1, kmax = 25 tol = 10-2

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!