Академический Документы
Профессиональный Документы
Культура Документы
4- Mtodos de Runge-Kutta
Definio 7.4.1: Sejam r um inteiro positivo e nmeros reais ai, bi, bij, para i = 1(1)r2 e j = 1(1)r.
com
r
K i = f ( xn + ai h, y n + h bij K j ) , i = 1(1)r (3)
j =1
e
r
a i = bij i = 1(1)r (4)
j =1
Observe que (1) e (2) definem uma classe de mtodos de passo um com tamanho h, isto ,
x n+1 = xn + h e as constantes reais ai, bi, bij identificam o particular mtodo deste tipo. Por serem
mtodos de passo um, o tamanho h (que poderia ser denotado por hn ) pode ser alterado a cada
passo, o que uma caracterstica desses mtodos.
1 Mais para frente discutiremos com mais detalhes esta afirmao sobre a ordem do mtodo.
2
A notao i=1(1)r significa que o i varia de 1 at r de um em um.
161
Observe tambm que nos Mtodos de Runge-Kutta o nmero r de estgios, identifica o
nmero de avaliaes da funo f que so necessrias a cada passo.
De acordo com Butcher (Butcher, 1987) podemos representar os coeficientes de um
mtodo de Runge-Kutta numa forma mais compacta do seguinte modo:
a B
bt
Definio 7.4.2: O mtodo de Runge-Kutta definido por (1) e (2) consistente com o P.V.I. se
( x n , y n ;0) = f ( x n , y n ).
Observao: Observe que o mtodo de Runge-Kutta consistente com o P.V.I. se, e somente se
r
b
j =1
j = 1.
162
k 3 = f ( xn + a3 h, y ( xn ) + b31hk1 + b32 hk 2 ) = f n + h[ a3 f x + b31 ff y + b32 ff y ]( x n , y ( x n )) +
a32 1 (9)
h 2[ f xx + a 3[b31 + b32 ] ff xy + ( b31 + b32 ) 2 f 2 f yy ]( x n , y ( x n )) + O ( h 3 )
2 2
Como b31 = a3 b32 temos
(ha 3 ) 2
k 3 = f + ha 3 f x + ha3 ff y hb32 ff y + hb32 f y + h 2 a 2b32 Ff y + f xx + (ha 3 ) 2 ff xy h 2 a 3b32 ff xy
2!
( ha3 ) 2 2 h2
+ h 2 a3 b32 ff xy + f f yy h 2 a 3 f 2 f yy h 2 a3b32 f 2 f yy + b322 f 2 f yy + h 2 a 3b32 f 2 f yy
2! 2!
2
h
h 2b322 f 2 f yy + b322 f 2 f yy + O( h 3 ).
2!
( ha3 ) 2
k 3 = f + ha3 [ f x + ff y ] + h 2 a 2b32 Ff y + [ f xx + 2 ff xy + f 2 f yy ] + O(h 3 ) .
2!
2
( ha )
k 3 = f + ha3 F + h 2 a 2b32 Ff y + 3
G + O( h 3 ) .
2!
Portanto
(ha 2 ) 2 (ha 3 ) 2
( x, y , h) = b1 f + b2 [ f + ha2 F + G + O( h 3 )] + b3 [ f + ha 3 F + h 2 a 2b32 Ff y + G + O( h 3 )]
2! 2!
2
h
= ( b1 + b2 + b3 ) f + h[a 2b2 + a3b3 ]F + [b2 a22G + 2a3b32 a2 Ff y + a32b3G] + O( h 3 )
2!
Portanto
h2
( x, y, h ) = (b1 + b2 + b3 ) f + h[ a 2b2 + a3b3 ] F + ( b2 a22 + a 32 b3 )G + 2a3b32 a2 Ff y ] + O( h 3 ) (10)
2!
Por outro lado, a t do algoritmo de Taylor desenvolvida, chega :
h h2
t ( x, y, h ) = f + F + [ G + f y .F ] + O( h 3 ) (11)
2 3!
Estes mtodos so gerados a partir da comparao entre a expanso da srie para
t ( x n , y n ; h) gerada pelo mtodo (10) e t ( x , y ( x ); h ) da soluo analtica.
Exemplo 7.4.1:
Determinar um mtodo de 2 estgios e de ordem mxima.
Comparando (10) com (11) no desenvolvimento em Taylor, chegamos ao sistema:
b1 + b2 = 1
b a =1 .
2 2 2
(*)
Como temos duas equaes e trs incgnitas, temos infinitos mtodos de Runge-Kutta de ordem 2
e dois estgios.
163
647 F
4
8 h2 64447 G
444 8
t ( x , y , h) = (b1 + b2 ) f + hb2 a 2 ( f x + ff y ) + b2 a 2 ( f xx + 2 ff xy + f yy f 2 ) + O(h 3 )
2
(13)
2
Observao: No conseguimos um mtodo de Runge-Kutta de 2 estgios com ordem 3 a menos
que se imponha condies sobre a f ( x , y ) , pois para se ter ordem 3, teramos mais a seguinte
condio (alm de (*)):
a22 b2 1 1 a 22 1 1 a 1 1
G = G + f yF G = f y F ( 2 )G = f y F
2 6 6 4 6 6 4 6 6
e isso s seria satisfeito se impusssemos condies sobre f(x, y).
Exemplo 7.4.2:
Um mtodo de Runge-Kutta de 2 estgios de ordem 2:
1
1. Seja b1 = 0 b2 = 1 e a 2 = .
2
Temos ento y n+1 y n = h ( xn , y n , h) = h[b1 + b2 ] = hb2 k 2 .
Portanto
h h h
y n+1 y n = hf ( x n + , y n + ha2 k 1 ) = f ( x n + , y n + f ( x n , y n )) ,
2 2 2
que o mtodo de Euler modificado.
1 1
2. Seja b1 = . Portanto b2 = e a 2 = 1
2 2
h
y n+1 y n = [ f ( x n , y n ) + f ( x n + h, y n + hf ( x n , y n ))] ,
2
que mtodo de Euler melhorado.
Exemplo 7.4.3:
Resolva o Problema de valor inicial
y'= x y 2
y (0) = 0
pelo mtodo de Euler Modificado usando h = 0,1. Calcular y1 e y 2 .
Soluo:
O mtodo de Euler Modificado dado por:
h h
y n+1 y n = hf ( x n + , y n + f ( x n , y n ))
2 2
h h
y1 = y0 + hf ( x 0 + , y 0 + f ( x0 , y 0 )) , f ( x 0 , y 0 ) = 0 0 = 0
2 2
0,1 0,1
y1 = 0 + 0,1 f ( , 0 + .0) = 0,1. f (0,05; 0) = 0,1[0,05 0 2 ] = 0,005
2 2
h h
y 2 = y1 + hf ( x1 + , y1 + f ( x1 , y1 ))
2 2
f ( x1 , y1 ) = 0,1 ( 0,005) = 0,099975
2
0,1 0,1
y 2 = 0,005 + 0,1 f (0,1 + ; 0,005 + 0,0099975) = 0,0199900025
2 2
164
Comparando (10) com (11) e considerando a nulidade das expresses que acompanham as
potncias de h at ordem 3, obtemos as condies de ordem, dadas a seguir:
1
b1 + b2 + b3 = 1 a 2 b2 + a 3 b3 =
2
(14)
1 1
a 2 b2 + a3 b3 = b21b32b3 =
2 2
3 6
Considerando em (10) a 2 e a 3 como parmetros livres, determinamos de maneira nica
os demais parmetros, obtendo a famlia de mtodos de Runge-Kutta de 3 estgios com ordem 3.
Temos portanto 4 equaes a 6 incgnitas; atribuindo valores a 2 variveis determinamos
as outras 4. Novamente temos infinitos mtodos de Runge-Kutta de 3 estgios de ordem 3.
Tambm nesse caso, no conseguimos um mtodo de 3 estgios e de ordem 4 a menos que
se imponha condies sobre f(x,y).
1
Exemplo 7.4.4: Seja b1 = ; b2 = 0
4
1 3 3 1 2
b3 = 1 = ; a 3 = a3 =
4 4 4 2 3
1 2 3
a 22 .0 = ( ) 2 . = 0 ; a 2 serve.
3 3 4
1
Impondo que a 2 = temos
3
1 1 2
b32 = b32 = .
4 6 3
Temos:
y n+1 y n = h ( xn , y n , h ) = h[ b1k1 + b2 k 2 + b3k 3 ]
= h[ b1 f ( x n , y n ) + b 3 f ( x n + a 3 h , y n + h [( a 3 b 32 ) k 1 + b 32 k 2 ])
1424 3
=0
y n+1 y n = h [ f ( x n , y n ) + 3 f ( x n + 2 h , y n + 2 f ( x n + h , y n + 1 f ( x n , y n )])
4 3 3 3 3
que o mtodo de Heun.
Exemplo 7.4.5:
1 2 1 2 1
Considere b1 = e b2 = (e portanto b3 = 1 = ).
6 3 6 3 6
1 2a + 1a = 1
b2 a2 + b3a 3 = 2 2 6 3 2
Temos 3
1 2 1 1
b2 a 22 + b3 a32 = a 22 + a 32 =
3 3 6 3
Tm-se que 4 a2 + a3 = 3 a 3 = 3 4 a2 .
Assim:
4 a22 + 9 24a 2 + 16a 22 = 2 20a 22 24a 2 + 7 = 0 .
24 576 560 24 16 = 28
a2 = a2 = a2 = 40 .
2.20 40 = 1
2
1 162
Se a 2 = a 3 = 3 4a 2 = 1 e b32 = = 2.
2 611
165
y n+1 y n = h ( xn , y n , h ) = h(b1k1 + b2 k 2 + b3k 3 )
= [b1 f ( xn , y n ) + b2 f ( xn + a 2h, y n + ha 2 k1 ) + b3 f ( xn + a3 h, y n + h[ a3 b32 )k 1 + b32 k 2 ])]
h h
f ( x , y ) + 4 f ( x + , y + f ( x n , y n )) + f ( xn + h, y n hf ( x n , y n ) +
h n n n
2 n
2
y n+1 y n =
6 h h
2 hf ( x n + , y n + f ( x n , y n ))
2 2
que o mtodo de Kutta de ordem 3.
Exemplo 7.4.6:
Considere b2 = b3 e a 2 = a 3 .
Temos
b1 = 1 2b3
1 1
2b3 a3 = 2 b3 a3 = 4 1 1 2
a3 = a3 =
1 1 4 6 3
2b3a 32 = b3 a32 =
3 6
2 3 3 1 1 3 8 2
a 2 = , b3 = = b2 , b1 = 1 = e b32 = . . =
3 8 4 4 6 2 3 3
Assim, o mtodo constitudo pelos parmetros determinados acima :
y n+1 y n = h[ b1 f + b2 f ( xn + ha 2 , y n + ha 2 f ( x n , yn )) + b3 f ( x n + ha 3 , yn + h( a3 b32 ) f ( x n , y n ) +
b32 f ( x n + ha 2 , y n + ha 2 f ( xn , y n ))].
1 3 2h 2h 3 2h 2h 2h 2h
y n+1 y n = h[ f + f ( x n + , yn + f ( x n , y n )) + f ( x n + , yn + f (x n + , yn + f ( x n , y n ))].
4 8 3 3 8 3 3 3 3
que o mtodo de Nystrn de ordem 3.
166
2. Os mtodos de ordem 4 so os mais usados.
A medida que p cresce, o nmero de condies de ordem aumenta numa razo maior, e
conseqentemente o nmero de equaes do sistema a ser resolvido tambm cresce, tornando a
obteno de soluo para o sistema mais complexa. Torna-se ento interessante utilizar equaes
auxiliares, que substituam com vantagens, algumas das equaes auxiliares, denominadas
condies simplificadoras, que permitem simplificar a obteno de mtodos RK(s,p).
Enumeraremos estas condies por A(p), B(p), C(p), D( ) e E( ,p) e representam o seguinte:
Observaes:
Calculemos a funo erro principal para os mtodos de Runge-Kutta nos seguintes casos:
167
Tn+1 = y ( x n+1 ) y ( x n ) h ( xn , y( x n ), h) = y ( x n+1 ) y ( xn ) hf ( x n , y ( x n ))
Temos
Tn+1 = y ( x n+1 ) y ( x n ) h ( x n , y ( xn ), h) = y ( x n+1 )
h2
= y ( x n+1 ) y ( x n ) h[(b1 + b2 ) f + hb2 a 2 F + b2 a22 G + O(h 3 )]
2!
b1 + b2 = 1
Como r = 2 e p = 2, temos: 1
b a =
2 2
2
h h2
Portanto Tn+1 = y ( x n+1 ) y ( x n ) h[ f +
F+ b2 a22 G + O(h 3 )] .
2 2!
Desenvolvendo y ( x n+1 ) em srie de Taylor em torno do ponto x n , obtemos:
h2 h3 h
Tn+1 = y ( x n ) + hy ' ( x n ) + y"( xn ) + y ' ' ' ( x n ) + O( h 4 ) y ( xn ) h[ f ( xn , y ( x n )) + Fx = xn
2! 3! 2
h2
+ b2 a 22G x= xn + O(h 3 )
2!
3
h h3
Tn+1 = [G + Ff y ] x = xn b2 a22 Gx = xn + O( h 4 )
3! 2
1 1 1 1 1 1
Tn+1 = [ Ff y + ( b2 a22 )G ] x = xn + O (h 4 ) = [ Ff y + ( a 2 )G ] x = x n h 3 + O ( h 4 )
6 6 2 6 6 4
1 1 1 1 1 1
( x, y ) = Ff y + ( a2 )G e ETLP = [ Ff y + ( a 2 )G ]h .
3
6 6 4 6 6 4
Exemplos 7.4.7:
a) Provar que a e.d.o. y ' = 2ax resolvida exatamente (segundo o ETLP) por um mtodo de
Runge-Kutta de ordem 2.
1 1 1
Tem-se que: ETLP = [ [ Ff y + { a 2 )G ]h 3 . Entretanto f = 2ax f y = 0 e
6 6 4
G = f xx + 2 ff xy + f f yy = 0 + 2( 2ax) 0 + f 2 .0 = 0
2
ETLP = 0.
Ou seja,
y ( x n+1 ) y ( x n ) hf ( x n , y ( x n )) .
168
y'= x y 2
b) Calcule o ETLP quando o problema de valor inicial resolvido por:
y (0) = 0
b1) Mtodo de Euler;
b2) Mtodo de Euler Modificado.
Soluo:
fx + f y f 1 + ( 2 y)( x y 2 ) 2
b1) ETLP = { }h 2 = h .
2 2
1 1 1
b2) ETLP = { Ff y + ( a 2 )G}h 3
6 6 4
1 1 1
Como a 2 = , ento ETLP = { Ff y + G}h 3
2 6 24
Se G = f xx + 2 ff xy + f f yy = 0 + 2( x y 2 ).0 + ( 2)( x y 2 ) 2 = 2( x 2 2 xy 2 + y 4 )
2
2y 1
ETLP = { (1 2 xy + 2 y 3 ) ( x 2 2 xy2 + y 4 )}h 3
6 12
y ' = 0,04 y
c) Resolva o P.V.I. pelos Mtodos de
y (0) = 1000
c1) Euler
c2) Euler-Modificado.
C3) Runge Kutta.
(Obs. Soluo Exata: y ( x ) = 1000e 0, 04x )
Soluo:
Para h = 1 , temos
y (1) y1 = (1 + 0,04).1000 = 1040 .
169
y 4 = (1 + 0,04.0,25) 4 .1000 = 1040,604 .
Para h = 0,1 , temos:
y (1) y10 e
y10 = (1 + 0,04.0,1)10 .1000 = 1040.7277 .
2 2
Anlogo ao que vimos para o Mtodo de Euler,
h2
y k = (1 + 0,04 h + 0,04 2 ) k .1000
2
Para h = 1 , temos
1
y (1) y1 = (1 + 0,04 + .0.04 2 ).1000 = 1040,8.
2
Para h = 0,5 , tem-se:
( 0,5) 2
y (1) y 2 = (1 + 0,04.0,5 + .0,04 2 ) 2 .1000 = 1040,808.
2
Para h = 0,25 , tem-se:
(0,25) 2
y (1) y 4 = (1 + 0,04.0, 25 + .0,04) 2 ) 4 .1000 = 1040,8101.
2
Para h = 0,1 , tem-se:
(0,1) 2
y (1) y10 = (1 + 0,04.0,1 + .0,04 2 )10 .1000 = 1040,8107.
2
Observao: Dada a resposta exata y (1) = 1040,8108 com quatro casas decimais, vemos que,
medida que h diminui, cada mtodo obtm uma melhor aproximao e que entre os dois, como era
de se esperar, o Mtodo de Euler Aperfeioado fornece melhores resultados; veja que h = 0,1 ,
y (1) 1040,8107 , por Euler Aperfeioado!
Observamos que sendo x 0 = 0, ento x k = x0 + k.h = kh .
Por outro lado, a srie de Taylor de e 0, 04 x , em torno de x = 0 :
x 2 (0,04) 3 x 3
e 0, 04 x = 1 + 0,04 x + 0,04 2 + + ...
2 3!
2
2 h (0,04) 3 h 3
e 0, 04h = 1 + 0,04h + 0,04 + + ...
2 3!
h2 k
V-se que tanto (1 + 0,04h) k do mtodo de Euler como (1 + 0,04h + 0,04 2 ) do mtodo
2
de Euler Aperfeioado so aproximaes para e 0, 04hk = e 0, 04 x k .
170
1
Observao: Como estamos interessados em y(1), ou seja, x =1, ento k = . Assim, tambm
h
natural, que no mtodo de Euler3 , medida que h diminui, chegamos mais prximos da soluo
pois
e 0, 04 = lim (1 + 0,04 h)1 / h .
h0
Exemplo 7.4.8:
2y
y ' = + ( x + 1) 3
Dado o P.V.I. x +1 obtenha y (1) e y( 2).
y (0) = 3
1
Soluo: A soluo exata desta equao : y ( x ) = [( x + 1) 4 + 5( x + 1) 2 ] , portanto y(1) = 18 e
2
y(2) = 63.
Aplicando o mtodo de Runge Kutta de 4a. ordem, descrito abaixo
1
y n+1 = y n + ( K 1 + 2 K 2 + 2 K 3 + K 4 )
6
onde
K1 = hf ( x n , y n ) ,
h K
K 2 = hf ( x n + , y n + 1 ) ,
2 2
h K
K 3 = hf ( x n + , y n + 2 ) ,
2 2
K 4 = hf ( x n + h, y n + k 3 ) ,
obtemos os seguintes resultados:
Para h = 0,125:
k xk yk
1 0,125 3,964938
2 0,25 5,126896
3 0,375 6,513706
4 0,5 8,1516128
5 0,625 10,08786
6 0,75 12,34551
7 0,875 14,96864
171
8 1 17,99972
9 1,125 21,48418
10 1,25 25,47034
11 1,375 30,00947
12 1,5 35,15578
13 1,625 40,96639
14 1,75 47,50137
15 1,875 54,8237
16 2,0 62,99929
Para h =0,2:
k xk yk
1 0,2 4,636539
2 0,4 6,820251
3 0,6 9,67593
4 0,8 13,34757
5 1,0 17,99838
6 1,2 23,81075
7 1,4 30,98627
8 1,6 39,74576
9 1,8 50,32921
10 2,0 62,99581
7.4.3- Exerccios
7.4.3.1) Fazer os exerccios relativos aos tpicos vistos nos livros: Barroso, L. C. e Ruggiero,
M.A.G.
172