Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Numerical Method Write a Matlab function for the Newton-Raphson algorithm. The i

ID: 2994199 • Letter: N

Question

Numerical Method


Write a Matlab function for the Newton-Raphson algorithm. The inputs should the function f (as an anonymous function handle), its derivative f' (as an anonymous function handle), the initial guess x0, and the maximum allowable approximate percent relative error, The outputs of the function should be the value of the root, xr, the value of the approximate percent relative error, and the number of iterations, Niter. Name your function NewtonRaphson. In another file, called HW2Pbl.m, define the function f and its derivative corresponding to Question 1. Run your code for epsilon max a =100%, 10%, 1%, 0.1%, 0.01%, 0.001%, 0.0001%. Plot the approximate percent relative error as a function of the number of iterations using log scales.

Explanation / Answer

To call the cubic1 function,