lunes, 5 de marzo de 2012

Método de Newton-Raphson



X f(x) Ecuación = x^2-x-2 X1 f(X1) f'(X1) X0 e% Respuesta
-10 108 Ecuación derivada  = 2x-1 0 -2 -1 -2 100
-9 88 X1 = 0 -2 4 -5 -1.2 66.6666667
-8 70 e% = 0.01 -1.2 0.64 -3.4 -1.01176471 18.6046512
-7 54 -1.01176471 0.035432526 -3.02352941 -1.00004578 1.17183924
-6 40 -1.00004578 0.000137333 -3.00009155 -1 0.00457764 -1
-5 28 -1 2.09548E-09 -3 -1 6.9849E-08 -1
-4 18 -1 0 -3 -1 0 -1
-3 10 -1 0 -3 -1 0 -1
-2 4 -1 0 -3 -1 0 -1
-1 0 -1 0 -3 -1 0 -1
0 -2 -1 0 -3 -1 0 -1
1 -2 -1 0 -3 -1 0 -1
2 0 -1 0 -3 -1 0 -1
3 4 -1 0 -3 -1 0 -1
4 10 -1 0 -3 -1 0 -1
5 18
6 28
7 40
8 54
9 70
10 88
matlab



function x = Newt_n(f_name, xO)
% Iteración de Newton sin gráficos
x = xO; xb = x-999;
n=0; del_x = 0.01;
while abs(x-xb)>0.000001
  n=n+1; xb=x ;
  if n>300 break; end
  y=feval(f_name, x) ;
  y_driv=(feval(f_name, x+del_x) - y)/del_x;
  x = xb - y/y_driv ;
  fprintf(' n=%3.0f, x=%12.5e, y=%12.5e, ', n,x,y)
  fprintf(' yd = %12.5e \n', y_driv)
end
fprintf('\n Respuesta final = %12.6e\n', x) ;




f(x) = (x – 3) (x – 1) (x – 1)

n xn f(xn) f'(xn) xn+1
0 0.50000000 -0.62500000 2.75000000 0.72727273
1 0.72727273 -0.16904583 1.31404959 0.85591767
2 0.85591767 -0.04451055 0.63860849 0.92561694
3 0.92561694 -0.01147723 0.31413077 0.96215341
4 0.96215341 -0.00291894 0.15568346 0.98090260
5 0.98090260 -0.00073639 0.07748373 0.99040636
6 0.99040636 -0.00018496 0.03865069 0.99519176
7 0.99519176 -0.00004635 0.01930234 0.99759300
8 0.99759300 -0.00001160 0.00964539 0.99879578
9 0.99879578 -0.00000290 0.00482125 0.99939771
10 0.99939771 -0.00000073 0.00241026 0.99969881


No hay comentarios:

Publicar un comentario