Vous êtes sur la page 1sur 32

Interpolasi

By Syaiful Anam
Applied Mathematical Modeling and
Computation Laboratory
Mathematics Department
Brawijaya University
Basic Scenario
We are able to prod some function, but do
not know what it really is.
This gives us a list of data points: [xi,fi]

f(x)
fi fi+1

xi xi+1
Maclaurin and Taylor Polynom
ials
When a Taylor series is truncated to a finite
number of terms the result is a Taylor
polynomial.A Taylor series expanded about
, is called a Maclarin series.These Taylor
(and Maclaurin) polynomials are used to
numerically approximate functions.We
attribute much of the founding theory to
Brook Taylor (1685-1731), Colin Maclaurin
(1698-1746) and Joseph-Louis Lagrange
(1736-1813).
Polynomial Interpolation
Use polynomial of degree N-1 to fit exactly
with N data points (xi,yi), i =1, 2, , N.
N 1
f ( x) c0 c1 x c2 x L cN 1 x
2

The coefficient ci is determined by a


system of linear equations
Joseph-Louis Lagrange
(1736-1813)
Italian-French mathematician
associated with many classic
mathematics and physics
Lagrange multipliers in
minimization of a function,
Lagranges interpolation
formula, Lagranges theorem
in group theory and number
theory, and the Lagrangian
(L=T-V) in mechanics and
Lagrange equations.
Lagrange Interpolation

This method is generally the easiest to work. The


data does not have to be equally spaced and is
useful for finding the points between quadratic and
cubic methods. However, it does not provide an
accurate model for large sets of terms.

P x L1 x y1 L2 x y2
Lagrange Interpolation

The function can be defined as:

Pn 1 x L1 x y1 L2 x y2 Ln x yn
where,
Lk x
x x1 x x2 x xn 1 x xn
xk x1 xk x2 xk xn 1 xk xn
n
x - xi

i 1 xk xi
k i
Lagrange Interpolation

The function can be defined as:


Pn 1 x C1 x x2 x x3 x xn
C2 x x1 x x3 x xn

Cn x x1 x x2 x xn 1
where, the coefficients are defined as:
yk
Ck x
xk x1 xk x2 xk xk 1 xk xk 1 xk xn 1 xk xn
Lagrange Interpolation

The method works for quadratic and cubic


polynomials. As you add additional points in the
degree of the polynomial increases. So if you have
n points it will fit a (n-1)th degree polynomial.
Example of Lagrange
Interpolation

What are the coefficients of the polynomial and


what is the value of P2(2.3)?

y1 10.6
x y C1 9.298
x1 x2 x1 x3 1.1 1.7 1.1 3.0
1.1 10.6
15.2
1.7 15.2 C2 19.4872
3 20.3 1.7 1.11.7 3.0
20.3
C3 8.2186
3.0 1.1 3.0 1.7
Example of Lagrange Interpolation

Lagrange Interpolation
The values are evaluated
25
P(x) = 9.2983*(x-1.7)(x-3.0) 20
- 19.4872*(x-1.1)(x-3.0)
15

y values
+ 8.2186*(x-1.1)(x-1.7)
10
P(2.3) = 9.2983*(2.3-1.7)(2.3-3.0) 5
- 19.4872*(2.3-1.1)(2.3-3.0)
0
+ 8.2186*(2.3-1.1)(2.3-1.7) 1 1.5 2 2.5 3

= 18.3813 x values
Example of Lagrange
Interpolation

What happens if we increase the number of data


points?
Coefficient for 2 is:
x y Ci
1.1 10.6 28.1765 y2
C2
1.7 15.2 129.9145 x2 x1 x2 x3 x2 x4 x2 x5
3 20.3 6.4208
1.4 13.4 -116.319
2.2 18.7 -53.125
Example of Lagrange Interpolation

Note: that the coefficient Lagrange Interpolation


creates a P4(x) polynomial
25
and comparison between the
20
two curves. The original
value P2(x) is given. 15

Y Values
10
The problem with adding
5
additional points will create
bulges in the graph. 0
1 1.5 2 2.5 3
X Values
Example of Lagrange
Interpolation
Example
Given points (x1,y1)=(-2,4), (x2,y2)=(0,2),
(x3,y3)=(2,8)
( x 0)( x 2) ( x (2))( x 2) ( x (2))( x 0)
p( x) 4 2 8
(2 0)(2 2) (0 (2))(0 2) (2 (2))(2 0)
x ( x 2) ( x 2)( x 2) x( x 2)
4 2 8 x2 x 2
8 4 8
Sir Isaac Newton
1643 - 1727
Newton laid the
foundation for
differential and
integral calculus.
His work on optics
and gravitation
make him one of
the greatest
scientists the
world has known.
Newton Interpolation
Polynomials
Newton form of the equation of a straight line passing
through two points (x0, y0) and (x1, y1) is
p1 ( x) p0 ( x) a1 ( x x0 )
a0 a1 ( x x0 )
Newton form of the equation of a parabola passing
through three points (x0, y0), (x1, y1), and (x2, y2) is
p2 ( x) p1 ( x) a2 ( x x0 )( x x1 )
a0 a1 ( x x0 ) a2 ( x x0 )( x x1 )
the general form of the polynomial passing through n
points (x0, y0), ,(xn-1, yn-1) is
pn ( x) pn 1 ( x) an ( x x0 )...( x xn 1 )
a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) ... an ( x x0 )...( x xn 1 )
Newton Interpolation Polynomials (Newton
Divided Difference )
p ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) ... an ( x x0 )...( x xn 1 )
Substituting (x0, y0) into y a0 a1 ( x x0 ) a2 ( x x0 )( x x1 )
a0 f ( x0 )
y0
Substituting (x1, y1) into y a0 a1 ( x x0 ) a2 ( x x0 )( x x1 )
f ( x1 ) f ( x0 )
a1 f [ x1 , x0 ]
x1 x0
y1 y0

x1 x0
Substituting (x2, y2) into y a1 a2 ( x x1 ) a3 ( x x1 )( x x2 )
a2 f [ x2 , x1 , x0 ]
y2 y1 y1 y0

x x x1 x0 f [ x2 , x1 ] f [ x1 , x0 ]
2 1
x2 x0 x2 x0
Newton Polynomial (Newtons Divided
Differences)
Differences
i xi yi=f(xi) ST-1 ST-2 ST-3
0 x0 f(x0) f[x1,x0] f[x2,x1,x0] f[x3,x2,x1,x0]
1 x1 f(x1) f[x2,x1] f[x3,x2,x1]
2 x2 f(x2) f[x3,x2]
3 x3 f(x3)

p3(x)=f(x0)+f[x1, x0] (x-x0)+ f[x2,x1, x0] (x-x0) (x-


x1)+f[x3,x2,x1, x0] (x-x0) (x-x1)(x-x2)
ST : Selisih Terbagi
Example of Newton
Interpolation
Passing through the points (x0, y0)=(-2,
4), (x1, y1)=(0, 2), and (x2, y2)=(2, 8).
Answers f ( x1 ) f ( x0 ) y1 y0
f [ x2 , x1 ] f [ x1 , x0 ] f [ x1 , x0 ]
f [ x2 , x1 , x0 ] x1 x0 x1 x0
x2 x0
24
3 (1) 1
1 0 (2)
2 (2)

p2(x)=f(x0)+f[x1, x0] (x-x0)+ f[x2,x1, x0] (x-x0) (x-x1)


p 2 ( x ) 4 ( x 2) x ( x 2) x 2 x 2
Example of Newton
Interpolation

What are the coefficients of the polynomial and


what is the value of P4(2.3)?
X Y
0 1
1 2 The true function of
2 4 the points is f(x) = 2x
3 8
4 16
Example of Newton
Interpolation

The coefficients are the top row of the chart:


P4 x 1 1* x 0 0.5 * x 0 x 1
0.1667 * x 0 x 1 x 2
0.04167 * x 0 x 1 x 2 x 3
Example of Newton
Interpolation
The values are evaluated
P4(x) = 1 + (x-0)
+ 0.5*(x-0)(x-1)
0.1667*(x-0)(x-1)(x-2)
+ 0.04167*(x)(x-1)(x-2)(x-3)
P(2.3) = 1 + (2.3)
+ 0.5*(2.3)(1.3)
+ 0.1667*(2.3)(1.3)(0.3)
+ 0.04167*(2.3)(1.3)(0.3)(-0.7)
= 4.9183
Forward Newton
i xi yi=f(xi) f 2 f 3f
0 x0 f0 f0 2f0 3f0
1 x1 f1 f1 2f1
2 x2 f2 f2
3 x3 f3

f0=f(x0)=y0 f1=f(x1)=y1 etc.


f0=f1-f0 f1=f2-f1 etc
2f0=f1-f0 2f1=f1-f0
3f0=2f1-2f0
Forward Newton
(1) f 0 f ( x0 )
y0

f ( x1 ) f ( x0 ) f 0
f [ x1 , x0 ]
(2) x1 x0 h

f [ x2 , x1 ] f [ x1 , x0 ]
(3) f [ x2 , x1 , x0 ]
x2 x0
f ( x2 ) f ( x1 ) f ( x1 ) f ( x0 )

x2 x1 x1 x0

x2 x0
f1 f 0
h 2
f0

2h 2!h 2
Forward Newton
General Form

f0 n
f [ xn ,..., x1 , x0 ] n
n!h
f 0 2 f 0 n f 0
pn ( x ) f 0 ( x x0 ) 2
( x x0 )( x x1 ) ... n
( x x0 )( x x1 )..( x xn 1 )
1!h 2!h n!h
Forward Newton
f 0 2 f 0 n f 0
pn ( x ) f 0 ( x x0 ) 2
( x x0 )( x x1 ) ... n
( x x0 )( x x1 )..( x xn 1 )
1!h 2!h n!h

shf 0 s( s 1)h 2 2 f 0 s ( s 1)( s 2)...( s n 1)h n n f 0


pn ( x ) f 0 2
...
1!h 2!h n!h n

f 0 f ( x0 )
y0
( x x0 )
x x0 sh, s R s
h

shf 0 s( s 1)h 2 2 f 0 s ( s 1)( s 2)...( s n 1)h n n f 0


pn ( x ) f 0 ...
1!h 2!h 2 n!h n
sf 0 s( s 1)2 f 0 s ( s 1)( s 2)...( s n 1)n f 0
pn ( x ) f 0 ...
1! 2! n!

Rekursif Relation

s ( s 1)( s 2)...( s n 1)n f 0


pn ( x) pn 1 ( x)
n!
p0 ( x) f ( x0 )
Example

What are the coefficients of the polynomial and


what is the value of P4(2.3)?
X Y
0 1
1 2
2 4
3 8
4 16
x x0 sh, s R ( x x0 )
s
h

sf 0 s( s 1)2 f 0 s ( s 1)( s 2)...( s n 1)n f 0


pn ( x ) f 0 ...
1! 2! n!
2.3 *1 2.3(2.3 1)1 2.3(2.3 1)(2.3 2)1 2.3(2.3 1)(2.3 2)(2.3 3)1
p4 (2.3) 1
1! 2! 3! 4!
4.918338
Backward Newton Gregory
i xi yi=f(xi) f 2f 3f
-3 x-3 f-3
-2 x-2 f-2 f-2
-1 x-1 f-1 f-1 2f-1
0 x0 f0 f0 2f0 3f0

k+1fi=kfi- kf i-1

sf 0 s ( s 1) 2 f 0 s ( s 1)( s 2)...( s n 1) n f 0
pn ( x ) f 0 ...
1! 2! n!
Example

What are the coefficients of the polynomial and


what is the value of P4(2.3)?
X Y
0 1
1 2
2 4
3 8
4 16
( x x0 ) (2.3 4)
s s
h 1

sf 0 s( s 1) 2 f 0 s ( s 1)( s 2)...( s n 1) n f 0
pn ( x ) f 0 ...
1! 2! n!
1.7 * 8 1.7(1.7 1)4 1.7( 1.7 1)(1.7 2)2 1.7(1.7 1)(1.7 2)(1.7 3)1
p4 ( 2.3) 16
1! 2! 3! 4!
4.918338

Vous aimerez peut-être aussi