Você está na página 1de 27

Ecuaciones diferenciales de 1er orden :

E D O. Grafica Euler
Se quiere solucionar problema de EDO de 1 Orden de la forma
dy
= f ( x, y )
dx

El mtodo para la resolucin es de la forma


Nuevo valor = valor anterior + pendiente * tamao del paso

yi+1= yi + h

Todos los m todos de integracin de EDO de un solo paso se pueden expresar de


esta forma, lo que cambia es la forma como se calcula la pendiente
yi+1= yi + h

yi+1= yi + h

Predicho
yi+1

Error

yi
Pendiente =

Verdadero

h
h

La primera derivada proporciona una


estimacin directa de la pendiente.

xi-1

xi
h= paso

xi+1

Mtodo de Euler:
Es un mtodo sencillo para la integracin de ecuaciones diferenciales
de primer orden.
Sea:

dy
= f (x,y)
dx

con la condicin de contorno:

y(x 0 ) = y0

x1 = x 0 + h
y1 y0 + f (x0 ,y 0 ) h

Utilizar el mtodo de Euler para aproximar el valor de la solucin de


la siguiente ecuacin diferencial en los puntos x = 0.2, 0.4, 0.6, 0.8 y 1,
usando h = 0.2 y h = 0.1.

dy
= 2x + y ; y(0) = 1
dx
h = 0.2

x1 = x 0 + h = 0 + 0.2 = 0.2
y1 y0 + f (x0 ,y 0 ) h = 1 + 1 0.2 = 1.2
x2 = x1 + h = 0.2 + 0.2 = 0.4
y2 y1 + f (x1, y1 ) =h 1.2 + 1.6 0.2 = 1.52

x3 = x2 + h = 0.4 + 0.2 = 0.6


y3 y2 + f (x 2 , y2 ) h = 1.52 + 2.32 0.2 = 1.984
x4 = x 3 + h = 0.6 + 0.2 = 0.8
y4 y3 + f (x 3 , y3 ) h = 1.984 + 3.184 0.2 = 2.6208
x5 = x 4 + h = 0.8 + 0.2 = 1.0
y5 y4 + f (x4 ,y 4 ) h = 2.6208 + 4.2208 0.2 = 3.46496

h = 0.1

x1 = x 0 + h = 0 + 0.1 = 0.1
y1 y0 + f (x0 ,y 0 ) h = 1 + 1 0.1 = 1.1
x2 = x1 + h = 0.1 + 0.1 = 0.2
y2 y1 + f (x1, y1 ) =h 1.1 + 1.3 0.1 = 1.23
x3 = x2 + h = 0.2 + 0.1 = 0.3
y3 y2 + f (x 2 , y2 ) h = 1.23 + 1.63 0.1 = 1.393
x4 = x 3 + h = 0.3 + 0.1 = 0.4
y4 y3 + f (x 3 , y3 ) h = 1.393 + 2.3923 0.1 = 1.83153

x5 = x 4 + h = 0.4 + 0.1 = 0.5


y5 y4 + f (x4 ,y 4 ) h = 1.5923 + 2.3923 0.1 = 1.83153
x6 = x 5 + h = 0.5 + 0.1 = 0.6
y6 y5 + f (x 5 , y5 ) h = 1.83153 + 2.83153 0.1 = 2.114683
x7 = x 6 + h = 0.6 + 0.1 = 0.7
y7 y6 + f (x6 , y6 ) h = 2.114683 + 3.314683 0.1 = 2.4461513
x8 = x 7 + h = 0.7 + 0.1 = 0.8
y8 y7 + f (x 7 , y7 ) h = 2.4461513 + 3.8461513 0.1 = 2.8307664

x9 = x 8 + h = 0.8 + 0.1 = 0.9


y9 y8 + f (x 8 , y8 ) h = 2.8307664 + 4.4307664 0.1 = 3.273843
x10 = x 9 + h = 0.9 + 0.1 = 1.0
y10 y9 + f (x9 , y9 ) h = 3.273843 + 5.073843 0.1 = 3.7812273
Vemos que obtenemos valores distintos de los que habamos calculado
para h = 0.2. Cuanto menor sea h, mejor ser la aproximacin (aunque
tambin ms laboriosa). Para un h constante el error ser tanto mayor
cuanto ms nos alejemos del punto inicial, como puede apreciarse en la
grfica siguiente en la que comparamos las dos soluciones aproximadas
con la solucin exacta.

y(x) = -2(x+1)+3e

h = 0.1

h = 0.2

0
0

0.2

0.4

0.6

0.8

1.2

Mtodo de Euler modificado:


La solucin exacta de la ecuacin diferencial de primer orden:

dy
= f (x,y) ; y(x 0 ) = y0
dx
en el punto x1 vendra dada por la siguiente expresin:
x1

y(x1 ) = y(x0 ) + f (x,y) dx


x0

En el mtodo de Euler sencillo que vimos anteriormente tombamos la


siguiente aproximacin:

y(x1 ) y(x0 ) + f (x0 , y0 ) (x1 x 0 )

Esta aproximacin es equivalente a suponer que en el integrando de la


solucin exacta f(x,y) es constante e igual a su valor en el extremo
inferior de la integral, es decir, f(x, y) = f(x0,y0):
x1

y(x1 ) = y(x0 ) + f (x,y) dx = y(x0 ) + f (x 0 , y0 ) (x1 x0 )


x0

si f (x,y) = f (x0 ,y 0 )

Parecera ms razonable el pensar que obtendramos un valor ms


preciso si aproximramos la integral de f(x,y) por un promedio de sus
valores en los dos extremos de la integral en vez de tomarla igual a su
x1 inferior.
valor en el extremo
f (x , y ) + f (x ,y )

y(x1 ) = y(x0 ) + f (x,y) dx = y(x0 ) +


x0

(x1 x0 )

f (x0 ,y 0 ) + f (x1 , y1 )
si f (x,y) =
2
Sin embargo, de esa manera, nos encontraramos con el problema de
que, para calcular y1 necesitamos saber su valor para evaluar f(x1,y1).

El problema se solventa del siguiente modo: Primero se obtiene una


aproximacin de y1 usando el mtodo de Euler sencillo:

y1 (0) y 0 + f (x 0 , y0 ) h
a continuacin, se usa esta aproximacin sencilla para calcular f(x1,y1(0))
y as poder tomar la siguiente nueva estimacin para el valor de y1 :

y1 (1)

f (x 0 , y0 ) + f (x1 ,y1(0) )
= y0 +
h
2

naturalmente, podramos utilizar esta nueva aproximacin para obtener


otra:

y1 (2)

f (x 0 , y0 ) + f (x1 ,y1(1) )
= y0 +
h
2

y as, podramos iterar hasta obtener una aproximacin definitiva.

Una vez que estimemos que tenemos una estimacin sensata de y1


repetiramos el procedimiento para calcular y2:

y2

(0)

y2 (1)

y2 (2)

y1 + f (x1 , y1 ) h
f (x1 , y1 ) + f (x 2 , y2 (0) )
= y1 +
h
2

f (x1 , y1 ) + f (x 2 , y2 (1) )
= y1 +
h
2
M

Utilizar el mtodo de Euler modificado para aproximar el valor de la


solucin de la siguiente ecuacin diferencial en los puntos x = 0.2 y 0.4,
usando h = 0.2 y con tres decimales de aproximacin:

dy
= 2x + y ; y(0) = 1
dx
h = 0.2

x1 = x 0 + h = 0 + 0.2 = 0.2
y1
y1

(1)

(0)

y 0 + f (x 0 , y0 ) h = 1 + 1 0.2 = 1.2

1+ 2 0.2 + 1.2
f (x 0 , y0 ) + f (x1 ,y1(0) )
0.2 = 1.26
= y0 +
h =1+
2
2

y1 (2)
y1

(3)

y1

(4)

1+ 2 0.2 + 1.26
f (x 0 , y0 ) + f (x1 ,y1(1) )
0.2 = 1.266
= y0 +
h=1+
2
2
f (x0 , y0 ) + f (x1 , y1(2) )
1+ 2 0.2 + 1.266
= y0 +
h =1+
0.2 = 1.2666
2
2
f (x 0 , y0 ) + f (x1 , y1 (3) )
1+ 2 0.2 + 1.2666
= y0 +
h =1+
0.2 = 1.26666
2
2

Luego, con tres cifras decimales, tendramos:

y1 1.267

x2 = x1 + h = 0.2 + 0.2 = 0.4


y2 (0) y1 + f (x1 , y1 ) h = 1.267 + (2 0.2 + 1.267) 0.2 = 1.6004
(0)
,
y
)
+
f
(x
,
y
)
f
(x
(1)
1 1
2 2
y2 = y1 +
h
2
(2 0.2 + 1.267) + (2 0.4 + 1.6004)
(1)
y2 = 1.267 +
0.2 = 1.67374
2

y2 (2)
y2

(2)

y2
y2

y2
y2

= 1.267 +

(3)

(2)

(2 0.2 + 1.267) + (2 0.4 + 1.67374)


2

0.2 = 1.681074

f (x1 ,y1 ) + f (x 2 , y2 (2) )


= y1 +
h
2

= 1.267 +

(4)

(4)

f (x1 , y1 ) + f (x 2 , y2 (1) )
= y1 +
h
2

(2 0.2 + 1.267) + (2 0.4 + 1.681074)


2

0.2 = 1.6818074

f (x1 , y1 ) + f (x2 ,y2 (3) )


= y1 +
h
2

= 1.267 +

(2 0.2 + 1.267) + (2 0.4 + 1.6818074)


2

0.2 = 1.6818807

Luego, con tres cifras decimales, tendramos:

y2 1.682

y(x) = -2(x+1)+3e

h = 0.1

h = 0.2

h = 0.2
Euler modificado

0
0

0.2

0.4

0.6

0.8

1.2

Mtodo de Runge-Kutta (de cuarto orden):


Los llamados mtodos de Runge-Kutta son una serie de algoritmos
para calcular aproximaciones nmericas del valor de la solucin de:

dy
= f (x,y) ; y(x 0 ) = y0
dx

en puntos de la forma siguiente:

x1 = x 0 + h ; x2 = x1 + h ; etc
con muy buena precisin, sin que, para ello, sea necesario que los h sean
muy pequeos.
El procedimiento consta de los siguientes pasos:

Para calcular un valor aproximado de la solucin y1 en el punto


x1 = x0 + h, se calculan los siguientes nmeros:

k1 = h f (x 0 ,y0 )
h
k1
k 2 = h f (x0 + , y0 + )
2
2
k2
h
k3 = h f (x 0 + , y0 + )
2
2

k 4 = h f (x0 + h, y0 + k3 )
1
K0 = (k1 + 2k 2 + 2k 3 + k4 )
6

y entonces se toma:

y1 = y0 + K0

Procediendo del mismo modo, calcularamos el valor aproximado de


la solucin, y2, en el punto x2 = x1 + h:

k1 = h f (x1 , y1 )
h
k1
k 2 = h f (x1 + , y1 + )
2
2
k2
h
k3 = h f (x1 + , y1 + )
2
2

k 4 = h f (x1 + h, y1 + k3 )
1
K0 = (k1 + 2k 2 + 2k 3 + k4 )
6
y2 = y1 + K0

Y as, sucesivamente, para el punto ensimo, tendramos xn = xn-1 + h:

k1 = h f (x n1 , yn1 )
h
k1
k 2 = h f (xn1 + , yn1 + )
2
2
k2
h
k3 = h f (x n1 + ,y n1 + )
2
2

k 4 = h f (xn1 + h, yn1 + k3 )
1
K0 = (k1 + 2k 2 + 2k 3 + k4 )
6
yn = yn1 + K0

Utilizar el mtodo de Runge-Kutta con el problema siguiente para


calcular la solucin aproximada en x = 0.2 y x =0.4:

dy
= 2x + y ; y(0) = 1
dx
h = 0.2:

x1 = x 0 + h = 0 + 0.2 = 0.2

k1 = h f (x 0 ,y0 ) = 0.2 (2 0 + 1) = 0.2


k1
h
k 2 = h f (x0 + , y0 + ) = 0.2 f (0 + 0.1, 1+ 0.1)
2
2
k 2 = 0.2 (2 0.1+ 1.1) = 0.26
k2
h
k3 = h f (x 0 + , y0 + ) = 0.2 f (0.1, 1.13)
2
2
k3 = 0.2 (2 0.1 + 1.13) = 0.266

k 4 = h f (x0 + h, y0 + k3 )= 0.2 f (0.2, 1.266)


k 4 = 0.2 (2 0.2 + 1.266) = 0.3332
1
K0 = (k1 + 2k 2 + 2k 3 + k4 ) = 0.2642
6
y1 = y0 + K0 = 1.2642
x2 = x1 + h = 0.2 + 0.2 = 0.4
k1 = h f (x1 , y1 ) = 0.2 (2 0.2 + 1.2642) = 0.33284
k1
h
k 2 = h f (x1 + , y1 + ) = 0.2 f (0.3, 1.43062) = 0.40612
2
2

k2
h
k3 = h f (x1 + , y1 + ) = 0.2 f (0.3, 1.46726) = 0.41345
2
2

k 4 = h f (x1 + h, y1 + k3 ) = 0.2 f (0.4, 1.67765) = 0.49553


1
K0 = (k1 + 2k 2 + 2k 3 + k4 ) = 0.41125
6
y2 = y1 + K0 = 1.2642 + 0.41125 = 1.67545

Utilizar el mtodo de Runge-Kutta con el problema siguiente para


calcular la solucin aproximada en x = 0.1 y x =0.2:

dy
= x 2 + y2
dx
h = 0.1:

; y(0) = 1

x1 = x 0 + h = 0 + 0.1 = 0.1

k1 = h f (x 0 ,y0 ) = 0.1f (0,1) = 0.1 (0 + 1 ) = 0.1


h
k1
k 2 = h f (x0 + , y0 + ) = 0.1 f (0.05, 1.05)
2
2
2
2
k 2 = 0.1 (0.05 + 1.05 )= 0.1105
k2
h
k3 = h f (x 0 + , y0 + =) 0.1 f (0.05, 1.05525)
2
2
k3 = 0.1116052
2

k 4 = h f (x0 + h, y0 + k3 ) = 0.1 f (0.1, 1.1116052)


2

k 4 = 0.1 (0.1 + 1.1116052 ) = 0.1245666

1
K0 = (k1 + 2k 2 + 2k 3 + k4 ) = 0.1114628
6
y1 = y0 + K0 1.1115
x2 = x1 + h = 0.1+ 0.1 = 0.2
k1 = h f (x1 , y1 ) = 0.1 (0.12 + 1.11152 ) = 0.1245432
h
k1
k 2 = h f (x1 + , y1 + ) = 0.1 f (0.15, 1.1737716) = 0.1400239
2
2

k2
h
k3 = h f (x1 + , y1 + ) = 0.1 f (0.15, 1.181512) = 0.141847
2
2

k 4 = h f (x1 + h, y1 + k3 ) = 0.1f (0.2, 1.2533471) = 0.1610878

1
K0 = (k1 + 2k 2 + 2k 3 + k4 ) = 0.1415621
6
y2 = y1 + K0 1.2531

Você também pode gostar