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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!