Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Secant Method in Matlab Write a Matlab function to locate a root by the secant method. Your function should be put in the file

image text in transcribed

The Secant Method in Matlab Write a Matlab function to locate a root by the secant method. Your function should be put in the file mysecant.m, and should be called as x=mysecant(f, x0, x1, tol, nmax) Here f is the function f, x0, x1 are the initial guesses, tol is the error tolerance, nmax is the maximum number of iterations, and x is the output of your function. Test your function to find the value Squareroot 2, as the root for f(x) = x^2 - 2, to see if it works. Use sprintf and "disp" to display your result in each iteration, so you can check the convergence. Then, use it to find a root for the function f(x) = e^-x - cos(x) in the interval [1.1, 1.6]. Use tol = 1e-12 and nmax=10. Your two initial guesses should be on the interval [1.1, 1.6]. How does the result compare to those with Newton's method? Comment in detail. What to hand in: Your file mysecant.m, test result for f(x) = x^2 - 2, and the result for f(x) = e^-x - cos(x)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions