Sunteți pe pagina 1din 25

10/30/2011

INTERPOLAO

Profa.LucianaMontera
montera@facom.ufms.br
FaculdadedeComputao Facom/UFMS

MtodosNumricos

Interpolao
Definio
Aplicaes
InterpolaoLinear
Equaodareta
Estudodoerro

InterpolaoPolinomial
FrmuladeLagrange

l d
PolinmioInterpoladordeLagrange
Estudodoerro

MtodosNumricos

10/30/2011

Definio
oprocessodeestimarvaloresdeuma
funofparavaloresdex diferentesdexi,
para i=0,...,n,sabendoseapenasosvaloresde
f(x)nospontosx0, x1, ...,xn.

MtodosNumricos Interpolao

Definio
oprocessodeestimarvaloresdeuma
funofparavaloresdex diferentesdexi,
para i=0,...,n,sabendoseapenasosvaloresde
f(x)nospontosx0, x1, ...,xn.
Qualovalordef(xi)parax1 <xi <x2 ?
x

x0

x1

x2

f(x0)

f(x1)

f(x2)

...

xn
f(xn)
MtodosNumricos Interpolao

10/30/2011

Aplicaes
Obtenodevaloresintermediriosem
t b l (crescimentodebactrias,consumodegua,
tabelas(
energia,etc)
Integraonumrica
Clculoderazesdeequao
Soluodeequaesdiferenciasordinrias
Soluo de equaes diferencias ordinrias
(EDOs)

MtodosNumricos Interpolao

Interpolao
Qualovalordef(xi)parax1 <xi <x2 ?
x

x0

x1

x2

f(x0)

f(x1)

f(x2)

...

xn
f(xn)

Comodeterminarovalordef(xi)?
Obterumafunoquerelacionaasvariveisxey

POLINMIO
MtodosNumricos Interpolao

10/30/2011

Interpolao
MtodosdeInterpolaoPolinomialso
utilizados
tili d para aproximar
i
uma funo
f f(x)
f( )
quando:
f(x)desconhecida.Temseapenasvaloresdef
emumconjuntodepontos
j
p
f(x)conhecidamasdedifcilmanipulao

MtodosNumricos Interpolao

InterpolaoPolinomial
Interpolao Polinominal
Linear:Polinmiodegrau1
Quadrtica:Polinmiodegrau2
Lagrange:Polinmiodegraun
MtodosNumricos Interpolao

10/30/2011

InterpolaoLinear
Problema:Sejaf(x)dadapelatabela
x0

x1

x2

f0

f1

f2

...

Nota:
f(xi) =fi
xn
fn

Determinar uma aproximao para f(), onde xi < < xi+1 para 0 i < n
f no conhecida aproximar f pelopolinmioP1
P1()sercalculado,enof()
MtodosNumricos Interpolao

InterpolaoLinear
P1(x)opolinmiodegrau1quepassapelospontos
A=(xi,fi)eB=(xi+1,fi+1)

f() P
P1()=f
() = fi +(
+ ( xi)(f
) (fi+1
i 1 fi)
(xi+1 xi)

MtodosNumricos Interpolao

10/30/2011

InterpolaoLinear
EquaesdaReta

y=ax

a =coeficienteangular
b =coeficientelinear

y=ax+b
b
MtodosNumricos Interpolao

InterpolaoLinear
EquaesdaReta
Pi=(xi,yi)
Pi+1

Pi+1=(xi+1,yi+1)

Pi

MtodosNumricos Interpolao

10/30/2011

InterpolaoLinear
EquaesdaReta
a =coeficienteangular=inclinaodareta=tag
yi+1

yi

a =tag =cat.op.=yi+1 yi
cat.adj.x
d
i+1 xi

xi+1

xi

MtodosNumricos Interpolao

InterpolaoLinear
EquaesdaReta
Pi+1

yi+1
P

y
yi

Pi

xi

xi+1
MtodosNumricos Interpolao

10/30/2011

InterpolaoLinear
EquaesdaReta

Semelhana
entre tringulos
Semelhanaentretringulos
Pi+1

yi+1
P

y
yi

Pi

a =tag =cat.op. =cat.op.


cat.adj. cat.adj.

a =tag =yi+1 yi = y yi
xi+1 xi
xi

xi

xi+1
MtodosNumricos Interpolao

InterpolaoLinear
EquaesdaReta

Semelhana entre tringulos


Semelhanaentretringulos
Pi+1

yi+1
P

y
yi

Pi

xi

yi+1 yi = y yi
xi+1 xi
xi

xi+1
MtodosNumricos Interpolao

10/30/2011

InterpolaoLinear
EquaesdaReta
yi+1 yi = y yi
xi+1 xi
xi
(y yi)(xi+1 xi)= ( xi)(yi+1 yi)
(y yi)=( xi)(yi+1 yi)
(xi+1 xi)
y= yi++( xi)(yi+1 yi)
(xi+1 xi)

MtodosNumricos Interpolao

InterpolaoLinear
P1(x)opolinmiodegrau1quepassapelospontos
A=(xi,fi)eB=(xi+1,fi+1)

f() P
P1()=f
() = fi +(
+ ( xi)(f
) (fi+1
i 1 fi)
(xi+1 xi)

MtodosNumricos Interpolao

10/30/2011

InterpolaoLinear
Exemplo:

O nmero de bactrias, por unidade de volume,


existente em uma cultura aps
p x horas apresentado
p
na tabela:
x(horas)

y(volumedebactrias)

32

47

65

92

132

Calcule o volume de bactrias no instante t = 3 horas e 42 minutos, ou


seja, calcule o valor de P1(3,7).

f() P1()=fi +( xi)(fi+1 fi)


(xi+1 xi)
MtodosNumricos Interpolao

InterpolaoLinear
Exemplo:

O nmero de bactrias, por unidade de volume,


existente em uma cultura aps
p x horas apresentado
p
na tabela:
x(horas)

y(volumedebactrias)

32

47

65

92

132

Calcule o volume de bactrias no instante t = 3 horas e 42 minutos, ou


seja, calcule o valor de P1(3,7).

f(3,7) P1(3,7)=92+(3,7 3)(132 92)


(4 3)
f(3,7) P1(3,7)=120

MtodosNumricos Interpolao

10

10/30/2011

InterpolaoLinear
Exerccio:

O nmero de bactrias, por unidade de volume,


existente em uma cultura aps
p x horas apresentado
p
na tabela:
x(horas)

y(volumedebactrias)

32

47

65

92

132

Calcule o volume de bactrias no instante t = 1h e 25min.

MtodosNumricos Interpolao

InterpolaoLinear
Exemplo: Dada a tabela
x(rad)

0,1

0,2

0,3

0,4

sen(x)

0,1

0,199

0,296

0,389

Calcule o valor aproximado de sen(0,15)

f(0,15) P1(0,15)=0,1+(0,15 0,1)(0,199 0,1)


(0,2 0,1)
f(0,15) P1(0,15)=0,1495

MtodosNumricos Interpolao

11

10/30/2011

InterpolaoLinear
Exerccio: Dada a tabela
x(rad)

0,1

0,2

0,3

0,4

sen(x)

0,1

0,199

0,296

0,389

Calcule o valor aproximado de sen(0,32)

MtodosNumricos Interpolao

InterpolaoLinear
Erro
Seja o intervalo [xi, xi+1] e um ponto x (xi, xi+1).
Como P1(x) apenas uma aproximao para f(x), o erro cometido nesta
aproximao :
E(x) = f(x) P1(x)
E(x) = (x xi) (x xi+1) f()

para algum (xi, xi+1)

2
MtodosNumricos Interpolao

12

10/30/2011

InterpolaoLinear
Conta para o Erro
Suponha que x (xi, xi+1), |f (x)| M2, para alguma constante M2.
A seguinte estimativa para o erro pode ser considerada:

|E(x)| M2 (xi+1 xi)2


8

MtodosNumricos Interpolao

InterpolaoLinear
Exemplo: Dada a tabela
x(rad)

0,1

0,2

0,3

0,4

sen(x)

0,1

0,199

0,296

0,389

Valor aproximado de sen(0,15)

f(0,15) P1(0,15)=0,1495

Calcule o erro da aproximao acima


f(x) = sen(x)
f(x) = cos(x)
f(x) = sen(x)

|f(x)|
|f
(x)| =|sen(x)|
=| sen(x)| |sen(0,2)|
| sen(0 2)|
sen(0,2) = 0,199 < 0,2 x [0,1, 0,2]

|E(x)| M2 (xi+1 xi)2 = 0,2 (0,2 0,1) 2 = 0,00025


8

MtodosNumricos Interpolao

13

10/30/2011

InterpolaoPolinomial
Nota:
f(xi) =fi=yi

Problema:Dadosn+1paresdevalores(xi,fi),
i=0,...,ncomxi xj paraij,determinarumpolinmio
degraunquepassaporestesn+1pontos.
x0

x1

x2

y0

y1

y2

...

xn
yn

f no conhecida aproximar f pelopolinmioPn


Pn()sercalculado,enof()
MtodosNumricos Interpolao

InterpolaoPolinomial
x0

x1

x2

y0

y1

y2

...

xn
yn

Pn(x)

MtodosNumricos Interpolao

14

10/30/2011

InterpolaoPolinomial
x0

x1

x2

y0

y1

y2

Proposio:

...

xn
Pn(x)

yn

Sejamn+1pontosdadospor(xi,fi),i=0,...,n

ondexi xi,paraij.Entoexisteumnicopolinmiodegraun
quepassaporestespontos.

MtodosNumricos Interpolao

InterpolaoPolinomial
Demonstrao:

ConsiderePn(x)umpolinmiodegraun:

Pn(x)=a0 +a1x+a2x2 +a3x3+...+anxn

aixi

sendoai=cte

i=0

Pn passapelospontos(x
passa pelos pontos (xi,ffi).
)
Pn(xi)=fi,i=0,...,n
precisodeterminarasconstantesai paradepoisdeterminarPn(x).
MtodosNumricos Interpolao

15

10/30/2011

InterpolaoPolinomial
Demonstrao:
Temsolu
uonica?

Pn(xi)=fi,i=0,...,nequivalenteaosistema:
a0 +a1x0 +a2x02 +a3x03 +...+anx0n

=f0

a0 +a1x1 +a2x12 +a3x13 +...+anx1n

=f1

.
.
.

a0 +a1xn +a2xn2 +a3xn3+...+anxnn

=fn

OSistematemsoluonicadesdequeodeterminantedamatriz
doscoeficientesdasicgnitassejanonulo
MtodosNumricos Interpolao

InterpolaoPolinomial
Demonstrao:
1x0
A=

x02

x03

...x0n

1 x1 x12 x13 ...x1n


..
..
.....
1xn xn2 xn3 ...xnn

Aamatrizdecoeficientes
dasicgnitas.
umamatrizde
Vandermonde, cujodet(A)
dadopor:

det(A)=(xj xi)
1i<jn

Comoxi xj paraij,temosquedet(A)0,comoqueramosdemonstrar.
MtodosNumricos Interpolao

16

10/30/2011

InterpolaoPolinomial
x0

x1

x2

y0

y1

y2

...

xn
Pn(x)

yn

Pn(x)existeenico
Problema: dadosospontos(xi,fi) parai=0,...,n,ondexi xjj paraij,
determinarovalordef() ,paraxj,j=0,...,n.

Soluo: Aproximar f() porPn(),ondePn opolonmiodegraun


quepassapelospontos(xi,fi)parai=0,...,n.
MtodosNumricos Interpolao

InterpolaoPolinomial
Exemplo:determineovalordelog(2,45)aproximadoporumpolinmio
interpoladordegrau3.
x

2,3

2,4

2,5

2,6

log(x)

0,361728

0,380211

0,397940

0,414973

a0 +a1x0 +a2x02 +a3x03 =f0


a0 +a1x1 +a2x12 +a3x13 =f1
a0 +a1x2 +a2x22 +a3x23 =ff2
a0 +a1x3 +a2x32 +a3x33 =f3

MtodosNumricos Interpolao

17

10/30/2011

InterpolaoPolinomial
Exemplo:determineovalordelog(2,45)aproximadoporumpolinmio
interpoladordegrau3.
x

2,3

2,4

2,5

2,6

log(x)

0,361728

0,380211

0,397940

0,414973

a0 +2,3a1 +5,9a2 +12,167 a3

=f0

a0 +2,4a1 +5,76a2 +13,824a3

=f1

a0 +2,5a
2 5 1 +6,25a
6 25 2 +15,625a
15 625 3

=ff2

a0 +2,6a1 +6,76 a2 +17,576a3

=f3

a0
a1
a2
a3

=0,404885
=0,528963
=0,107300
,
=0,009667

P3(x)=0,404885+0,528963x0,107300x2 +0,009667x3
log(2,45) P3(2,45)=0,389170

MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
Teorema (Lagrange): Seja f uma funo definida num intervalo [a,
b]] e conhecida nos p
pontos ((xi, fi) i = 0,...,
, , n. Existe um e um s
polinmio Pn de grau menor ou igual a n interpolador de f nos
pontos dados.
Demonstrao: Seja o polinmio Pn definido por:
n

Pn (x) =

f(xi)Li (x)

i=0

onde:
Polin.degraun

Lk (x) =

j=0,jk

x xj
xk xj

k = 1, ..., n
MtodosNumricos Interpolao

18

10/30/2011

FrmuladeLagrange
n

Lk (x) =

j=0,jk

x xj
xk xj

k = 1, ..., n

Lk (xi) =

j=0,jk

xi xj
xk xj

k = 1, ..., n

1 sek=i

Lk (xi) =

0seki
MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
n

Pn (x) = Li(x)fi
i=0

Pn(x)umpolinmiodegraun,poisasomade
Li(x)fiqueumpolinmiodegraunparai=0,...,n
Pn(x)=f(x)para todoxk,k=0,...,n
n

Pn(xk)=Li(xk)fi =fi paratodok=0,...,n


i=0
MtodosNumricos Interpolao

19

10/30/2011

PolinmioInterpoladordeLagrange
Exemplo: Determineopolinmiodegrau3, P3(x),quepassa
pelospontosdatabelaabaixo.Emseguida,calculeP3(2).
xi

fi

P3(x)=Li(x)fi =L0(x)f00 +L1(x)f11 +L2(x)f22 +L3(x)f33


i=0

=L0(x)f0+L1(x)f1+L2(x)f2+L3(x)f3
=L0(x)2 +L1(x)4 +L2(x)5 +L3(x)0
MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
n
xi

fi

Lk (x)=x xj
j=0 x x
j=0,
k
j
jk

L0(x)=(x 1)(x 3)(x 4)=(x 1)(x 3)(x 4)=(x 1)(x 3)(x 4)


(0 1)(0 3)(0 4)( 1)( 3)( 4) 12

L1(x)=
( ) (x 0)(x 3)(x 4)=x(x 3)(x 4)=x(x 3)(x 4)
(1 0)(1 3)(1 4)(1)( 2)( 3)6

L2(x)=(x 0)(x 1)(x 4)=x(x 1)(x 4)=x(x 1)(x 4)


(3 0)(3 1)(3 4)(3)(2)(1)6
MtodosNumricos Interpolao

20

10/30/2011

PolinmioInterpoladordeLagrange
Exemplo: Determineopolinmiodegrau3, P3(x),quepassa
pelospontosdatabelaabaixo.Emseguida,calculeP3(2).
xi

fi

P3(x)=Li(x)fi =L0(x)2 +L1(x)4 +L2(x)5 +L3(x)0


i=0

P3(x)=
=2 (x 1)(x 3)(x 4) +4 x(x 3)(x 4) +5 x(x 1)(x 4)
12

P3(2)= 1+8+10=17
3333

MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
Exerccio: Determineopolinmiodegrau3, P3(x),quepassapelos
pontosdatabelaabaixo.Emseguida,calculeP
pontos
da tabela abaixo. m seguida, calcule P3((1,5).
,5).
xi

fi

15

40

85

MtodosNumricos Interpolao

21

10/30/2011

PolinmioInterpoladordeLagrange
Erro
Proposio: Seja f (n+1) vezes derivvel o intervalo no
intervalo (a, b) e x0 < x1 < ... < xn (a, b). Ento, para
x (a, b), x xi, existe um (a, b) tal que:
n

f(x) = Pn(x) + (x xk) f(n+1)()


k=0

E
Erro
E(x)
E( )

(n + 1)!
n

E(x) = f(x) Pn(x) = (x xk)f(n+1)()


k=0

(n+1)!

MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
Cota para o Erro
Suponha que exista uma contante M tal que |f(n+1)(x)| M
para x (a, b). Ento:
n

|E(x)| = |f(x) Pn(x)| = |(x xk)|f(n+1)()


k=0

(n + 1)!
(n+1)!

|(x xk)|M
k=0
(n+1)!
MtodosNumricos Interpolao

22

10/30/2011

PolinmioInterpoladordeLagrange
Exemplo: Usando a tabela abaixo, e sabendo que
1 45 por
f(x) = ex, determine a aproximao para e1,45
P3(1,45) e calcule uma cota para o erro cometido.
x

1,0

1,2

1,4

1,6

f(x)

2,718

3,320

4,055

4,953

Soluo:
3

P3(x)=Li(x)fi =L0(x)2,718 +L1(x)3,320 +L2(x)4,055 +L3(x)4,953


i=0

MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
x

1,0

1,2

1,4

1,6

f(x)

2,718

3,320

4,055

4,953

Lk (x)=x xj
j=0 x x
j=0,
k
j
jk

L0(x)=(x 1,2)(x 1,4)(x 1,6)=(x 1,2)(x 1,4)(x 1,6)=(x 1,2)(x 1,4)(x 1,6)
(1 1,2)(1 1,4)(1 1,6)( 0,2)( 0,4)(0,6) 0,048
L1(x)=(x 1)(x 1,4)(x 1,6)=(x 1)(x 1,4)(x 1,6)=(x 1)(x 1,4)(x 1,6)
(1,2 1)(1,2 1,4)(1,2 1,6)(0,2)( 0,2)(0,4)0,016
L2(x)=(x 1)(x 1,2)(x 1,6)=(x 1)(x 1,2)(x 1,6)=(x 1)(x 1,2)(x 1,6)
(1,4 1)(1,4 1,2)(1,4 1,6)(0,4)(0,2)(0,2)0,016
L3(x)=(x 1)(x 1,2)(x 1,4)=(x 1)(x 1,2)(x 1,4)=(x 1)(x 1,2)(x 1,4)
(1,6 1)(1,6 1,2)(1,6 1,4)(0,6)(0,4)(0,2)0,048

23

10/30/2011

PolinmioInterpoladordeLagrange
3

P3(x)=Li(x)fi =L0(x)2,718 +L1(x)3,320 +L2(x)4,055 +L3(x)4,953


i=0

(x 1)(x 1,4)(x 1,6)


(x 1,2)(x 1,4)(x 1,6)
P3(x)=2,718+3,320
0,048

0,016

(x 1)(x 1,2)(x 1,6)


(x 1)(x 1,2)(x 1,4)
4,055+4,953
0,016

0,048

P3(1,45)=2,718{[(1,45 1,2)(1,45 1,4)(1,45 1,6)]/0,048}+


3,320{[(1,45 1)(1,45 1,4)(1,45 1,6)]/0,016}+
4,055{[(1,45 1)(1,45 1,2)(1,45 1,6)]/0,016}+
4,953{[(1,45 1)(1,45 1,2)(1,45 1,4)]/0,048}=4,26306
MtodosNumricos Interpolao

PolinmioInterpoladordeLagrange
Erro
P3(1,45)=4,26306
e1,45 =4,26311
E(1,45)=e1,45 P3(1,45)=4,26311 4,26306=0,00005

MtodosNumricos Interpolao

24

10/30/2011

PolinmioInterpoladordeLagrange
CotaparaoErro
|ex|Mparax (1,1,6)
|e1,6|=4.953 M4.953
n

|E|
|(x xk)|M
k=0
(n+1)!
=|(1,45 1)(1,45 1,2)(1,45 1,4)(1,45 1,6)|4,953
4!

=0,00017
MtodosNumricos Interpolao

25

S-ar putea să vă placă și