Question: How to write this matlab function for bisection root finding method? Write a function with the following header: function [n iterations, root] = my root

How to write this matlab function for bisection root finding method?  How to write this matlab function for bisection root finding method?

Write a function with the following header: function [n iterations, root] = my root bisection(f, a, b, tolerance) where: _ f is a function handle that represents a continuous real-valued function f de_ned on R. f takes a single input argument that is a scalar of class double (other than NaN, Inf, and -inf) and outputs a single output argument that is a scalar of class double (other than NaN, Inf, and -Inf). _ a and b are scalars of class double such that (b > a) and (f(a)*f(b) > my_function = @(x) x.^2 - 5; >> [n, root] = my_root_bisection(my_function, 2, 3, 1e-3) n = 12 root = 2.2361 >> f = @(var) cos(var/2); >> [n, root] = my_root_bisection(f, 3, 4, 1e-5) n = 10 root = 3.1416 >> f = @(x) cos(x)-x; >> [n, root] = my_root_bisection(f, -10, 10, 1e-4) n = 15 root = 0.7391

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!