ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Muller Newton-Raphson editor

wbdaTrabajo13 de Junio de 2013

413 Palabras (2 Páginas)587 Visitas

Página 1 de 2

MULLER NEWTON-RAPHSON

EDITOR

function raiz=NewtonRaphson(f,fderiv,x)

error=0.0005;

maxiter=50;

k=0;

fprintf('%5d%15.10f\n',k,x);

while 1

x0=x;

x=x0-f(x0)/fderiv(x0);

k=k+1;

fprintf('%5d%15.10f\n',k,x);

if (abs(x-x0)<=error || k==maxiter)

break

end

end

if k<maxiter

raiz=x;

end

VENTANA DE COMANDOS

3. Resuelva las siguientes ecuaciones aplicando el método de Newton-Raphson:

a) x3-5x2+25x -2=0

>> f=inline('(x^3)-(5.*(x^2))+(25*x)-2')

f =

Inline function:

f(x) = (x^3)-(5.*(x^2))+(25*x)-2

>> fderiv=inline('(3*x^2)-(10*x)+25')

fderiv =

Inline function:

fderiv(x) = (3*x^2)-(10*x)+25

>> NewtonRaphson(f,fderiv,1)

0 1.0000000000

1 -0.0555555556

2 0.0776154641

3 0.0812977895

4 0.0813004578

ans =

0.0813

>>

b) x2-4x+1=0

>> f=inline('x^2-4*x+1')

f =

Inline function:

f(x) = x^2-4*x+1

>> fderiv=inline('2*x-4')

fderiv =

Inline function:

fderiv(x) = 2*x-4

>> NewtonRaphson(f,fderiv,5)

0 5.0000000000

1 4.0000000000

2 3.7500000000

3 3.7321428571

4 3.7320508100

ans =

3.7321

c) x4-4x3+6x+4=0

>> f=inline('(x^4)-(4.*(x^3))+(6*x)+4')

f =

Inline function:

f(x) = (x^4)-(4.*(x^3))+(6*x)+4

>> fderiv=inline('(4.*(x^3))-(12.*(x^2))+6')

fderiv =

Inline function:

fderiv(x) = (4.*(x^3))-(12.*(x^2))+6

>> NewtonRaphson(f,fderiv,1)

0 1.0000000000

1 4.5000000000

2 3.8995098039

3 3.5463970753

4 3.3957035576

5 3.3663077676

6 3.3652314310

7 3.3652300134

ans =

3.3652

>>

d) 24x3+12x2+2x+1=0

>> f=inline('(24.*(x^3))+(12.*(x^2))+(2*x)+1')

f =

Inline function:

f(x) = (24.*(x^3))+(12.*(x^2))+(2*x)+1

>> fderiv=inline('(72.*(x^2))+(24*x)+2')

fderiv =

Inline function:

fderiv(x) = (72.*(x^2))+(24*x)+2

>> NewtonRaphson(f,fderiv,1)

0 1.0000000000

1 0.6020408163

2 0.3249123755

3 0.1099635935

4 -0.1435766705

5 -23.3074715163

6 -15.5938929544

7 -10.4515360646

8 -7.0233629778

9 -4.7380601349

10 -3.2148530813

11 -2.2001196584

12 -1.5252876982

13 -1.0791023606

14 -0.7897860809

15 -0.6138756042

16 -0.5265356393

17 -0.5019085644

18 -0.5000108450

19 -0.5000000004

ans =

-0.5000

...

Descargar como (para miembros actualizados) txt (2 Kb)
Leer 1 página más »
Disponible sólo en Clubensayos.com