Write one a MATLAB function that implements the Bisectionmethod, Newton’s method and Secant Method (all in one function).Your function must have the following signature
function output = solve(f,options)
% your code here
end
where
the input is
- • f: the function in f(x) =0.
- options: is a struct type with the following fields o method:bisection, newton or secant
- tol: the tolerance for stopping the iterations.
- maximum_iterations: the maximum number of iterationsallowed.
- initial_guess: that is P_0; if the method needs it
- df: the derivative of f if the method needs it
- initial_interval: if the method needs it
the output is also a struct type with the following fields
- • message: either ‘success’ or an error message.
- • root: the solution in case of success.
- • iterations: an array that saves all iterations of thealgorithm. Each row represents an iteration of the algorithm. Eachrow must contain P_n, f(P_n) and |P_n-P_n-1|.
- Write a script file that tests your function using thefollowing equations
600x^4 – 550x^3 +200x^2 – 20x -1 = 0