Write one a MATLAB function that implements the Bisection method, Newton’s method and Secant Method (all...

80.2K

Verified Solution

Question

Advance Math

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

Answer & Explanation Solved by verified expert
3.9 Ratings (412 Votes)
function dummybiscnewtonsecant clc clear all fx600x4 550x3 200x220x 1 function fpx6004x3 5503x2 2002x20 derivative of unction tol1e8 a0 b2 interval x005 dispRoot by Bisection method ybisecionfabtol function calling a10 b11 interval dispRoot by fixed point method C1fixedpgx0tol function calling dispRoot by Newton method y2newtfx0tol function calling a205 b22 interval dispRoot by Secant method    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students