Você está na página 1de 30

Interpolao

Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Clculo Numrico
Unidade 2: Interpolao

Rafael Beserra Gomes

Universidade Federal do Rio Grande do Norte

Maio 2012

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Objetivo
Interpolao usando Sistemas Lineares
Mtodos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Interpolao

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Objetivo
Interpolao usando Sistemas Lineares
Mtodos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Objetivo

Objetivo da interpolao
Os mtodos de interpolao aproximam uma funo a partir da ima-
gem da funo de pelo menos dois pontos.

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Objetivo
Interpolao usando Sistemas Lineares
Mtodos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Mtodos numricos

Polinmio interpolador
Dados n + 1 pontos distintos x0 , x1 , ..., xn e n + 1 valores y0 , y1 , ..., yn ,
existe um e s um polinmio Pn (x) de grau menor ou igual a n tal que
Pn (xk ) = yk .
Mtodos de obteno do polinmio:
Resoluo de sistemas lineares
Frmula de Lagrange
Frmula de Newton

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Deduo
Interpolao usando Sistemas Lineares
Exemplo
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Interpolao Linear

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Deduo
Interpolao usando Sistemas Lineares
Exemplo
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Interpolao Linear

Interpolao Linear
Dados 2 pontos x0 e x1 e seus respectivos valores f (x0 ) e f (x1 ), temos:
b + ax0 = f (x0 )
b + ax1 = f (x1 )  
x0 1 f (x0 )
x1 1 f (x1 )
Uma das formas de obter soluo
f (k ) f (x0 ) k x0
=
f (x1 ) f (x0 ) x1 x0

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Deduo
Interpolao usando Sistemas Lineares
Exemplo
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

x0 = 2, f (x0 ) = 4
x1 = 3, f (x1 ) = 7
Aplicando a proporo linear entre os pontos:
f (k ) 4 k 2
=
74 32
Logo: 1(f (k ) 4) = 3(k 2) f (k ) = 3k 6 + 4 = 3k 2
Dessa forma, por exemplo, f (2.5) = 7.5 2 = 5.5

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Deduo
Interpolao usando Sistemas Lineares
Exemplo
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Interpolao usando
Sistemas Lineares

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Interpolao Quadrtica

Interpolao Quadrtica
Dados 3 pontos x0 , x1 e x2 e seus respectivos valores f (x0 ), f (x1 ) e
f (x2 ), temos:
c + bx0 + ax02 = f (x0 )
c + bx1 + ax12 = f (x1 )
c + bx2 + ax22 = f (x2 )

x02

1 x0 c y0
1 x1 x12 b = y1
1 x2 x22 a y2
Cuidado: preste ateno na ordem das colunas da matriz A e a
ordem do vetor soluo (a, b, c)ou(c, b, a).

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

x0 = 2, f (x0 ) = 4
x1 = 3, f (x1 ) = 2
x2 = 4, f (x2 ) = 7
Temos portanto o seguinte sistema linear para resolver:

1 2 4 c 4
1 3 9 b = 2
1 4 16 a 7

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo
Resolvendo por eliminao de Gauss (2 casas decimais), obtemos:
() 1.00 2.00 4.00 | 4.00
() 1.00 3.00 9.00 | 2.00
() 1.00 4.00 16.00 | 7.00
Passo 1
() 1.00 2.00 4.00 | 4.00
(1.00) 1.00 3.00 9.00 | 2.00
(1.00) 1.00 4.00 16.00 | 7.00
Passo 2
() 1.00 2.00 4.00 | 4.00
() 0.00 1.00 5.00 | -2.00
(2.00) 0.00 2.00 12.00 | 3.00
Final:
() 1.00 2.00 4.00 | 4.00
() 0.00 1.00 5.00 | -2.00
() 0.00 0.00 2.00 | 7.00
x1 = 29.000000
x2 = -19.500000
x3 = 3.500000

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Interpolao com mais de 3 pontos

Interpolao com mais de 3 pontos


Dados n+1 pontos x0 , x1 , x2 ... xn e seus respectivos valores f (x0 ),
f (x1 ), f (x2 ) ... f (xn ), temos:

1 x0 x02 . . . x0n

c0 y0
1 x1 x12 . . . x1n c1 y1
=

. .. .. ..
..

. . .
1 xn xn2 ... xnn cn yn
Cuidado: mais uma vez preste ateno na ordem das colunas da
matriz A e a ordem do vetor soluo (c0 , ..., cn )ou(cn , ..., c0 ).

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

x0 = 1, f (x0 ) = 2
x1 = 2, f (x1 ) = 1
x2 = 3, f (x2 ) = 2
x3 = 4, f (x3 ) = 6
x4 = 1, f (x4 ) = 0
x5 = 5, f (x5 ) = 3
Temos portanto o seguinte sistema linear para resolver:

1 1 1 1 1 1 c0 2
1 2 4 8 16 32 c1 1


1 3 9 27 81 243 c2
2
1 4 16 64 256 1024 c3 =

6

1 1 1 1 1 1 c4 0
1 5 25 125 625 3125 c5 3

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Resolvendo por eliminao de Gauss (2 casas decimais), obtemos:


c0 = 0.140000
c1 = 3.230000
c2 = -0.120000
c3 = -2.080000
c4 = 0.940000
c5 = -0.110000
O polinmio interpolador portanto:
f (x) = 0.11x 5 + 0.94x 4 2.08x 3 0.12x 2 + 3.23x + 0.14.

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Quadrtica
Interpolao usando Sistemas Lineares
Com mais de 3 pontos
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Aproximando o grfico em um dos pontos dados, vemos que ele est


ligeiramente fora da curva. Por qu?

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Polinmio interpolador de
Lagrange

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Frmula de Lagrange
O polinmio na forma de Lagrange dado por:
n
X
Pn (x) = f (xk )`k (x)
k =0

O polinmio tal que zeramos o termo `k (x) se x 6= xk .


Por exemplo: P2 (x) = f (x0 )`0 (x) + f (x1 )`1 (x) + f (x2 )`2 (x)
.
Para x = x0 : P2 (x) = f (x0 )`0 (x) +f (x1 )`1 (x) +f (x2 )`2 (x)
Para x = x1 : P2 (x) = f (x0 )`0 (x)+ f (x1 )`1 (x) +f (x2 )`2 (x)
Para x = x2 : P2 (x) = f (x0 )`0 (x) +f (x1 )`1 (x)+ f (x2 )`2 (x)

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Definio de `k (x)

Definimos ento `k (x) como:

(x x0 )(x x1 )...(x xk 1 )(x xk +1 )...(x xn )


`k (x) =
(xk x0 )(xk x1 )...(xk xk 1 )(xk xk +1 )...(xk xn )

Por exemplo:
Seja n = 2 (3 pontos), ento:
(x x1 )(x x2 )
`0 (x) =
(x0 x1 )(x0 x2 )
(x x0 )(x x2 )
`1 (x) =
(x1 x0 )(x1 x2 )
(x x0 )(x x1 )
`2 (x) =
(x2 x0 )(x2 x1 )

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

x0 = 2, f (x0 ) = 4
x1 = 3, f (x1 ) = 2
x2 = 4, f (x2 ) = 7
Os fatores `k (x) so dados por:
(x 3)(x 4) x 2 7x + 12
`0 (x) = =
(2 3)(2 4) 2
(x 2)(x 4) x 2 6x + 8
`1 (x) = =
(3 2)(3 4) 1
(x 2)(x 3) x 2 5x + 6
`2 (x) = =
(4 2)(4 3) 2

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

x0 = 2, f (x0 ) = 4
x1 = 3, f (x1 ) = 2
x2 = 4, f (x2 ) = 7
Portanto:
x 2 7x + 12 x 2 5x + 6
P2 (x) = 4 + 2(x 2 + 6x 8) + 7
2 2
P2 (x) = 2(x 2 7x + 12) + 2(x 2 + 6x 8) + 3.5(x 2 5x + 6)
P2 (x) = 3.5x 2 19.5x + 29
Confira com o exemplo de interpolao quadrtica.

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Polinmio interpolador de
Newton

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Diferena dividida
Termo recursivo definido por:
f [x1 , x2 , ..., xn ] f [x0 , x1 , ..., xn1 ]
f [x0 , x1 , ..., xn ] =
xn x0

Por exemplo:
f [x0 ] = f (x0 )
f [x1 ] f [x0 ]
f [x0 , x1 ] =
x1 x0
f [x1 , x2 ] f [x0 , x1 ]
f [x0 , x1 , x2 ] =
x2 x0
f [x1 , x2 , x3 ] f [x0 , x1 , x2 ]
f [x0 , x1 , x2 , x3 ] =
x3 x0

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Frmula de Newton
Pn (x) = f [x0 ]
+ (x x0 )f [x0 , x1 ]
+ (x x0 )(x x1 )f [x0 , x1 , x2 ]
+ ...
+ (x x0 )(x x1 )...(x xn1 )f [x0 , x1 , ..., xn ]

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

x0 = 2, f (x0 ) = 4
x1 = 3, f (x1 ) = 2
x2 = 4, f (x2 ) = 7
Primeiro calculemos as diferenas divididas a serem usadas:
f [x0 ] = f (x0 ) = 4
f [x1 ] = f (x1 ) = 2
f [x2 ] = f (x2 ) = 7
f [x1 ] f [x0 ] 24
f [x0 , x1 ] = = = 2
x1 x0 32
f [x2 ] f [x1 ] 72
f [x1 , x2 ] = = =5
x2 x1 43
f [x1 , x2 ] f [x0 , x1 ] 5 (2)
f [x0 , x1 , x2 ] = = = 3.5
x2 x0 42

Rafael Beserra Gomes Clculo Numrico


Interpolao
Interpolao Linear
Interpolao usando Sistemas Lineares
Polinmio interpolador de Lagrange
Polinmio interpolador de Newton

Exemplo

Depois, substituindo as diferenas divididas na frmula de Newton,


obtemos: P2 (x) = f [x0 ] + (x x0 )f [x0 , x1 ] + (x x0 )(x x1 )f [x0 , x1 , x2 ]
P2 (x) = 4 + (x 2)(2) + (x 2)(x 3)3.5
P2 (x) = 3.5x 2 19.5x + 29

Rafael Beserra Gomes Clculo Numrico

Você também pode gostar