Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a function with the prototype function r secant (f, x0, x1, tol, kmax) which implements the secant method to find a root
1. Write a function with the prototype function r secant (f, x0, x1, tol, kmax) which implements the secant method to find a root of a function f between x0 and x1. Successive estimates are calculated until either the relative error ek is less than tol or k=kmax. Recall that ek Ik-k-1 Ik Test that your function is working correctly by choosing a simple test function where you know the location of one (or more) of its roots. 2. Write a script that uses your function from question 1 to find the roots of 1 f(x)=+xsin ( with tol 10 and kmax = 20. Plot the graph of f(x). The plot will help you = choose appropriate values of x0 and x1 to find all of the roots of f(x). 3. Check your answers to the previous question using MATLAB's built-in fzero function. 4. Add the roots of f(x) to your plot of f(x), ensuring that they are clearly marked.
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