Write a MATLAB script that uses that Newton method function

Write a MATLAB script that uses that Newton method function to find the root of f(x) = e^-0.5x (4 - x) - 2 using initial guesses of x_0 = 2, x_0 = 6, and x_0 = 8. Explain the results you observe.

Solution

% Newton Raphson Method
clear all
close all
clc
a = input(\'value of first initial root\');
b =input (\'value of 2nd initial root\');
% Change here for different functions
f=@(x) exp(-0.5*x)*(4-x) -2
%this is the derivative of the above function
df=@(x) -exp(-0.5*x)-0.5*(4-x)*exp(-0.5*x)
% Change lower limit \'a\' and upper limit \'b\'
a=2; b=6;
x=a;
for i=1:1:100
x1=x-(f(x)/df(x));
x=x1;
end
sol=x;
fprintf(\'Approximate Root is %.15f\',sol)

 Write a MATLAB script that uses that Newton method function to find the root of f(x) = e^-0.5x (4 - x) - 2 using initial guesses of x_0 = 2, x_0 = 6, and x_0 =

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site