Question
Newton Raphson and Secant Method Consider the equation f(x) = tan(pi*x) - x - 6 a) Write a MATLAB function program that implements the Newton-Raphson
Newton Raphson and Secant Method
Consider the equation
f(x) = tan(pi*x) - x - 6
a) Write a MATLAB function program that implements the Newton-Raphson method to solve f(x) = 0.
b) Write another MATLAB function that implements the secant method.
c) Using the initial guesses of xl = 0.48 (and x0 = 0.54 for the secant method) write out explicitly your calculations (do this by hand) for the first two steps of each method. List the number of iteration, previous estimate of the root, most updated estimate of the root and the approximate relative error.
d) Use both programs to find the root of the above equation to within an approximate relative error of 10-6. Design your MATLAB codes as such to output the number k of each iteration, the previous and new estimate of the solution and the relative approximate error. Limit your code to run no more than 25 iterations.
e) Plot the relative approximate error as a function of iteration (on a lin-log plot). For each method, which has the steepest slope and why (a qualitative answer is good enough) ?
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