Question: In MATLAB: Suppose a user wants to make a root finder in Matlab. Create a script that does the following: 1. Allows the user to

In MATLAB: Suppose a user wants to make a root finder in Matlab. Create a script that does the following:
1. Allows the user to enter a function, f(x), the end-points of the plot window and the method to find the root.
2. Plot the function for the user to view the location of the roots.
3. Using a case-switch, call function bisection.m, fixed.m, newton.m or secant.m (each of these should prompt the user for the necessary input information). *Note: these are functions you will create
4. Plot the points generated through each pass in the algorithmic loop.
5. Return the root, the time elapsed and the number of iterations.
Run your script with the following function using each method.
*For part 3
Bisection Method
% Bisection Method
% a is a point left of the root
% b is a point right of the root
% m is the point halfway between a and b
m = a + (b-a)/2;
if sign(f(a)) == sign(f(m))
a = m;
else
b = m;
end
Fixed-point Method
% Fixed-point f(x) = g(x) - x = 0
% which implies: x(n+1) = g(x(n))
p = g(p0);
Newton Method
% Newtons Method
% x is the guess
% xn is the new guess
% f1 is the first derivative
xn=x-f(x)/f1(x);
Secant Method
% Secant Method
% x0 and x1 are guesses that are distinct
% xn is the new guess that will connect to x1
xn = x1 - f(x1)*(x1-x0)/(f(x1)-f(x0));
Please show all work. Thanks!

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!