Professional Documents
Culture Documents
2 de abril de 2012
Métodos Numéricos para EDOs
Outline
1 Introdução
3 Métodos de Runge-Kutta
6 Estabilidade
8 Sumário
Métodos Numéricos para EDOs
Introdução
Existência de Solução
Teorema
Suponha que f satisfaz a condição de Lipschitz
√
ẋ = x, x(0) = 0
√
x não é Lipschitz em x = 0.
t2
Solução não é única: x = 4 ou x = 0.
Métodos Numéricos para EDOs
Introdução
ẋ = x 2 , x(0) = 1
Método de Euler
como Z t
x(t) = x0 + f (s, x(s)) ds, t ≥ t0
t0
Métodos Numéricos para EDOs
Métodos de Euler e do Trapézio
Método de Euler
Métodos de Integração: Retangular de avanço
Aproximamos a integral pela área do retângulo:
Regra retangular de avanço
3
2.5
2
f (t)
1.5
1 h
←T→
0.5
0
0 1 2 3 x(h)
u(kT − T ) 5 6 7 t
– p. 7/40
Z t Z t+h
x(t+h) = x0 + f (s, x(s))ds+ f (s, x(s))ds ≈ x(t)+hf (t, x(t))
t0 t
Métodos Numéricos para EDOs
Métodos de Euler e do Trapézio
Método de Euler
xk+1 = xk + hf (tk , xk )
Métodos Numéricos para EDOs
Métodos de Euler e do Trapézio
Método do Trapézio
AproximamosMétodos de Integração: Retangular trapezoidal
a integral pela área do trapézio:
Regra retangular trapezoidal
3
2.5
2
f (t)
1.5
1 h
←T→
0.5
0
0 1 2 3 x(h)
u(kT − T ) 5 6 7 t
– p. 20/40
Z t+h
h
f (s, x(s))ds ≈ [f (t, x(t)) + f (t + h, x(t + h))]
t 2
Métodos Numéricos para EDOs
Métodos de Euler e do Trapézio
Método do Trapézio
h
xk+1 = xk + [f (tk , xk ) + f (tk+1 , xk+1 )]
2
Note que xk+1 aparece em ambos os lados da equação. Por isso,
precisamos resolver a equação não-linear implı́cita para obter xk+1
(o que exige calcular f em diversos pontos).
O método de Euler é um exemplo de método explı́cito.
O método do trapézio é um exemplo de método implı́cito.
Métodos Numéricos para EDOs
Métodos de Runge-Kutta
Métodos de Runge-Kutta
Método clássico:
h
xk+1 = xk + (k1 + 2k2 + 2k3 + k4 )
6
k1 = f (tk , xk )
k2 = f (tk + h/2, xk + hk1 /2)
k3 = f (tk + h/2, xk + hk2 /2)
k4 = f (tk + h, xk + hk3 )
Métodos Numéricos para EDOs
Métodos de Runge-Kutta
Erro de truncamento
xk+1 = xk + hΦ(tk , xk ; h)
Erro de truncamento
x(tk+1 ) − x(tk )
Tk = − Φ(tk , xk ; h)
h
Usando a série de Taylor:
h2 00
x(tk+1 ) = x(tk ) + hx 0 (tk ) + x (tk ) + . . .
2
obtemos
h
Tk = x 0 (tk ) + x 00 (tk ) + . . . − Φ(tk , xk ; h)
2
Métodos Numéricos para EDOs
Métodos de Runge-Kutta
Erro de truncamento
h
Tk = x 0 (tk ) + x 00 (tk ) + . . . − Φ(tk , xk ; h)
2
Para o método de Euler, como Φ = x 0 , temos que
h 00 h2
Tk = x (tk ) + x 000 (tk ) . . . = O(h)
2 6
Métodos Numéricos para EDOs
Métodos de Runge-Kutta
Erro Global
Métodos de Runge-Kutta
Métodos de Runge-Kutta
Assim, obtemos
1/p+1
TOL
hOPT = h
errok
Métodos Numéricos para EDOs
Métodos de Passo Variável
xk+1 = xk + hf (tk , xk ).
Métodos Numéricos para EDOs
Representação em Espaço de Estados
ẋ1 = x2
g
ẋ2 = − senx1
l
Métodos Numéricos para EDOs
Representação em Espaço de Estados
ẋ1 = x2
g
ẋ2 = − senx1
l
Definindo
x1 x2
x= e f (x) = g ,
x2 − l senx1
obtemos a EDO de primeira ordem
ẋ = f (x)
Métodos Numéricos para EDOs
Representação em Espaço de Estados
ẋ = f (x)
x1 x2
x= e f (x) =
x2 − gl senx1
ẋ = f (x)
x1 x2
x= e f (x) =
x2 − gl senx1
Exercı́cio
F = mẍ = −c ẋ − kx
Métodos Numéricos para EDOs
Representação em Espaço de Estados
Exercı́cio
x1 = x, x2 = ẋ
d x1 x2
=
dt x2 −kx1 /m − cx2 /m
F = mẍ = −c ẋ − kx
Métodos Numéricos para EDOs
Representação em Espaço de Estados
Exercı́cio
Exercı́cio
V = RI + Lİ + VC
I = C V̇C
Métodos Numéricos para EDOs
Representação em Espaço de Estados
Exercı́cio
V = RI + Lİ + VC
I = C V̇C
d VC I /C
=
dt I (V − VC − RI )/L
Métodos Numéricos para EDOs
Representação em Espaço de Estados
Exercı́cio
V = RI + Lİ + VC
I = C V̇C
d VC 0 1/C VC 0
= +
dt I −1/L −R/L I V /L
Métodos Numéricos para EDOs
Estabilidade
Estabilidade
ẋ = λx, λ ∈ C.
x(t) = x0 e λt
Estabilidade
ẋ = λx, λ ∈ C.
Usando o método de Euler, obtemos a seguinte iteração
o que leva a
xk = (1 + λh)k x0 .
Temos que xk → 0 quando k → ∞ se |1 + λh| < 1.
Métodos Numéricos para EDOs
Estabilidade
Estabilidade
Estabilidade
{λ : |1 + λh| < 1}
= xn=+|1hλx
R̂(µ)
xn+1 µ|−1 .
− n+1
Regiões de Estabilidade
which means the stability region is the R̂(µ)
exterior ofµ|the. disk of radius 1 centred at 1 i
= |1 − −1
plane. These are some simple examples. All three of these are graphed in Figure 1
which means the stability region is the exterior of the disk of radius 1 centred at 1 in the com
plane. These are some simple examples. All three of these are graphed in Figure 10.3.
a)a) b) b) c) c
(a) Região de estabili- (b) Região de estabili-
dade
Figure para10.3:
Figure
10.3: método
Stabilityde Eu- dade
Stability Regions:
Regions: para method,
(a) Euler’s
(a) Euler’s método do trapezoidal
(b) trapezoidal
method, (b)
rule, (c) implicit Eul
rule, (c) imp
ler trapézio
For the fourth-order Runge-Kutta method (8.4), the stability function is found to be:
For the fourth-order Runge-Kutta method (8.4), the stability function is found
1 1 1
Para |λ| grande, temos que fazer µ + µ2 +pequeno
R(µ) = 1h+ muito µ3 + µ4 .para
2 1 26 1 24 1
R(µ) = 1 + µ + µ + µ3 + µ4 .
manter Note
a estabilidade
that as we woulddo método
expect, de Euler.
R(hλ) agrees with 2the Taylor
6 Series24expansion of exp(hλ) thr
fourth order; the latter gives the exact flow map for dx/dt = λx. To graph R we could us
PorNote
outro
thatlado,
as we
following
owould
trick.
método
expect,
For each
dooftrapézio
value R(hλ) agrees
µ, R is
éwith
sempre
a complex
estável.
the Taylor
number. Series expansion
The boundary of exr
of the stability
fourthis order; thealllatter
the set of µ such gives the isexact
that R(µ) on theflow
unitmap
circle.for dx/dt
That = λx. To graph R we
means
following trick. For each value of µ, R is a complex iθ
number. The boundary of the s
R(µ) = e ,
is the set of all µ such that R(µ) is on the unit circle. That means
Another popular method: Implicit|1Euler,
Métodos Numéricos para EDOs + µ/2| ≤ |1 − µ/2|,
Estabilidade or, when µ/2 is closer to −1 than to 1,xwhich=
is x
just+the entire left complex half-plane.
hλx
n+1 n n+1
Another popular method: Implicit Euler,
= xn=+|1hλx
R̂(µ)
xn+1 µ|−1 .
− n+1
Regiões de Estabilidade
which means the stability region is the R̂(µ)
exterior ofµ|the. disk of radius 1 centred at 1 i
= |1 − −1
plane. These are some simple examples. All three of these are graphed in Figure 1
which means the stability region is the exterior of the disk of radius 1 centred at 1 in the com
plane. These are some simple examples. All three of these are graphed in Figure 10.3.
a)a) b) b) c) c
(c) Região de estabili- (d) Região de estabili-
dade
Figure para10.3:
Figure
10.3: método
Stabilityde Eu- dade
Stability Regions:
Regions: para method,
(a) Euler’s
(a) Euler’s método do trapezoidal
(b) trapezoidal
method, (b)
rule, (c) implicit Eul
rule, (c) imp
ler trapézio
For the fourth-order Runge-Kutta method (8.4), the stability function is found to be:
For the fourth-order Runge-Kutta method (8.4), the stability function is found
1 1 1
Para |λ| grande, temos que fazer µ + µ2 +pequeno
R(µ) = 1h+ muito µ3 + µ4 .para
2 1 26 1 24 1
R(µ) = 1 + µ + µ + µ3 + µ4 .
manter Note
a estabilidade
that as we woulddo método
expect, de Euler.
R(hλ) agrees with 2the Taylor
6 Series24expansion of exp(hλ) thr
fourth order; the latter gives the exact flow map for dx/dt = λx. To graph R we could us
PorNote
outro
thatlado,
as we
following
owould
trick.
método
expect,
For each
dooftrapézio
value R(hλ) agrees
µ, R is
éwith
sempre
a complex
estável.
the Taylor
number. Series expansion
The boundary of exr
of the stability
fourthis order; thealllatter
the set of µ such gives the isexact
that R(µ) on theflow
unitmap
circle.for dx/dt
That = λx. To graph R we
means
Em geral, métodos implı́citos apresentam
following trick. For each value of µ, R is a complex
região de estabilidade
number. The boundary of the s
iθ
muito maior R(µ) = e ,
is the que
set ofmétodos explı́citos.
all µ such that R(µ) is on the unit circle. That means
Métodos Numéricos para Another
EDOs popular method: Implicit|1Euler,
+ µ/2| ≤ |1 − µ/2|,
Estabilidade
or, when µ/2 is closer to −1 than to 1,xwhich=
is x
just+the entire left complex half-plane.
hλx
n+1 n n+1
Another popular method: Implicit Euler,
x = x + hλx µ|−1 .
R̂(µ) n= |1 − n+1
Regiões de Estabilidade n+1
which means the stability region is the exterior of the disk of radius 1 centred at 1 i
R̂(µ) = |1 − µ|−1 .
plane. These are some simple examples. All three of these are graphed in Figure 1
which means the stability region is the exterior of the disk of radius 1 centred at 1 in the com
plane. These are some simple examples. All three of these are graphed in Figure 10.3.
a)a) b) b) c) c
(e) Região de estabili- (f) Região de estabili-
dade
Figure para10.3:
Figure
10.3: método
Stabilityde Eu- dade
Stability Regions:
Regions: para method,
(a) Euler’s
(a) Euler’s método do trapezoidal
(b) trapezoidal
method, (b)
rule, (c) implicit Eul
rule, (c) imp
ler trapézio
For the fourth-order Runge-Kutta method (8.4), the stability function is found to be:
For the fourth-order Runge-Kutta method (8.4), the stability function is found
1 1 1
R(µ) = 1 + µ + µ2 + µ3 + µ4 .
Se tivermos um processador muito rápido, 2 1 26o problema
1 24 1
R(µ) = 1 + µ +qualµ + µ3 + µ4de . fazer
h muito Note that as eweassim
pequeno would expect,
tornarR(hλ) de2theEuler
agrees with
o método 6 estável?
Taylor Series24
expansion of exp(hλ) thr
fourth order; the latter gives the exact flow map for dx/dt = λx. To graph R we could us
Note following
that as we would
trick. expect,
For each value R(hλ) agrees
of µ, R is withnumber.
a complex the Taylor Series expansion
The boundary of exr
of the stability
fourthis order; thealllatter
the set of µ such gives the isexact
that R(µ) on theflow
unitmap
circle.for dx/dt
That = λx. To graph R we
means
following trick. For each value of µ, R is a complex number. The boundary of the s
R(µ) = eiθ ,
is the set of all µ such that R(µ) is on the unit circle. That means
Métodos Numéricos para Another
EDOs popular method: Implicit|1Euler,
+ µ/2| ≤ |1 − µ/2|,
Estabilidade
or, when µ/2 is closer to −1 than to 1,xwhich=
is x
just+the entire left complex half-plane.
hλx
n+1 n n+1
Another popular method: Implicit Euler,
x = x + hλx µ|−1 .
R̂(µ) n= |1 − n+1
Regiões de Estabilidade n+1
which means the stability region is the exterior of the disk of radius 1 centred at 1 i
R̂(µ) = |1 − µ|−1 .
plane. These are some simple examples. All three of these are graphed in Figure 1
which means the stability region is the exterior of the disk of radius 1 centred at 1 in the com
plane. These are some simple examples. All three of these are graphed in Figure 10.3.
a)a) b) b) c) c
(g) Região de estabili- (h) Região de estabili-
dade
Figure para10.3:
Figure
10.3: método
Stabilityde Eu- dade
Stability Regions:
Regions: para method,
(a) Euler’s
(a) Euler’s método do trapezoidal
(b) trapezoidal
method, (b)
rule, (c) implicit Eul
rule, (c) imp
ler trapézio
For the fourth-order Runge-Kutta method (8.4), the stability function is found to be:
For the fourth-order Runge-Kutta method (8.4), the stability function is found
1 1 1
R(µ) = 1 + µ + µ2 + µ3 + µ4 .
Se tivermos um processador muito rápido, 2 1 26o problema
1 24 1
R(µ) = 1 + µ +qualµ + µ3 + µ4de . fazer
h muito Note that as eweassim
pequeno would expect,
tornarR(hλ) de2theEuler
agrees with
o método 6 estável?
Taylor Series24
expansion of exp(hλ) thr
fourth order; the latter gives the exact flow map for dx/dt = λx. To graph R we could us
Note following
that as we would
trick. expect,
For each R(hλ) agrees withnumber.
the Taylor Series expansion of exr
maiores erros (relativos) devalue of µ, R is
arredondamento;a complex The boundary of the stability
fourthis order; thealllatter
the set of µ such gives the isexact
that R(µ) on theflow
unitmap
circle.for dx/dt
That = λx. To graph R we
means
maisfollowing
erros detrick. For each value of
arredondamento µ, acumulados.
são R is a complex
R(µ) = eiθ ,
number. The boundary of the s
is the set of all µ such that R(µ) is on the unit circle. That means
>atRhat
= abs(R);
Métodos=Numéricos
abs(R); para EDOs
>ntourplot(X,Y,Rhat,[1]);
Estabilidade
contourplot(X,Y,Rhat,[1]);
gure 10.410.4
Figure shows stability
shows regions
stability for for
regions some Runge-Kutta
some Runge-Kuttamethods upup
methods to to
order 4. 4.
order The shadin
The sha
figure indicates
Regiões
n the the
de the
figure indicates magnitude
Estabilidade |R(z)| within the stability region.
magnitude |R(z)| within the stability region.
ERK,ERK,
s=p=1
s=p=1 ERK, s=p=2
ERK, s=p=2
3 3 3 3
2 2 2 2
1 1 1 1
0 0 0 0
−1 −1 −1 −1
−2 −2 −2 −2
−3 −3 −3 −3
−3 −3 −2 −2 −1 −1 0 0 −3 −3 −2 −2 −1 −1 0 0
Regiões de Estabilidade
ERK, ERK,
s=p=3s=p=3 ERK, s=p=4
ERK, s=p=4
3 3 3 3
2 2 2 2
1 1 1 1
0 0 0 0
−1 −1 −1 −1
−2 −2
−2 −2
−3 −3
−3 −3
−3 −2 −1 0 −3 −2 −1 0
−3 −2 −1 0 −3 −2 −1 0
Figure
(k)Figure
Região de 10.4: Explicitpara
estabilidade Runge-Kutta
(l) RegiãoStability Regions
de estabilidade
10.4: Explicit Runge-Kutta Stability Regions para
Runge-Kutta de ordem 3 Runge-Kutta de ordem 4
What is the meaning of these funny diagrams? They tell us a huge amount. Consider fir
hat is the meaning of these funny diagrams? They tell us a huge amount. Consider firs
Métodos Numéricos para EDOs
EDOs do Tipo Stiff
Sumário
Método Classificação Acurácia Uso
ode45 explı́cito média primeiro método a se
tentar
ode23 explı́cito baixa maiores tolerâncias
ou problemas mode-
radamente stiff
ode15s implı́cito baixa a média se ode45 é lento de-
vido a stiffness
ode23s implı́cito baixa problemas stiff com
altas tolerâncias.
mais estável que
ode15s
ode113 explı́cito alta baixas tolerâncias
(múltiplos ou problemas com-
passos) putacionalmente
intensos