Interpolation and Curve Fitting: Pierre Bézier
Interpolation and Curve Fitting: Pierre Bézier
Curve Fitting
Pierre Bzier
Administration
Assignment
send
your code to TA
([email protected]), EC229b
Outline
Overview
of interpolation problem
Polynomial interpolation
Bezier curves and b-splines
Least square approximation
Robust curve fitting
Interpolation
Basic
( xi , yi ),
i 1,, m
f ( xi ) yi ,
i 1,, m
Interpolation (cont.)
Additional
Additional
Purposes of Interpolation
Plotting
points
Reading
Differentiating
Replacing
Interpolation vs Approximation
Interpolation function fits given data points
exactly
Interpolation is inappropriate if data points
subject to significant errors
Approximation is usually preferable for
smoothing noisy data
Issues in Interpolation
There
What
Should
Are
Choosing Interpolant
Choice of function for interpolation based on
How
determining
its parameters
evaluating function
differentiating or integrating function
How
polynomials
Trigonometric functions
Exponential functions
Rational functions
We
10
Polynomial Interpolation
Simplest
Unique
There
11
Lagrangian Polynomials
For
P3 ( x )
( x x1 )( x x2 )( x x3 )
( x x0 )( x x2 )( x x3 )
y0
y1
( x0 x1 )( x0 x2 )( x0 x3 )
( x1 x0 )( x1 x2 )( x1 x3 )
( x x0 )( x x1 )( x x3 )
( x x0 )( x x1 )( x x2 )
y2
y3
( x2 x0 )( x2 x1 )( x2 x3 )
( x3 x0 )( x3 x1 )( x3 x2 )
12
13
E ( x ) f ( x ) Pn ( x ) ( x x0 )( x x1 ) ( x xn ) g ( x )
Define
auxiliary function
W (t ) f (t ) Pn (t ) (t x0 )(t x1 ) (t xn ) g ( x )
n+2 zeros, x0, x1, , xn, and x
W
(t) has n+1 zeros if W is a C1 function
W
(t) has n zeros if W is a C2 function
and so on..
W(n+1)(t) has at least one zero between ( x0 , xn , x )
has
( n 1)
() 0
14
d
n 1
f (t ) Pn (t ) (t x0 )( t x1 ) (t xn ) g ( x )
t
dt
f ( n 1) () 0 ( n 1)! g ( x )
f ( n 1) ()
E ( x ) ( x x0 )( x x1 ) ( x xn )
( n 1)!
15
Interpolation
Error
Interpolationoutside
16
Divided-differences
Divided-differences
17
Divided Differences
Given
x1 x0
x1 x0
f [ x1 , x2 ] f [ x0 , x1 ]
f [ x0 , x1 , x2 ]
x2 Wen-Chieh
x0
Numerical Methods
Lin
18
a0 f 0 f [ x0 ]
then Pn ( x0 ) a0 f 0
a1 f [ x0 , x1 ]
then Pn ( x1 ) a0 ( x1 x0 )a1
Let
f 0 f1
f 0 ( x1 x0 )
f1
x0 x1
Numerical Methods Wen-Chieh Lin
19
then
f [ x1 , x2 ] f [ x0 , x1 ]
a2 f [ x0 , x1 , x2 ]
x2 x0
Pn ( x2 ) a0 ( x2 x0 )a1 ( x2 x0 )( x2 x1 )a2
f1 f 0
f 0 ( x2 x0 )
x1 x0
f 2 f1 f1 f 0
x2 x1 x1 x0
( x2 x0 )( x2 x1 )
x2 x0
f 2
Numerical Methods Wen-Chieh Lin
20
We
( x x0 )( x x1 ) ( x xn 1 )an
Pn ( x ) f [ x0 ] ( x x0 ) f [ x0 , x1 ]
( x x0 )( x x1 ) f [ x0 , x1 , x2 ]
( x x0 )( x x1 ) ( x xn 1 ) f [ x0 ,, xn ]
Numerical Methods Wen-Chieh Lin
21
22
Pn ( x ) f [ x0 ] ( x x0 ) f [ x0 , x1 ]
( x x0 )( x x1 ) f [ x0 , x1 , x2 ]
( x x0 )( x x1 ) ( x xn 1 ) f [ x0 ,, xn ]
Numerical Methods Wen-Chieh Lin
23
P3 ( x ) 22.0 ( x 3.2)
8.400
( x 3.2)( x 2.7)
2.856
( x 3.2)( x 2.7)( x 1.0)( 0.528)
Numerical Methods Wen-Chieh Lin
24
P4 ( x ) P3 ( x )
( x 3.2)( x 2.7)( x 1.0)( x 4.8)(0.256)
Numerical Methods Wen-Chieh Lin
25
26
Identical Polynomials
Every
27
Different Forms of
Polynomial Interpolation
Polynomials
Their
Only
28
29
f [ x0 ] ( x x0 ) f [ x0 , x0 h ]
( x x0 )( x x0 h ) f [ x0 , x0 h, x0 2h ]
( x x0 )( x x0 h ) ( x x0 ( n 1)h ) f [ x0 ,, x0 nh ]
30
differences
f i f i 1 f i
Second-order differences
2
f i ( f i ) ( f i 2 f i 1 ) ( f i 1 f i )
f i 2 2 f i 1 f i
Binomial coefficients
nth-order differences
n(n 1)
n
f i f i n nf i n 1
f i n 2 f i
2!
i 0,, ( N n )
Numerical Methods Wen-Chieh Lin
31
f1 f 0 f 0
f [ x0 , x0 h ]
h
h
f [ x0 , x0 h, x0 2h ]
f 2 f1
h
f1 f 0
h
2h
f0
2
2h
f 2 2 f1 f 0
2
2h
f [ x0 , x0 h, x0 2h, x0 3h ]
f 3 2 f 2 f1
2h2
f 2 2 f1 f 0
2h2
3h
3 f 0
3
3! h
n
f0
f [ x0 , x0 h,, x0 ( n 1)h ] n
Numerical Methods
n! h Wen-Chieh Lin
32
f 0
f 0 ( x x0 )
h
f0
( x x0 )( x x0 h )
2
2! h
2
n f 0
( x x0 )( x x0 h ) ( x x0 ( n 1)h )
n! h n
Numerical Methods Wen-Chieh Lin
33
Pn (x ) f 0 ( x x0 )
h
2 f 0
( x x0 )( x x0 h )
2
2! h
n f 0
( x x0 )( x x0 h ) ( x x0 ( n 1)h )
n! h n
x x0
s
h
s( s 1) 2
s( s 1) ( s (n 1)) n
f 0 sf 0
f 0
f0
2!
n!
Numerical Methods Wen-Chieh Lin
34
2
6
0.5
3
35
Original Function
Numerical Methods
Wen-Chieh
Fitting
with P (x) Lin
8
36
37
Spline Curves
Linear
spline
Slope is discontinuous!
Cubic
spline
38
Cubic Spline
gi-1(x)
x0
x1
xi-1
gi(x)
xi
gi+1(x)
xi+1
knots
xn-1
xn
gi ( x ) ai ( x xi ) bi ( x xi ) ci ( x xi ) d i
3
39
Cubic Spline
gi-1(x)
x0
x1
xi-1
gi(x)
xi
xi+1
gi+1(x)
knots
xn-1
xn
gi ( x ) ai ( x xi )3 bi ( x xi ) 2 ci ( x xi ) d i
gi ( xi ) yi
Continuous position
gi ( xi 1 ) gi 1 ( xi 1 )
g 'i ( xi 1 ) g 'i 1 ( xi 1 )
Continuous slope
Continuous curvature
40
hi xi 1 xi
Si g"i ( xi ), i 1,..., n 1
Sn g"n 1 ( xn )
We
ll compute
Representing
HS Y
Numerical Methods Wen-Chieh Lin
41
Computing di , ai and bi
gi ( x ) ai ( x xi )3 bi ( x xi ) 2 ci ( x xi ) d i
From
gi ( xi ) yi , we know d i yi
From
gi ( xi 1 ) gi 1 ( xi 1 ) , we have
ai ( xi 1 xi ) bi ( xi 1 xi ) ci ( xi 1 xi ) d i yi 1
3
Using
hi xi 1 xi and d i yi , we obtain
ai hi bi hi ci hi yi yi 1
3
42
From
Since
Si
bi
2
Si 1 Si
ai
6hi
Numerical Methods Wen-Chieh Lin
43
Computing ci
Substitute
so far into
Then
solve for ci
Si 1 Si 3 Si 2
hi hi ci hi yi yi 1
6hi
2
yi 1 yi 2hi Si hi Si 1
ci
hi
6
Numerical Methods Wen-Chieh Lin
44
Relating S and h
gi ( x ) ai ( x xi ) bi ( x xi ) ci ( x xi ) d i
2
g 'i ( x ) 3ai ( x xi ) 2bi ( x xi ) ci
3
From
Plug
x = xi into gi
(x)
we have
22
g 'i 1 ( xi))
33aai
(
(
x
x
x
x
)
22bibi1(1x( x
xi
x1i)1
)
ci
c1i 1
i
11
i
i
i1
1)
i
45
Substituting
yi 1 yi yi yi 1
h
i 1
i
6f [ xi , xi 1 ] f [ xi 1 , xi ]
Numerical Methods Wen-Chieh Lin
46
h
0
2(h0 h1 )
h1
h1
2(h1 h2 )
h2
h2
2( h2 h3 ) h3
f [ x , x ] f [ x , x ]
1
2
0
1
f [ x2 , x3 ] f [ x1 , x2 ]
6 f [ x3 , x4 ] f [ x2 , x3 ]
f
[
x
,
x
]
f
[
x
,
x
]
n 2
n 1
n 1 n
hn 2
S0
S2
S3
Sn 1
2( hn 2 hn 1 ) hn 1
Sn
hi xi 1 xi
Si g"i ( xi ), i 1,..., n 1
Sn g"n 1 ( xn )
Numerical Methods Wen-Chieh Lin
47