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

Write a user-defined function with function call [r k] = root_finder(f,x0,kmax,tol) where f is an inline function, x0 is a specified value, kmax is the maximum number of iterations, and tol is a specified tolerance. The function sets x1 = x0, calculates |f(x1)|, and if it is less than the tolerance, then x1 approximates the root r. If not, it will increment x1 by 0.01 to obtain x2, repeat the procedure, and so on. The process terminates as soon as |f(xk)| < tol for some k. The outputs of the function are the approximate root and the number of iterations it took to find it. Execute the function for f(x) = x2 3.3x + 2.1, x0 = 0.5, kmax = 50, tol = 10-2. Repeat problem for f(x)=3+ln(2x-1)-ex ,x0=1, kmax=25, tol = 10-2 (using Matlab)

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!