3

Click here to load reader

Método de Newton

  • Upload
    jor

  • View
    218

  • Download
    3

Embed Size (px)

DESCRIPTION

metodo de newton

Citation preview

Page 1: Método de Newton

Método de Newton(25, pág 115)function p=newtonp(tx,ty)n=length(tx);p=[ty(1)];raices=[];for k=2:n raices=[raices tx(k-1)]; q=poly(raices); A=(ty(k)-polyval(p,tx(k)))/polyval(q,tx(k)); p=[0 p]+A*q;end>> tx=[-1 0 1 2];>> p=[1 -1 0 7];>> ty=polyval(p,tx);>> tx=[tx -2]; % Agregando el nuevo punto>> ty=[ty 1]; >> q=newtonp(tx,ty)

q =

0.2500 0.5000 -1.2500 0.5000 7.0000>> tx=[-1 0 1 2];

>> ty=[5 7 7 11];

>> x=[-0.5 0.25 1.5 2.25];

>> y=interp1(tx,ty,x,'spline')

y =

6.6250 6.9531 8.1250 13.3281

Page 2: Método de Newton

(36,117)

function y=func1(x)tx=[-1 2 3 5];ty=[-3 5 2 -1];y=interp1(tx,ty,x,'spline');function y=func2(x)tx=[-1 1 4 5];ty=[1 -3 -2 2];y=interp1(tx,ty,x,'spline');

>> x=-1:0.01:5;

>> y=func1(x);

>> z=func2(x);

>> plot(x,y,'g',x,z,'b'), grid on

-1 0 1 2 3 4 5-6

-4

-2

0

2

4

6

8