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

5) (50 points) The Newton-Raphson method is a root (the value of x for which f(x

ID: 2259735 • Letter: 5

Question

5) (50 points) The Newton-Raphson method is a root (the value of x for which f(x) = 0) locating formula commonly employed. As shown in Fig. 1, If the initial guess at the root is x, a tangent can be extended from the point (x.f(x)) The point where this tangent crosses the x axis represents an improved estimate of the root. It is therefore possible to write, fai) a) Where f'(xi) is the derivative of the function evaluated at x. This equation is known as the Newton-Raphson formula. fa) Tanaent line at x Figure 1. Grophicol drpiction of the Newton Rophson Marhod Write a Matlab code (do not use built in root finding Matlab routines) to estimate the root of f(x) = e-x-x , employing an initial guess of ro-o Note: you should define a function named myfunction, which takes as input the value of x and outputs both the value of the function at k and the value of the derwatve of the function at x

Explanation / Answer

% Newton Raphson Method clear all close all clc % Change here for different functions myfunction=@(x) e^(-x)-x %this is the derivative of the above function dmyfunction=@(x) -e^(-x)-1 a=0; x=a; for i=1:1:100 x1=x-(myfunction(x)/dmyfunction(x)); x=x1; end sol=x; fprintf('Approximate Root is %.15f',sol) a=0; x=a; er(5)=0; for i=1:1:5 x1=x-(myfunction(x)/dmyfunction(x)); x=x1; er(i)=x1-sol; end plot(er) xlabel('Number of iterations') ylabel('Error') title('Error Vs. Number of iterations')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote