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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started