Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Integração Numérica
Objetivos
f ( x)dx
A integral de uma função f(x)
no intervalo [a,b]
a
Motivação
• Por que integrar com métodos Numéricos?
– Algumas integrais são difíceis, ou mesmo impossíveis de se
resolver analiticamente.
𝑡
𝑥
Por exemplo, qual a primitiva de 𝑑𝑥 ?
0 (𝑡 3 2 −𝑥 3 2 )2 3
b P (x)dx
a 0
(Regra do Retângulo)
b b
f(x)dx P1 (x)dx (Regra do Trapézio)
b
a a
P 2 (x)dx
a
(Regra de Simpson)
Fórmulas de Newton-Cotes
Regra do
Retângulo
(P0(x))
Regra do
Trapézio
(P1(x))
Regra de
Simpson
(P2(x))
Regra do Trapézio
• A regra do trapézio consiste em aproximar a função f(x)
por um polinômio de grau 1 passando pelos pontos
(x0,f(x0)) e (x1,(f(x1)).
Regra do Trapézio
• Fazendo n =1
b b b
I f ( x).dx P1 ( x).dx [ f ( x0 ) z.f ( x0 )]dx
a a a
Como x x0
z dx h.dz
h
Considerando a = x0 e b = x1, os intervalos de integração,
tem-se para:
x0 x0
xaz 0
h
x x
x b z 1 0 1
h
Regra do Trapézio
• Logo:
1
I [ f ( x0 ) z.f ( x0 )].h.dz
0
z2
I h.[ z. f ( x0 ) .. f ( x0 )]10
2
I h.[ f ( x0 ) 0,5.f ( x0 )]
I h.[ f ( x0 ) 0,5.( f ( x1 ) f ( x0 ))]
h
I .[ f ( x0 ) f ( x1 )]
2
Erro de Truncamento
0
2 sen(x)dx
h h h
I ( f ( x0 ) f ( x1 )) ( f ( x1 ) f ( x2 )) ... ( f ( xn 1 ) f ( xn ))
2 2 2
h
I ( f ( x0 ) 2. f ( x1 ) 2. f ( x2 ) ... 2. f ( xn1 ) f ( xn ))
2
Erro de Truncamento
Em cada um dos n subintervalos, comete-se um erro
ligado ao método dos trapézios.
ba
Dado que n , temos que o erro total cometido é:
h
f ( ) 3 (b a ) f ( ) 3 (b a )
E n h h f ( )h 2
12 h 12 12
Exemplo
• Retomamos o cálculo de
0
2
sen( x)dx,
/20
h
4 8
Exemplo
• Tem-se então:
/8 3
I sen0 2sen sen sen sen 0,9871158
2 8 4 8 2
Erro menor que o trapézio simples.
Para 8 subintervalos:
/20
h
8 16
/ 16 3 3 7
I sen0 2sen sen sen ... sen sen sen
2 16 8 16 8 16 2
0,9967852
Exemplo
Exercício
• Calcule a integral:
1
I x 2 .dx
0
Logo:
aa
xaz 0
h
z ( z 1) 2
2
ba I [ f ( x0 ) z.f ( x0 ) . f ( x0 )]hdz
xb z 2 2!
h 0
Regra de Simpsom 1/3
• Integrando, obtém-se:
z2 z3 z2 2
I h[ z. f ( x0 ) f ( x0 ) ( ) f ( x0 )]02
2 6 4
Sabe-se que:
f ( x0 ) f ( x1 ) f ( x0 )
2 f ( x0 ) f ( x2 ) 2. f ( x1 ) f ( x0 )
Logo
1
I h[2. f ( x0 ) 2( f ( x1 ) f ( x0 )) ( f ( x2 ) 2. f ( x1 ) f ( x0 ))]
3
h
I [ f ( x0 ) 4. f ( x1 ) f ( x2 )]
3
Erro de Truncamento
• Integrar o resíduo
b
E R2 ( x).dx
a
z ( z 1)( z 2) '''
2
E . f ( ).h 4 .dz
0
3!
2
h 4 '' '
E . f ( ). ( z 3 3z 2 2 z )dz
3! 0
h 4 '' ' z4
E . f ( )[ z 3 z 2 ]02
3! 4
h 4 '' '
E . f ( ).0 0
3!
Erro de Truncamento
• Integrar o resíduo com grau maior
2
E R3 ( x).dx
0
3
I ( x 3 2 x 1)dx
1
Exemplo
• Simpsom utiliza 3 pontos (2 subintervalos)
x2 x0 3 1
h 1
2 2
Então xi f ( xi )
1 4
2 13
3 34
h 1
I ( f ( x0 ) 4. f ( x1 ) f ( x2 )) (4 4.13 34)
3 3
I 30
Exemplo
• Resposta analítica
x4
[ x 2 x]13 32,25 2,25 30
4
• Comparando os resultados, pode-se perceber que o erro
foi nulo, como esperado (a 1ª Regra de Simpsom nos dá
erro zero para função até do 3º grau.
• Cálculo do Erro
h5 '''' 1
E . f ( ) .0 0
90 90
Regra de Simpsom 1/3
Generalizada
• De maneira análoga à regra do trapézio, podemos generalizar
a regra 1/3 de Simpson.
x2 n x2 x4 x2 n
I f ( x)dx f ( x)dx f ( x)dx f ( x)dx
x0 x0 x2 x2 n 2
Regra de Simpsom 1/3
Generalizada
x2 n x2 x4 x2 n
x0
f ( x)dx f ( x)dx f ( x)dx
x0 x2 x2 n 2
f ( x)dx
f ( x) dx f ( x0 ) 4 f ( x1 ) f ( x2 )
x2 n h
x0 3
f ( x2 ) 4 f ( x3 ) f ( x4 )
h
3
f ( x2 n 2 ) 4 f ( x2 n 1 ) f ( x2 n )
h
3
h n 1
f ( x)dx f ( x2i ) 4 f ( x2i 1 ) f ( x2i 2 )
x2 n
x0 3 i 0
Exemplo
• Calcular a integral a seguir usando a 1ª regras de
Simpson para 6 subintervalos:
Exemplo
Exercício
• Calcular a integral a seguir usando a 1ª regra de
Simpson Generalizada para 4 subintervalos:
sen( x).dx
0
Erro de Truncamento
f ( 4 ) ( ) 5
E n h
90
(b a ) f ( ) 5
( 4)
h
2h 90
(b a ) ( 4)
f ( )h 4
180
Exemplo
sen( x).dx
0
Exemplo
Regra de Simpson 3/8
• A regra de Simpson 3/8 consiste em aproximar a função
f(x) em um polinômio de grau 3.
𝑏 𝑏
𝑓 𝑥 𝑑𝑥 ≈ 𝑃3 𝑥 𝑑𝑥
𝑎 𝑎
𝑏
𝑧 𝑧−1 2
𝑧 𝑧−1 𝑧−2
𝐼= 𝑓 𝑥0 + 𝑧. ∆𝑓 𝑥0 + . ∆ 𝑓 𝑥0 + . ∆3 𝑓 𝑥0 𝑑𝑥
𝑎 2! 3!
Regra de Simpson 3/8
• Fazendo a mesma substituição de variáveis das aulas
anteriores
3
𝑧 𝑧−1 𝑧 𝑧−1 𝑧−2
𝐼= 𝑓 𝑥0 + 𝑧. ∆𝑓 𝑥0 + . ∆2 𝑓 𝑥0 + . ∆3 𝑓 𝑥0 ℎ. 𝑑𝑧
0 2! 3!
𝑧2 𝑧3 𝑧 2 2
𝑧4 𝑧3 𝑧2 3
3
𝐼 = ℎ[𝑧. 𝑓 𝑥0 + ∆𝑓 𝑥0 + − . ∆ 𝑓 𝑥0 + − + . ∆ 𝑓 𝑥0 ]
2 6 4 24 6 6 0
Regra de Simpson 3/8
• Tabela das Diferenças Ordinárias
Regra de Simpson 3/8
• Montando a tabela das diferenças ordinárias
∆𝑓 𝑥0 = 𝑓 𝑥1 − 𝑓(𝑥0 )
∆2 𝑓 𝑥0 = ∆𝑓 𝑥1 − ∆𝑓 𝑥0 = 𝑓 𝑥2 − 𝑓 𝑥1 − (𝑓 𝑥1 − 𝑓(𝑥0 ))
∆3 𝑓 𝑥0 = ∆2 𝑓 𝑥1 − ∆2 𝑓 𝑥0 = ∆𝑓 𝑥2 − ∆𝑓 𝑥1 − ∆𝑓 𝑥1 − ∆𝑓 𝑥0
= ∆𝑓 𝑥2 − 2∆𝑓 𝑥1 + ∆𝑓 𝑥0
= 𝑓 𝑥3 − 𝑓 𝑥2 − 2. 𝑓 𝑥2 − 𝑓 𝑥1 + 𝑓 𝑥1 − 𝑓 𝑥0
• Portanto,
∆𝑓 𝑥0 = 𝑓 𝑥1 − 𝑓(𝑥0 )
∆2 𝑓 𝑥0 = 𝑓 𝑥2 − 2. 𝑓 𝑥1 + 𝑓(𝑥0 )
∆3 𝑓 𝑥0 = 𝑓 𝑥3 − 3. 𝑓 𝑥2 + 3𝑓 𝑥1 − 𝑓(𝑥0 )
Regra de Simpson 3/8
• Colocando na integral
𝑧2 𝑧3 𝑧 2 2
𝑧4 𝑧3 𝑧2 3
𝐼 = ℎ[𝑧. 𝑓 𝑥0 + ∆𝑓 𝑥0 + − . ∆ 𝑓 𝑥0 + − + . ∆3 𝑓 𝑥0 ]
2 6 4 24 6 6 0
9 9 3
𝐼 = ℎ[3. 𝑓 𝑥0 + ∆𝑓 𝑥0 + . ∆2 𝑓 𝑥0 + . ∆3 𝑓 𝑥0 ]
2 4 8
9 9 3
𝐼 = ℎ[3. 𝑓 𝑥0 + (𝑓 𝑥1 − 𝑓 𝑥0 ) + (𝑓 𝑥2 − 2. 𝑓 𝑥1 + 𝑓(𝑥0 )) + . (𝑓 𝑥3
2 4 8
− 3. 𝑓 𝑥2 + 3𝑓 𝑥1 − 𝑓(𝑥0 ))]
9 9 9 9 9 3
𝐼 = ℎ[3. 𝑓 𝑥0 + 𝑓 𝑥1 − 𝑓 𝑥0 ) + 𝑓 𝑥2 − 𝑓 𝑥1 + 𝑓(𝑥0 ) + 𝑓 𝑥3
2 2 4 2 4 8
9 9 3
− 𝑓 𝑥2 + 𝑓 𝑥1 − 𝑓(𝑥0 ))]
8 8 8
3 9 9 3
𝐼 = ℎ[ 𝑓 𝑥0 + 𝑓 𝑥1 + 𝑓 𝑥2 + 𝑓 𝑥3 ]
8 8 8 8
Regra de Simpson 3/8
• Finalmente
3ℎ
𝐼= [𝑓 𝑥0 + 3𝑓 𝑥1 + 3𝑓 𝑥2 + 𝑓 𝑥3 ]
8
𝑏−𝑎
• ℎ=
3
Erro de Truncamento
• Para encontrar o erro de truncamento basta integrar o
resíduo 3
E R3 ( x).dx
0
3h
f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
x3 n
x0
f ( x) dx
8
3h
f ( x3 ) 3 f ( x4 ) 3 f ( x5 ) f ( x6 )
8
3h
f ( x7 ) 3 f ( x8 ) 3 f ( x9 ) f ( x10 )
8
Regra de Simpson 3/8
Generalizada
3h n 1
f ( x3i ) 3 f ( x3i 1 ) 3 f ( x3i 2 ) f ( x3i 3 )
xn
x0
f ( x)dx
8 i 0
3 f ( 4 ) ( ) 5 (b a ) 3 f ( 4 ) ( ) 5 (b a ) ( 4 )
E n h h f ( ) h 4
80 3h 80 80