08.08.2013 Views

Nadir Arada - (Cálculo Numérico) - Portal de docentes FCT/UNL

Nadir Arada - (Cálculo Numérico) - Portal de docentes FCT/UNL

Nadir Arada - (Cálculo Numérico) - Portal de docentes FCT/UNL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

APROXIMAÇÃO NUMÉRICA DE EQUAÇÕES<br />

DIFERENCIAIS ORDINÁRIAS<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

<strong>Nadir</strong> <strong>Arada</strong>


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Problema <strong>de</strong> Cauchy<br />

Seja I um intervalo <strong>de</strong> IR e seja f : I × IR −→ IR uma função contínua.<br />

Para yo dado, procura-se y que satisfaz o problema na condição inicial<br />

y ′ (t) = f(t, y(t)) t ∈ I<br />

on<strong>de</strong> y ′ (t) = dy<br />

dt<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

y(a) = yo


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Exemplos. Um problema <strong>de</strong> Cauchy po<strong>de</strong> ser linear, como por<br />

exemplo y ′ (t) = 3y(t) − 3t t > 0<br />

y(0) = 1<br />

on<strong>de</strong> f(t, u) = 3u − 3t e cuja única solução é y(t) = 2<br />

3 e3t + t + 1<br />

3 .<br />

• Um problema <strong>de</strong> Cauchy po<strong>de</strong> ser não linear, como por exemplo<br />

y ′ (t) = y 1<br />

3 , t > 0<br />

y(0) = 0<br />

para o qual f(t, u) = u 1<br />

3 e admite as três soluções y(t) =<br />

y(t) = −<br />

<br />

8t3 27<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

ou a solução trivial y(t) = 0.<br />

8t 3<br />

27 ,


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Existência e unicida<strong>de</strong> <strong>de</strong> solução exacta<br />

Teorema <strong>de</strong> Cauchy-Lipschitz. Suponha que f satisfaz as seguintes<br />

condições<br />

1. f é contínua em IR × I<br />

2. f é lipschitziana em relação a segunda variável, isto é existe uma<br />

constante positiva L (chamada constante <strong>de</strong> Lipschitz) tal que<br />

|f(t, y1) − f(t, y2)| ≤ L |y1 − y2| ∀ t ∈ I e ∀ y1, y2 ∈ IR.<br />

Então o problema <strong>de</strong> Cauchy admite uma única solução.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Derivada numérica<br />

Consi<strong>de</strong>re y ∈ C 1 [a, b] e seja t∗ um ponto genérico em ]a, b[. A<br />

<strong>de</strong>rivada <strong>de</strong> y no ponto t∗ é<br />

y ′ (t∗) = lim<br />

h→0 +<br />

y(t∗+h)−y(t∗)<br />

h<br />

Portanto, para h suficientemente pequeno e positivo, a quantida<strong>de</strong><br />

D+(t∗) = y(t∗+h)−y(t∗)<br />

h<br />

é uma aproximação da <strong>de</strong>rivada y ′ (t∗), chamada diferença finita<br />

progressiva.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Para estimar o erro <strong>de</strong> aproximação associado, basta consi<strong>de</strong>rar o<br />

<strong>de</strong>senvolvimento <strong>de</strong> Taylor <strong>de</strong> y a volta <strong>de</strong> t∗: Se y ∈ C 2 [a, b], tem-se<br />

Portanto,<br />

y(t∗ + h) = y(t∗) + hy ′ (t∗) + h2<br />

2 f”(η) η ∈ [t∗, t∗ + h]<br />

D+(t∗) − y ′ (t∗) = y(t∗+h)−y(t∗)<br />

h<br />

e, assim, o erro satisfaz<br />

<br />

′<br />

y (t∗) − D+(t∗) <br />

<br />

= f”(η)<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

2 h<br />

− y ′ (t∗) = h2<br />

2 f”(η)<br />

<br />

<br />

≤ maxt∈[t∗,t∗+h]|f”(t)| h<br />

2


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Do mesmo modo, a <strong>de</strong>rivada <strong>de</strong> y no ponto t∗ também po<strong>de</strong> ser<br />

<strong>de</strong>finida por<br />

y ′ (t∗) = lim<br />

h→0 +<br />

y(t∗)−y(t∗−h)<br />

h<br />

Portanto, para h suficientemente pequeno e positivo, a quantida<strong>de</strong><br />

D−(t∗) = y(t∗)−y(t∗−h)<br />

h<br />

é uma aproximação da <strong>de</strong>rivada y ′ (t∗), chamada diferença finita<br />

regressiva. Se y ∈ C 2 [a, b], tem-se<br />

y(t∗ − h) = y(t∗) − hy ′ (t∗) + h2<br />

2 f”(η) η ∈ [t∗ − h, t∗]<br />

Portanto, o erro satisfaz<br />

<br />

′<br />

y (t∗) − D−(t∗) <br />

<br />

= f”(η)<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

2 h<br />

<br />

<br />

≤ maxt∈[t∗−h,t∗]|f”(t)| h<br />

2


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Seja n ∈ IN, h = b−a<br />

n<br />

Aproximação do problema <strong>de</strong> Cauchy<br />

e sejam<br />

ti = a + ih, i = 0, · · · , n<br />

(n + 1) pontos equidistantes em [a, b]. O problema <strong>de</strong> Cauchy<br />

<strong>de</strong>finido para qualquer t ∈ [a, b] é também <strong>de</strong>finido nos nós ti, isto é<br />

Notamos<br />

y ′ (ti) = f (ti, y(ti)) i = 0, · · · , n<br />

ui uma aproximação <strong>de</strong> y(ti)<br />

Precisamos igualmente <strong>de</strong> aproximar a <strong>de</strong>rivada y ′ (ti): utilizamos as<br />

<strong>de</strong>rivadas numéricas introduzidas anteriormente.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Métodos <strong>de</strong> Euler<br />

Esquema <strong>de</strong> Euler progressivo<br />

ui+1−ui<br />

h = f (ti, ui) i = 0, 1, · · · , n − 1<br />

u0 = yo<br />

Esquema <strong>de</strong> Euler regressivo<br />

ui+1−ui<br />

h = f (ti+1, ui+1) i = 0, 1, · · · , n − 1<br />

u0 = yo<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

• O esquema <strong>de</strong> Euler progressivo é um esquema explícito que<br />

permite calcular ui+1 em função <strong>de</strong> ui explicitamente<br />

ui+1 = ui + hf (ti, ui)<br />

• O esquema <strong>de</strong> Euler regressivo é um esquema implícito, porque<br />

ui+1 é <strong>de</strong>finida implicitamente em função <strong>de</strong> ui<br />

ui+1 = ui + hf (ti+1, ui+1)<br />

Para <strong>de</strong>terminar ui+1, é preciso geralmente resolver uma equação não<br />

linear.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Exemplo 1. Consi<strong>de</strong>re o seguinte problema <strong>de</strong> Cauchy<br />

<br />

′ 2 y (t) = − 5 y(t) + sin (5t) t ∈ [0, 5.5]<br />

y(0) = 5<br />

cuja (única) solução é<br />

y(t) = 3270<br />

2<br />

629<br />

e− 5 t + 10<br />

125<br />

629 sin (5t) − 629 cos (5t)<br />

O método <strong>de</strong> Euler progressivo associado a este problema escreve-se<br />

⇐⇒<br />

ui+1−ui<br />

h<br />

2 = − 5ui + sin (5ti) i = 0, 1, · · · , n − 1<br />

u0 = 5<br />

<br />

ui+1 = 1 − 2<br />

5h ui + h sin(5ih) i = 0, 1, · · · , n − 1<br />

u0 = 5<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Para h = 1.1, tem-se<br />

ui+1 = 0.56 ui + 1.1 × sin(5.5i) i = 0, 1, · · · , 4<br />

u0 = 5<br />

Do mesmo modo, para h = 0.55, obtem-se<br />

ui+1 = 0.824 ui + 0.55 × sin (2.75i) i = 0, 1, · · · , 9<br />

u0 = 5<br />

Os resultados correspon<strong>de</strong>ntes são resumidos na Figura 1. O método<br />

parece convergir (lentamente), os resultados sendo melhores quando o<br />

passo <strong>de</strong>cresce.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

−1<br />

Solução exacta<br />

Euler progressivo h = 1.1<br />

Euler progressivo h = 0.55<br />

1 2 3 4 5<br />

Figura 1: Comparação das soluções obtidas pelo método <strong>de</strong> Euler para h = 1.1 e h = 0.55<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Convergência <strong>de</strong> Euler progressivo<br />

Teorema. Se y ∈ C 2 [a, b] e f é uma função <strong>de</strong> Lipschitz <strong>de</strong> constante<br />

L, então<br />

|y(ti) − ui| ≤ C(ti) h<br />

on<strong>de</strong><br />

C(ti) = eLt i−1<br />

2L max<br />

t∈[a,b] |y”(t)|<br />

Em particular, o método é convergente <strong>de</strong> or<strong>de</strong>m 1.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Demonstração. Seja ei = ui − y(ti) o erro no nó i. Então<br />

ei+1 − ei = (ui+1 − y(ti+1)) − (ui − y(ti))<br />

= (ui+1 − ui) − (y(ti+1) − y(ti))<br />

<br />

= hf(ti, ui) − hy ′ (ti) + h2<br />

2 y”(ηi)<br />

<br />

<br />

= hf(ti, ui) − hf (ti, y(ti)) + h2<br />

2 y”(ηi)<br />

<br />

= h(f(ti, ui) − f (ti, y(ti))) − h2<br />

2 y”(ηi)<br />

Uma vez que f é uma função <strong>de</strong> Lipschitz <strong>de</strong> constante L, tem-se<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

|f(ti, ui) − f (ti, y(ti))| ≤ L |ui − y(ti)| = L |ei|


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Portanto<br />

|ei+1 − ei| =<br />

<br />

<br />

h(f(ti, ui) − f (ti, y(ti))) − h2<br />

2 y”(ηi)<br />

≤ h |f(ti, ui) − f (ti, y(ti))| + h2<br />

2 |y”(ηi)|<br />

≤ h |f(ti, ui) − f (ti, y(ti))| + hτ(h)<br />

≤ hL |ei| + hτ(h)<br />

on<strong>de</strong> τ(h) = h<br />

2 maxi |y”(ηi)|. A combinação <strong>de</strong>stas <strong>de</strong>sigualda<strong>de</strong>s<br />

implica<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

|ei+1| ≤ |ei+1 − ei| + |ei| ≤ (1 + Lh) |ei| + hτ(h)


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Seja Ei = |ei|. Tem-se<br />

Ei+1 ≤ (1 + Lh) Ei + hτ(h)<br />

≤ (1 + Lh)((1 + Lh) Ei−1 + hτ(h)) + hτ(h)<br />

= (1 + Lh) 2 Ei−1 + (1 + (1 + Lh)) hτ(h)<br />

≤ (1 + Lh) 2 ((1 + Lh) Ei−2 + hτ(h)) + (1 + (1 + Lh)) hτ(h)<br />

= (1 + Lh) 3 <br />

Ei−2 + 1 + (1 + Lh) + (1 + Lh) 2<br />

hτ(h)<br />

<br />

≤ 1 + (1 + Lh) + (1 + Lh) 2 + · · · + (1 + Lh) i<br />

hτ(h)<br />

= (1+hL)i+1 −1<br />

hL<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

hτ(h) = (1+hL)i+1 −1<br />

L<br />

τ(h)


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Mas<br />

implicando que<br />

Assim<br />

e portanto<br />

1 + hL ≤ e hL<br />

∀ h > 0,<br />

(1 + hL) i ≤ e ihL − 1 = e Lti − 1.<br />

Ei ≤ eLti−1 L τ(h) ≤ eLti−1 h<br />

L 2 max<br />

t∈[a,b] |y”(t)|<br />

|ui − y(ti)| ≤<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

<br />

e Lt i−1<br />

2L<br />

max<br />

t∈[a,b] |y”(t)|<br />

<br />

h


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Exemplo 2. Consi<strong>de</strong>re o seguinte problema <strong>de</strong> Cauchy<br />

cuja (única) solução é<br />

<br />

′ 1 y (t) = 2 (t − y(t)) t ∈ [0, 3]<br />

y(0) = 1<br />

t<br />

−<br />

y(t) = 3e 2 + t − 2.<br />

O método <strong>de</strong> Euler progressivo associado a este problema escreve-se<br />

⇐⇒<br />

ui+1−ui<br />

h<br />

u0 = 1<br />

1 = 2 (ti − ui) i = 0, 1, · · · , n − 1<br />

<br />

ui+1 = 1 − h<br />

<br />

2<br />

ui + h2<br />

2 i i = 0, 1, · · · , n − 1<br />

u0 = 1<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Para h = 1, tem-se<br />

ui+1 = 1<br />

2 (ui + i) i = 0, 1, · · · , 3<br />

u0 = 1<br />

Do mesmo modo, para h = 0.5<br />

ui+1 = 0.75 ui + 0.125i i = 0, 1, · · · , 5<br />

u0 = 1<br />

e para h = 0.25, obtem-se<br />

ui+1 = 0.875 ui + 0.03125 i i = 0, 1, · · · , 11<br />

u0 = 1<br />

Os resultados correspon<strong>de</strong>ntes são resumidos na Figura 2. O método<br />

converge e, como é previsível, os resultados melhoram quando h<br />

<strong>de</strong>cresce.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

1<br />

0<br />

Solução exacta<br />

Euler progressivo h = 1<br />

Euler progressivo h = 0.5<br />

Euler progressivo h = 0.25<br />

0 0.5 1.0 1.5 2.0 2.5<br />

Figura 2: Comparação das soluções obtidas pelo método <strong>de</strong> Euler progressivo<br />

para diferentes valores <strong>de</strong> h<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Condições <strong>de</strong> estabilida<strong>de</strong><br />

A escolha do passo <strong>de</strong> tempo não é arbitrária. Para o método <strong>de</strong> Euler<br />

progressivo, problemas <strong>de</strong> instabilida<strong>de</strong> po<strong>de</strong>m acontecer.<br />

Por exemplo, consi<strong>de</strong>re o problema<br />

y ′ (t) = −2y t > 0<br />

y(0) = 1<br />

cuja solução exacta é y(t) = e −2t .<br />

Como po<strong>de</strong>mos ver nas figuras 3, 4, 5 e 6, os métodos <strong>de</strong> Euler<br />

progressivo e regressivo têm comportamentos diferentes em relação a<br />

h. O primeiro método converge para h = 0.9 e diverge para h = 1.1,<br />

quando o segundo converge para ambos os valores.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

3<br />

2<br />

1<br />

0<br />

−1<br />

−2<br />

−3<br />

Solução exacta<br />

Euler progressivo : h = 0.9<br />

Euler progressivo : h = 1.1<br />

1 2 3 4 5 6 7 8 9 10<br />

Figura 3: Convergência condicional do método <strong>de</strong> Euler progressivo<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

Euler progressivo : h = 0.9<br />

Euler progressivo : h = 1.1<br />

1 2 3 4 5 6 7 8 9 10<br />

Figura 4: Erro correspon<strong>de</strong>nte ao método <strong>de</strong> Euler progressivo<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

1<br />

0<br />

Solução exacta<br />

Euler regressivo : h = 0.9<br />

Euler regressivo : h = 1.1<br />

1 2 3 4 5 6 7 8 9 10<br />

Figura 5: Convergência do método <strong>de</strong> Euler regressivo<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

0.5<br />

0<br />

−0.5<br />

Euler regressivo : h = 0.9<br />

Euler regressivo : h = 1.1<br />

1 2 3 4 5 6 7 8 9 10<br />

Figura 6: Erro correspon<strong>de</strong>nte ao método <strong>de</strong> Euler progressivo<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Para perceber o que acontece, consi<strong>de</strong>re o problema mais geral<br />

y ′ (t) = λy, t > 0<br />

y(0) = yo<br />

on<strong>de</strong> λ < 0. A solução exacta é y(t) = yoe λt e satisfaz<br />

lim y(t) = 0.<br />

t→+∞<br />

Portanto uma solução aproximada tem necessariamente <strong>de</strong> satisfazer<br />

lim<br />

i→+∞ ui = 0<br />

Um esquema que satisfaz esta condição diz-se absolutamente estável<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Aplicando Euler progressivo, vem que ui+1 = (1 + λh) ui e, por<br />

recorrência, obtem-se<br />

ui+1 = (1 + λh) i u0 = (1 + λh) i yo.<br />

Portanto o esquema <strong>de</strong> Euler progressivo é absolutamente estável se, e<br />

só se, a seguinte condição <strong>de</strong> estabilida<strong>de</strong> é satisfeita<br />

|1 + λ h| < 1 ⇐⇒ 0 < h < 2<br />

|λ|<br />

No caso do exemplo prece<strong>de</strong>nte, esta condição não está satisfeita no<br />

caso <strong>de</strong> h = 1.1, o que explica que o método nao converge.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Aplicando Euler regressivo, vem que ui+1 =<br />

recorrência, obtem-se<br />

ui+1 =<br />

Uma vez que λ < 0, vem que<br />

i i 1<br />

1<br />

1−λh<br />

u0 1−λh yo.<br />

0 < 1<br />

1−λh < 1<br />

<br />

1<br />

1−λh<br />

ui e, por<br />

e portanto o esquema <strong>de</strong> Euler regressivo é absolutamente estável.<br />

Isto explica os resultados apresentados nas Figuras 5 e 6.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Métodos <strong>de</strong> Runge-Kutta <strong>de</strong> or<strong>de</strong>m 2<br />

Se integrarmos a equação a equação y ′ (t) = f (t, y(t)), entre ti e ti+1,<br />

obtemos<br />

y(ti+1) − y(ti) =<br />

ti+1<br />

ti<br />

f(t, y(t)) dt<br />

Portanto, em vez <strong>de</strong> utilizar a <strong>de</strong>rivação numérica, po<strong>de</strong>mos construir<br />

esquemas <strong>de</strong> aproximação utilizando métodos <strong>de</strong> integração.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Utilizando a regra do trapézio, obtemos o seguinte esquema implícito,<br />

chamado esquema <strong>de</strong> Crank-Nicolson:<br />

ui+1 = ui + h<br />

2 (f (ti, ui) + f (ti+1, ui+1))<br />

Modificando este esquema para o tornar explícito, obtemos o esquema<br />

<strong>de</strong> Heun:<br />

ui+1 = ui + h<br />

2 (f (ti, ui) + f (ti+1, ui + hf (ti, ui)))<br />

Os dois métodos são <strong>de</strong> or<strong>de</strong>m 2 em relação a h.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Utilizando a regra do ponto médio, obtemos o seguinte esquema<br />

<br />

ui+1 = ui + hf t 1<br />

i+ , u 1<br />

i+ ,<br />

2 2<br />

t 1<br />

i+ 2<br />

= ti + h<br />

2<br />

Modificando este esquema para o tornar explícito, aproximamos u 1<br />

i+<br />

2<br />

por ui + h<br />

2f (tn, ui) e obtemos o esquema <strong>de</strong> Euler modificado:<br />

ui+1 = ui + hf ti + h<br />

2 , ui + h<br />

2f (tn, ui) <br />

Os métodos <strong>de</strong> Heun e <strong>de</strong> Euler modificado pertencem a família dos<br />

métodos <strong>de</strong> Runge-Kutta <strong>de</strong> or<strong>de</strong>m 2.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Exemplo 3. Consi<strong>de</strong>re o problema <strong>de</strong> Cauchy do Exemplo 1. O<br />

método <strong>de</strong> Euler modificado associado a este problema escreve-se<br />

ui+1−ui<br />

h<br />

u0 = 5<br />

Uma vez que<br />

= f ti + h<br />

2 , ui + h<br />

2 f (ti, ui) <br />

f ti + h<br />

2 , ui + h<br />

= − 2<br />

5<br />

= − 2<br />

5<br />

= − 2<br />

5<br />

2 f (ti, ui) <br />

<br />

ui + h<br />

2 f (ti, ui) + sin 5ti + 5h<br />

2<br />

ui + h<br />

2<br />

1 − h<br />

5<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

i = 0, 1, · · · , n − 1<br />

<br />

2 − 5ui + sin(5ti) + sin 5ti + 5h<br />

2<br />

<br />

ui − h<br />

5 sin (5ti) + sin 5ti + 5h<br />

<br />

2


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

conclui-se que<br />

<br />

ui+1 = 1 − 2h<br />

5<br />

u0 = 5<br />

para i = 0, 1, · · · , n − 1.<br />

<br />

2h2 + 25<br />

ui − h2<br />

5 sin(5ih) + h sin5ih + 5h<br />

<br />

2<br />

Por conseguinte para h = 1.1, vem que<br />

ui+1 = 0.6568 ui − 0.242 × sin (5.5i) + 1.1 × sin(5.5i + 2.75)<br />

u0 = 5<br />

para i = 0, 1, · · · , 4.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Do mesmo modo, para h = 0.55, tem-se<br />

ui+1 = 0.8042 ui − 0.01331 × sin(2.75i) + 0.55 × sin (2.75i + 1.375)<br />

u0 = 5<br />

para i = 0, 1, · · · , 9.<br />

Os resultados correspon<strong>de</strong>ntes são resumidos na Figura 7 a seguir. A<br />

convergência melhora quando o passo <strong>de</strong>cresce, e é mais rápida que<br />

no caso <strong>de</strong> Euler progressivo.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

Solução exacta<br />

Euler modificado h = 1.1<br />

Euler modificado h = 0.55<br />

0 1 2 3 4 5<br />

Figura 7: Comparação das soluções obtidas pelo método <strong>de</strong> Euler modificado<br />

para h = 1.1 e h = 0.55<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Exemplo 4. Consi<strong>de</strong>re o problema <strong>de</strong> Cauchy do Exemplo 1. O<br />

método <strong>de</strong> Heun associado a este problema escreve-se<br />

ui+1−ui<br />

h<br />

u0 = 5<br />

Uma vez que<br />

f(ti,ui)+f(ti+1,ui+hf(ti,ui))<br />

= 2<br />

f (ti+1, ui + h f (ti, ui))<br />

= − 2<br />

5 (ui + h f (ti, ui)) + sin (5ti+1)<br />

= − 2<br />

5<br />

= − 2<br />

5<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

i = 0, 1, · · · , n − 1<br />

ui + h − 2<br />

5 ui + sin (5ti) + sin (5ti+1)<br />

<br />

2h 1 − 5<br />

ui − 2h<br />

5 sin (5ti) + sin (5ti+1)


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

conclui-se que<br />

<br />

ui+1 = 1 − 2h<br />

<br />

2h2<br />

h h2<br />

5 + 25<br />

ui + 2 − 5 sin (5ih) + h<br />

2 sin(5ih + 5)<br />

u0 = 5<br />

para i = 0, 1, · · · , n − 1.<br />

Para h = 1.1, tem-se<br />

ui+1 = 0.6568 ui + 0.308 × sin (5.5i) + 0.55 × sin (5.5i + 5)<br />

u0 = 5<br />

para i = 0, 1, · · · , 4.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Do mesmo modo, para h = 0.55, tem-se<br />

ui+1 = 0.8042 ui + 0.2145 × sin(2.75i) + 0.275 × sin(2.75i + 2.75)<br />

u0 = 5<br />

para i = 0, 1, · · · , 9.<br />

Os resultados correspon<strong>de</strong>ntes são resumidos na Figura 8 a seguir. A<br />

convergência melhora quando o passo <strong>de</strong>cresce, é mais rápida que no<br />

caso <strong>de</strong> Euler progressivo e é comparável a convergência do método<br />

<strong>de</strong> Euler modificado.<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

−1<br />

Solução exacta<br />

Heun h = 1.1<br />

Heun h = 0.55<br />

1 2 3 4 5<br />

Figura 8: Comparação das soluções obtidas pelo método <strong>de</strong> Heun para h =<br />

1.1 e h = 0.55<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Método <strong>de</strong> Runge-Kutta <strong>de</strong> or<strong>de</strong>m 4<br />

Existem outros métodos, mais complexos, como por exemplo o<br />

método <strong>de</strong> Runge-Kutta <strong>de</strong> or<strong>de</strong>m 4 obtido consi<strong>de</strong>rando o regra <strong>de</strong><br />

integração <strong>de</strong> Simpson:<br />

ui+1 = ui + h<br />

<br />

1<br />

6 Ki + 2K 2 i + 2K3i + K4 <br />

i<br />

on<strong>de</strong> ⎧⎪ ⎨<br />

⎪⎩<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

K 1 i = f (ti, ui)<br />

K 2 i = f ti + h<br />

2 , ui + h<br />

2 K1 i<br />

K3 i = f ti + h<br />

2 , ui + h<br />

K4 i = f ti+1, ui + hK3 <br />

i<br />

2 K2 i


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Exemplo 5. Consi<strong>de</strong>re o problema <strong>de</strong> Cauchy do Exemplo 1. O<br />

método <strong>de</strong> Runge-Kutta <strong>de</strong> or<strong>de</strong>m 4 associado a este problema<br />

escreve-se<br />

u0 = 1<br />

on<strong>de</strong><br />

ui+1−ui<br />

h<br />

K 1 i<br />

K 2 i<br />

<br />

1 1 = 6 Ki + 2K2 i + 2K3 i + K4 <br />

i<br />

= f (ti, ui) = − 2<br />

5 ui + sin(5ti)<br />

= f ti + h<br />

2 , ui + h<br />

2K1 <br />

i<br />

= − 2<br />

5<br />

= − 2<br />

5<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

ui + h<br />

2 K1 i<br />

1 − h<br />

5<br />

+ sin 5ti + h<br />

2<br />

i = 0, 1 · · · , n − 1<br />

<br />

ui − h<br />

5 sin (5ti) + sin 5ti + h<br />

2


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

K 3 i<br />

K 4 i<br />

<br />

2 = − 5<br />

ui + h<br />

2K2i <br />

+ sin 5ti + h<br />

<br />

2<br />

= f ti + h<br />

2 , ui + h<br />

2K2i = − 2<br />

<br />

5 1 − h<br />

<br />

h2<br />

5 + 25<br />

ui + <br />

h 2<br />

5 sin (5ti) + 5−h<br />

5 sin 5ti + h<br />

<br />

2<br />

= f ti+1, ui + hK3 <br />

2<br />

i = −<br />

= − 2<br />

<br />

+<br />

5<br />

<br />

− 2h<br />

5<br />

1 − h<br />

5<br />

2h2 + 25<br />

+ 2h2<br />

25<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias<br />

<br />

− 2h3<br />

125<br />

5<br />

<br />

ui + hK3 <br />

i + sin (5ti+1)<br />

<br />

ui − 2h3<br />

125 sin (5ti)<br />

sin 5ti + h<br />

<br />

2 + sin (5ti+1)


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

Portanto, para qualquer i = 0, 1 · · · , n − 1, tem-se<br />

ui+1 = ui + h<br />

<br />

6 K1 i + 2K2 i + 2K3i + K4 <br />

i<br />

<br />

= 1 + 2h<br />

<br />

2h2 4h3 h4<br />

5 + 25 − 475 + 1875<br />

ui<br />

<br />

+ 1 − 2h<br />

<br />

2h2 2h2<br />

5 + 25 − 125 sin (5ti)<br />

+ 3 − h<br />

<br />

5 sin 5ti + h<br />

<br />

2 + sin (5ti+1)<br />

Os resultados correspon<strong>de</strong>ntes a h = 1.1 e h = 0.55 são resumidos na<br />

Figura 9 a seguir. A convergência melhora quando o passo <strong>de</strong>cresce, e<br />

é mais rápida que no caso dos métodos anteriormente consi<strong>de</strong>rados.<br />

(C.f. Figura 10 e Figura 11 a seguir.)<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

Solução exacte<br />

Runge-Kutta 4 h = 1.1<br />

Runge-Kutta 4 h = 0.55<br />

0 1 2 3 4 5<br />

Figura 9: Comparação das soluções obtidas pelo método <strong>de</strong> Runge-Kutta <strong>de</strong><br />

or<strong>de</strong>m 4 para h = 1.1 e h = 0.55<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

−1<br />

1 2 3 4 5<br />

Solução exacte<br />

Runge-Kutta 4<br />

Heun<br />

Euler modificado<br />

Euler progressivo<br />

Figura 10: Comparação das soluções obtidas pelos diferentes métodos para h = 1.1<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias


Problema <strong>de</strong> Cauchy Derivada numérica Aproximação Euler Estabilda<strong>de</strong> Runge-Kutta 2 Runge-Kutta 4<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

Solução exacte<br />

Runge-Kutta 4<br />

Heun<br />

Euler modificado<br />

Euler progressivo<br />

0 1 2 3 4 5<br />

Figura 11: Comparação das soluções obtidas pelos diferentes métodos para h = 0.55<br />

<strong>Cálculo</strong> <strong>Numérico</strong> - Équações diferenciais ordinárias

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!