You are on page 1of 1

17/05/22 19:35 C:\Users\InfoBulles\Des...\Untitledaaaa.

m 1 of 1

clc
clear
a = 0.1;
b = 0.5;
xo= (b+a) /2;
ep =0.001;
f = @(x) log(x)- x .^2 +2;
figure (1), fplot(f,[a,b]);
grid on
f_prime = @(x) 1 ./ x - 2 .* x;
figure (2), fplot(f_prime,[a,b]);
grid on
[x,N] = MyNewtonRaphsonFun(f,f_prime,x0,eps)
N =0;
x =x0;
x1 =x - f(x0)/f_prime(x0);
i = 0;
while abs(x1 - x) > eps
x = x1;
x1 = x - f(x)/f_prime(x);
i =i +1;
figure(3),hold on, plot(i,x,'r*')
N = N + 1;
end

You might also like