You are on page 1of 1

28/5/20 10:17 PM C:\Users\Harpreet Kalsi\Doc...\newton.

m 1 of 1

clc
clear all

f=@(x) cos(x)-x*exp(x)
g=@(x) -sin(x)-x*exp(x)-exp(x);
x0=1;
e=1
while(e>.00001)
x1=x0-(f(x0)/g(x0));
e=abs(x1-x0);
x0=x1
end
f(x0)

You might also like