Upload
chiru1431
View
214
Download
0
Embed Size (px)
Citation preview
7/27/2019 ch5_4.doc'kfxzghj,
1/18
Chapter 5. B-Splines
5.1. First Order B-Spline
B-splines (think Basis splines) form a truly piecewise basis for the spline family
as can be learned later. For a set of infinite data points ),,( =ixi where 1+< ii xx
for any i , the B-splines of degree k are defined as
1),()()( 1111
11
+
= ++++
++
+
kxBxx
xxxB
xx
xxxB ki
iki
kik
i
iki
ik
i (5.1.1)
and
=
== +
otherwise
xxxxB
ii
i,0
),[,1)(
10(5.1.2)
where i and kare integers as usual. Note: 0)(1 xBk
i always.Each )(
0 xBi is nonzero in exactly one interval (Figure 5.1.1) and has a
discontinuity at 1+ix . For any dataset ),,2,1,,( niyx ii = , the constant B-spline is
=
=n
i
ii xByxs1
0 )()( (5.1.3)
which simply extends each iy across eachthi interval.
x(i-1) x(i) x(i+1) x(i+2) x(i+3) x(i+4)0
0.5
1
1.5
Bi0 B
i+20
Figure 5.1.1 Non-zero parts of B-splines of degree 0.
1
7/27/2019 ch5_4.doc'kfxzghj,
2/18
For 1=k , )(1xBi can be derived from Equations 5.1.1.and 5.1.2 as
=
+
=
++++
+
+
+
+++
+
+
elsewhere
xxxxx
xx
xxx
xx
xx
xBxx
xxxB
xx
xxxB
ii
ii
i
ii
ii
i
i
ii
ii
i
ii
i
i
,0
),[,
),[,
)()()(
21
12
2
1
1
0
1
12
20
1
1
(5.1.4)
which has two non-zero parts, in intervals [ )1, + ii xxx and [ )21 , ++ ii xxx as shown inFigure 5.1.2 (Dashed lines are used in order to make the splines more distinguishable).
These intervals are called the support of )(1 xBi . On each of its support intervals,
)(1 xBi is a linear function and its location and slope are solely determined by the
distribution of the ix s. )(1 xBi has a peak value of 1 at 1+ix and is continuous there. It
is quite clear that )(1xBi has
0C but not 1C continuity.
2
7/27/2019 ch5_4.doc'kfxzghj,
3/18
x(i-1) x(i) x(i+1) x(i+2) x(i+3) x(i+4)0
0.5
1
1.5
Bi-1
1 Bi
1 Bi+1
1 Bi+2
1
Figure 5.1.2 Non-zero parts of B-splines of degree 1.
It is interesting to note that )(1 xBi has some connection to the elementary
Lagrange interpolating polynomial. If we write the linear Lagrange interpolating
polynomial for the two-point data set of )1and,( += iijxj , the two elements would be:
ii
i
ii
i
xx
xxxl
xx
xxxl
=
=
+++
1
22
1
121 )(,)(
which are the second part of )(1
1 xBi and the first part of )(1xBi , respectively. As we
shall learn, this agreement does not extend to higher order B-splines.
In general, the 1st order B-spline is constructed from
)()( 1 1 xBDxs ii
i
=
= (5.1.5)
where iD are constants determined from the data. However, we know from Section 4.1.1
that the linear spline on a given data interval is also the Lagrange interpolation formula
for the data set consisting of the two end points of the same data interval. So lets discuss
the relationship of )(1 xBi with the linear splines. It turns out that for any data set
)infinitybecanwhere,,,2,1,,( nniyx ii = , the following function is a linear spline:
3
Support intervals for
7/27/2019 ch5_4.doc'kfxzghj,
4/18
)()(1
1
1
xByxs i
n
i
i
=
= (5.1.6)
To prove it, lets look at the formula of )(xs on interval [ ]1, +ii xx . Of all the
terms in the above equation, only)(
1
1
xBi and
)(1xB
i have non-zero contributions onthe interval. Thus
],[,)()()( 11
1
1
1 ++ += iiiiii xxxxByxByxs (5.1.7)
On the interval [ ]1, +ii xx , )(1 1 xBi will take the second leg of its formula and)(1 xBi will take the first leg of its formula (see Equation 5.1.4). Thus
],[,)( 11
1
1
1
++
++
+
+
= iiii
i
i
ii
i
i xxxxx
xxy
xx
xxyxs (5.1.8)
which is exactly the linear spline (see Equation 4.1.1) as well as the linear Lagrange
interpolating polynomial.
Say 2211 ,;, yxyx are the only nonzero data, then
0)()(0)(1
12
1
01+++++= xByxByxs
where
[ )
[ )
=
21
12
2
10
01
0
10
,
,
)(
xxxxx
xx
xxx
xx
xx
xB
and
[ )
[ )
=
32
23
3
21
12
1
1
1
,
,
)(
xxxxxxx
xxxxx
xx
xB
4
7/27/2019 ch5_4.doc'kfxzghj,
5/18
[ )
[ )
[ )
+
=
extensionRight,x
LagrangeisrowThis,x
extensionLeft,x
)(
32
32
32
21
12
12
21
21
10
01
01
xxxx
xxy
xxxx
xx
yxx
xx
y
xxxx
xxy
xs
The central row is the same as a Lagrange interpolating polynomial, but )(xs in
terms of B-splines is more general: it contains Lagrange plus two arbitrary end extensions
(points 30 ,xx are not part of the data set) as seen in Fig 5.1.3.
Now we see why we would use )(1 1 xBi instead of )(1 xBi in Equation 5.1.5
and 5.1.6. The reason is that the hat shape of )(1 xBi (Figure 5.1.2) is centered at 1+ix ,
not ix . For iy s contribution to take place, it should be teamed with a component of B-
splines
Figure 5.1.3 First degree B-spline for two data points.
that lags by 1. So yi is teamed with)(1
1
xBi . Similar notation is used for all higher order
B-splines. For example, in the case of 2=k which will be discussed later, the sum overi of terms iy )(
2
2 xBi are used together. Furthermore, since )(1
1 xBi is centered on
ix , ii yD = . Further insight can be gleamed from Figure 5.1.2.
It is worth noting that on [ )1, + ii xxx , )(1 1 xBi + )(1 xBi = 1 exactly. As wewill prove later, this is true for all orders of B-splines on all intervals.
5
0
0B0
1B0
2B
1
y1
y2
xx
0x
1 x2 x3
7/27/2019 ch5_4.doc'kfxzghj,
6/18
Generally for linear splines, two points are used to draw a straight line for each
interval. Then for each data point, its x and y information will contribute to two splines.
In the case of )(1xBi , this contribution is built into its expression through its two legs.
This is the essence of all B-splines and one reason why they are called basis splines.
Polynomial splines and Lagrange interpolating polynomials discussed before can
all be viewed as functions over interval(s), as functions should be. The emphasis here ison the intervals. A polynomial is set up over the interval(s), then, we go to its end points
for help on determining the coefficients of the polynomials.
B-splines, however, should be viewed more as belonging to the points. Each
point function covers certain interval(s). To build splines through B-splines, we will
always use the form similar to that in Equation 5.1.5. The y information is applied to thepoint function and we are done (almost, anyway) with the building of the splines. This
feature will be more evident in the case for )(2 xBi .
6
7/27/2019 ch5_4.doc'kfxzghj,
7/18
5.2 Second Order B-Splines
Now for 2=k , from Equation (5.1.1) and (5.1.2), we have
)()()( 1 113
31
2
2 xBxx
xxxB
xx
xxxB i
ii
ii
ii
ii
+++
+
+
+
=
+
= +++
+
++
)()(0
1
12
20
12
xBxx
xxxB
xx
xx
xx
xxi
ii
i
i
ii
i
ii
i
+
+ +++
++
++
+
++
+ )()(0
2
23
30
1
12
1
13
3 xBxx
xxxB
xx
xx
xx
xxi
ii
i
i
ii
i
ii
i
+
=
++
++++
+
++
++
++
+
+
++
+
++
elsewhere
xxx
xxxx
xx
xxx
xx
xxxx
xx
xxxx
xx
xxxxxxx
xx
xB
ii
iiii
i
ii
ii
ii
ii
ii
ii
ii
iiii
i
i
,0
),[,))((
)(
),[,))(())((1
),[,))((
)(
)(
32
2313
2
3
21
13
31
2
2
12
1
21
2
2(5.2.1)
Non-zero parts of three2
B splines are plotted in Figures 5.2.1. The support ofeach spline covers three intervals. It is a quadratic polynomial on each support interval.
Note that the peak value of )(2 xBi is less than 1. This is different from )(
0 xBi , )(1 xBi
and other interpolation functions that do have peak values of 1. If all the 2B splines
could be plotted, in any interval, there would be contributions from three splines. But we
only see this in ],[ 21 ++ ii xx in Figure 5.2.1. Interestingly, these three contributions sum
to unity.
7
7/27/2019 ch5_4.doc'kfxzghj,
8/18
Also, the components of )(2 xBi differ from the quadratic Lagrange polynomials.
For comparison, Figure 5.2.2 shows three quadratic elementary Lagrange polynomials for
the data set of )2and1,,( ++= iiijxj . The3
1l term goes negative. Different indeed!
x(i-1) x(i) x(i+1) x(i+2) x(i+3) x(i+4)0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Bi-12
Bi2
Bi+12
Figure 5.2.1 Non-zero parts of B-splines of degree 2. Note that the peak values are less than 1, but the
splines in ],[ 21 ++ ii xx sum to 1.
x(i-1) x(i) x(i+1) x(i+2) x(i+3) x(i+4)-
- .
0.5
1
1.5
3(x)
3(x)
l3(x)
8
7/27/2019 ch5_4.doc'kfxzghj,
9/18
Figure 5.2.2 Comparison between B-spline of degree 2 and the elementary quadratic Lagrange
polynomials. Note: one component goes negative, however =
=3
1
3 1i
il .
By taking derivatives of all the sections in Equation 5.2.1, we get
++
+
=
++
++++
+
++
++
++
+
+
++
+
++
elsewhere
xxxxxxx
xx
xxx
xx
xxxx
xx
xxxx
xx
xxxxxxx
xx
xB
ii
iiii
i
ii
ii
ii
ii
ii
ii
ii
iiii
i
i
,0
),[,))((
)(2
),[,1
),[,))((
)(2
)(
32
2313
3
21
13
13
2
2
12
1
21
2
9
7/27/2019 ch5_4.doc'kfxzghj,
10/18
=
=
=
=
=
=
=
=
=
+
++++++
++++
++
+
+
++
+++
++
pointsdataotherallat0
0)(,2
))((
)(2)(
2)(,
2)(
2
))((
)(2)(,0)(
2
3
2
132313
232
2
13
2
2
2
1
2
221
11
22
i
ii
iiiiii
ii
ii
ii
ii
ii
ii
iiiiii
ii
iiii
B
xBxxxxxx
xxxB
xxxB
xxxB
xxxxxx
xxxBxB
(5.2.2)
The second part of line one in Equation 5.2.2 is exactly the first part of line two,
so2
iB is continuous at 1+ix . The second part of line two is also exactly the first part of
line three, thus2
iB is continuous at 2+ix . The first part of line one equals line four and
2iB is continuous at ix . The second part of line three equals line four and
2iB is
continuous at 3+ix . Line 4 also means2
iB is continuous at all the other data points.
So,2
iB is continuous at all the data points. From Equation 5.2.1, we know2
iB
is continuous at all the locations between the data points. Thus2
iB is continuous at any
x and )(2 xBi has1C continuity. Any linear combination of )(
2 xBi s also has1C
continuity.
It can be shown that for any k
=
=i
k
i xB 1)( (5.2.3)
10
7/27/2019 ch5_4.doc'kfxzghj,
11/18
For 0=k and for any x , some m can be found such that [ )1, + mm xxx . Of allthe )(
0xBi with = ,i , only )(
0 xBm will be nonzero, thus
=
==i
mi xBxB 1)()(00
For 0>k , consider a function f which is a linear combination of )(xB ki
=
=i
k
i
k
i xBDxf )()(
Note here that the proof of Equation 5.2.3 does not requirek
iD to be arbitrary, but rather
1=kiD is enough.k
iD is used to illustrate its relationship with lower order terms.
=
+
+++
++
+
+
= ik
i
iki
kik
i
iki
ik
i xBxx
xxxBxx
xxDxf )()()(
1
1
11
11
=
+
+++
++
=
+
+
=
i
k
i
iki
kik
i
i
k
i
iki
ik
ixB
xx
xxDxB
xx
xxD )()(
1
1
11
11
Denoting 1+= ij , the second term above can be rewritten as
=
+
+
=
+
+
+
+=
+
+
=
=
i
k
i
iki
kik
i
j
k
j
jkj
kjk
j
j
k
j
jkj
kjk
j xBxx
xxDxB
xx
xxDxB
xx
xxD )()()( 11
1
1
1
1
1
1
So, f can be rewritten as
=
+
+
=
+
+
=
i
k
i
iki
kik
i
i
k
i
iki
ik
ixB
xx
xxDxB
xx
xxDxf )()()(
1
1
1
=
+
+
+
+
=
i
k
i
iki
kik
i
iki
ik
i xBxx
xxD
xx
xxD )(11
Introducing
iki
kik
iiki
ik
i
k
i xx
xxD
xx
xxDD
+
=
+
+
+
1
1
(5.2.4)and we have
=
=
i
k
i
k
i xBDxf )()(11
11
7/27/2019 ch5_4.doc'kfxzghj,
12/18
which means any function f that can be written as a linear combination of )(xBk
i can
also be written as a linear combination of )(1xB
k
i
. Equation 5.2.4 is the relationship
between their respective coefficients.
The above equations are recursive, )(xf can be written as combinations of
)(,),(),(021xBxBxB i
k
i
k
i
while k is decreased to 0,,2,1 kk . In the case k
is eventually reduced to 0, we get
=
=i
iixBDxf )()( 00
and0
iD can be calculated using the recursive scheme starting fromk
iD . So, ifk
iD are
known for all = ,i ,0
iD would be known for all = ,i .
Now, considering a specific function )(xf , where itsk
iD = 1 for all = ,i ,
the goal here is to find out what is )(xf exactly. In Equation 5.2.3, it is stated that)(xf is exactly 1. Now we can prove that.
From Equation 5.2.4, we get for any i
11
1 =
+
=
+
=
+
+
++
+
+
iki
ki
iki
i
iki
kik
i
iki
ik
i
k
ixx
xx
xx
xx
xx
xxD
xx
xxDD
11
1
11
11
1
1
12 =
+
=
+
=
+
+
++
+
+
iki
ki
iki
i
iki
kik
i
iki
ik
i
k
ixx
xx
xx
xx
xx
xxD
xx
xxDD
Repeating this process, we eventually get
11
1
11
11
1
1
10 =
+
=
+
=
+
+
+++
++
++ ii
i
ii
i
ikki
kki
i
ikki
i
iixx
xx
xx
xx
xx
xxD
xx
xxDD
which means
1)()()( 000
=
=
===i
i
i
iixBxBDxf
where at the second step in the above equation, the result for 0=k is used. Thus,Equation 5.2.3 has been proven.
Example 5.2.1 Illustrative example to demonstrate Equation 5.2.3
Say [ ]10 ,xxx , then
12
7/27/2019 ch5_4.doc'kfxzghj,
13/18
[ ]
[ ]
1
)(
1
)(
)(
)(
)(
))((
)(
))((
)(
))((
)()(
))((
)(
))((
))((
))((
)(
)(
))((
)(
)(
))((
)()(
))((
))((
)(
))((
)(
0
)()()()(
0
)()(
01
01
01
0
01
1
02
0102
0
0102
2
0
0102
02
11
0111
1
0111
11
0111
2
1
2
0
0102
2
0
2
1
0102
02
0111
11
2
2
0111
2
1
2
1
2
0
2
1
2
2
2
3
2
=
+
=
+
=
+
+
+
+
+
=
+
=
+
+
+
+
+
=
++++++=
=
xxxxxx
xx
xx
xx
xx
xxxxxxxx
xx
xxxx
xx
xxxx
xxxx
xxxxxxxx
xx
xxxx
xxxx
xxxx
xx
xB
xxxx
xx
xB
xxxx
xxxx
xxxx
xxxx
xB
xxxx
xx
xBxBxBxBxBxBi
i
5.3. Building Second Order B-Splines
Considering a data set: ( )niyx ii ,,2,1,, = , we wish to find the B-spline of
the 2nd
order. First, write the spline function as a linear combination of )(2
xBi
=
=i
iixBDxs )()(
2
2 (5.3.1)
where the index i goes from to in general and is consistent with what we usein Section 5.1. We should view the data set ( )niyx ii ,,2,1,, = as part of a data setthat has an infinite number of knots. As will be seen later, the rest of the infinite data set
is of no use to us for the current task. Also note, the subscripts on 2B are shifted, e.g.,
)(2
2xBD ii is used here for the same reason mentioned for the )(
1 xBi case.
As stated before, the support of this spline covers only three intervals. Soto find the splines that have contributions in the data set range, we need to find the left
most spline that has contributions to the 1st data interval and the right most spline that
contributes to the last data interval. As seen from the Figure 5.3.1, they should be
)(21 xB and )(2
1 xBn , respectively. So the contributing B2s are
2
1
2
0
2
1 ,,, nBBB .
Hence the required range for 2iiBD is 11 + ni . Equation 5.3.1 can then berewritten as
13
7/27/2019 ch5_4.doc'kfxzghj,
14/18
+
==
1
1
2
2 )()(n
i
ii xBDxs(5.3.2)
Figure 5.3.1.
The number of iD to be solved is 1+n , which is one more than the number of
knots (or data points). Right away, we know the 0C continuity can give us n conditionsand one more condition is needed.
To apply the 0C continuity conditions, we need to calculate the value of )(xs at
the knots. Looking at point ix in Figure 5.3.1, it is clear that only )(2
2 xBi and
)(2
1 xBi are nonzero. Thus
iiiiiiii yxBDxBDxs += + )()()(2
11
2
2 (5.3.3)
14
x1
x0
x2
x-1
xn-2
xn-1
xn
xn+1
Out of rangeOut of range
Data set
2
1B2
1nB
7/27/2019 ch5_4.doc'kfxzghj,
15/18
From Equation 5.2.1, setting 2 ii , and letting iii xxh = +1 , we get
)(
)(
))((
)()(
1
11
1
111
2
12
2
++
++
+
+
=
=
i
ii
i
ii
ii
iiii
iiii
h
xx
h
xx
xx
xxxx
xxxB
1
2
2 )(
+=
ii
i
iihh
hxB (5.3.4)
Similarly setting 1 ii in Equation 5.2.1 gives
)(
)(
)(
))((
)(
))((
)(
1)(
11
1
2
2
11
11
1
2
2
+
+
+
+
+
+
=
+
=
ii
ii
ii
iiii
ii
iiii
ii
ii
xx
xx
xx
xxxx
xx
xxxx
xxxB
1
12
2 )(
+
=ii
iii
hh
hxB (5.3.5)
Hence from Equation 5.3.3 - 5, we get
i
ii
i
i
ii
i
i yhh
hD
hh
hD =
++
+
+ 1
1
1
1
iiiiiii yhhDhDh )( 111 + +=+ (5.3.6)
where iii xxh = +1 . Equation 5.3.6 contains n equations and there are 1+n unknowns.Certainly, we can assign a value to 1D and use the above equation as a recursive scheme
to calculate all the rest of the coefficients. The value of 1D can be zero, or can be
calculated by some other methods (e.g., Cheney and Kincaid, 1994).
The values of 0x and 1+nx need to be assigned. If we define h-ratio11
0 :
=n
n
h
h
h
h
, then these can be set by the user. Usually they are assigned such that h-ratio 1:1= .
Example 5.3.1. Given 3 data points ( )3,2,1,, =iyx ii , solve for constants D.
15
7/27/2019 ch5_4.doc'kfxzghj,
16/18
( )
( )
( )301
3234233
2123122
1012011
,,givenunknowns3inequations3
:3
:2
:1
hhD
yhhDhDhi
yhhDhDhi
yhhDhDhi
+=+=
+=+=
+=+=
To solve, we must choose
Constraint like 01 =D or other.
To find 30 ,hh , vary the h-ratios2
3
1
0 ,h
h
h
hthat, in concert with 4,,1, =iDi ,
yield tautness to the spline.
The algorithm of the MATLAB code bspline2.m follows
(1) Input x where the interpolation value )(xsy = is needed;(2) Check to see ifx is out of range; if yes, abort the program; if no, proceed;(3) Calculate or assign 1D (See Cheney and Kincaid, 1994);
(4) Calculate iD (Equation 5.3.3);
(5) Find the data interval where x belongs;(6) Calculate y according to Equation 5.3.2.
Example 5.3.2. Show 2nd order B-splines for data sets in Examples 4.1.1 and 4.1.2
Figures 5.3.1 and 5.3.2 show the 2nd order B-splines for the data sets in Examples
4.1.1 and 4.1.2, respectively. Three sets of 0h and nh are used.
16
http://www.esm.psu.edu/courses/emch407/njs/m-files02/bspline2.mhttp://www.esm.psu.edu/courses/emch407/njs/m-files02/bspline2.m7/27/2019 ch5_4.doc'kfxzghj,
17/18
0 1 2 3 4 5 6 7 8 9 10-5
0
5
10
15
20
x
y
Quadratic B-Spline
d* => d calculated perCheney and Kincaid (1994)
h-ratio = 100:1 and d*
h-ratio = 1:1 and d = 0
h-ratio = 10:10 and d*
h-ratio = 1:1 and d*
Figure 5.3.1 Second Order B-spline for dataset from Example 4.1.1.
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-2.5
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
2.5
x
y
Quadratic B-Spline
h-ratio = 1:0.1 and d*
h-ratio = 1:1 and d*
h-ratio = 1:10 and d*
h-ratio = 1:1 and d = 0
d* => d calculated per
Cheney and Kincaid (1994)
Figure 5.3.2 Second Order B-spline for data set from Example 4.1.2.
17
7/27/2019 ch5_4.doc'kfxzghj,
18/18
We know )(xs in Equation 5.3.2 has 0C continuity, but what about 1C
continuity? Recalling from Section 4.2, the quadratic spline has 1C continuity. What
about )(xs in Equation 5.3.2? The answer is yes. Since )(xs is a linear combination of
the )(2xBi s which have
1C continuity, )(xs has 1C continuity too.
In general, )(xBk
i has continuous derivatives up to order 1k (see Cheney and
Kincaid, 1994).
Conclusion
In conclusion, we discovered that the B-splines:
(1) Have 0C continuity for any order.
(2) The first order spline requires no information in addition to the data points.
(3) The second order spline requires three additional pieces of information (one more
interval on each end of the data set and, say, 1d ) regardless of the number of data
points.
(4) The second order spline has1
C continuity.
Reference
Cheney, W. and Kincaid, D., Numerical Mathematics and Computing, Third Edition,Brooks/Cole Publishing Company, 1994.
18