Professional Documents
Culture Documents
Mathlab Code Graphical and Newton Raphson
Mathlab Code Graphical and Newton Raphson
figure(1)
ezplot(f_x)
grid on
hold on
%(b)
% first find dx
for i = 1:3
nr_x = nr_x_i;
plot(nr_x,f_x(nr_x) , '*b')
end
%(c)
%Secant Method
figure(2)
ezplot(f_x)
grid on
hold on
x1 = 0.5;
x2 = 0.4;
xn = x2 - f_x(x2) * (x1-x2)/(f_x(x1)-f_x(x2))
x1= x2
x2=xn
plot(xn,f(xn),'*r')
end
%(d)
figure(3)
ezplot(f_x)
hold on
grid on
ep = 0.01;
x = .3
xa = .3
x = x - f_x(x)/ df_x(x);
plot(x,f_x(x),'*r')
xa = xa - f_x(xa)/adf_x(xa);
plot(xa,f_x(xa),'*g')
end