# Newton-Raphson Algorithm Implemented in Matlab

a. Write a Matlab function newton.m which uses Newton-Raphson algorithm to compute an approximate solution to the equation f(x) = 0 starting from X0 and stopping when the magnitude of f(x) becomes smaller than e. The program should also restrict the maximum number of iterations to N. Your m-file should have a header line function [x, nitr] = newton (f, fp, x0, e, N) where fp is a user supplied function that computes f'(x).

Note: You can use Algorithm 2 on page 52 of Steven Pav's lecture notes as a template for your program.

b. Use your function newton.m to find the positive root of a function f(x) = exp(x) - sin(x) -2 with at least 10 correct digits after the decimal point. How many iterations did the algorithm require to converge the result.

See attachment .

© BrainMass Inc. brainmass.com October 10, 2019, 7:45 am ad1c9bdddfhttps://brainmass.com/computer-science/matlab/newton-raphson-algorithm-implemented-matlab-593879

#### Solution Summary

This solution implements a Newton-Raphson algorithm Matlab, using two separate scripts for the function whose zeros are sought and its derivative, and using the algorithm in a demo script.