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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3ba5af3557_98666f3ba5a5e594.jpg)
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
Get step-by-step solutions from verified subject matter experts
