This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
= 0. def
Points and vectors in space are modeled by ordered triples p -
(pl,p2,p3).
The length formula is [[p[[ de__f V/Pl2 + p~ + p~. Two nonzero points p and q and the origin 0 = (0, 0, 0) define a plane, and the angle at 0 between the vectors to p and q can be measured in this plane. If this angle is denoted by 0, it may be computed from Equation 2.1, where now (p, q) def -- Pl ql q- P2q2 + P3q3. Notice that in all of these examples, [Ipll = v/
. 2.1.1 def E p ( x k ) q ( X k ) , k--0 where {Xk} is the set of Chebyshev nodes defined in Equation 4.9. This inner product is obviously linear and Hermitean symmetric. It is nondegenerate, since (p, p> - 0 only if p has N + 1 distinct roots, which forces p - 0 since the degree of p E P is N or less. For the polynomials Tn, T,~ with 0 < n, m < N, we get
Euclidean
space
While not readily visualized, space can be generalized to a set of ordered lists of more than three real numbers. Fix a positive integer dimension N and consider R N, the set of ordered lists of N real numbers. Elements p = ( P l , . . . ,PN) and q -- ( q l , . . . , qN) can be combined componentwise, and they have lengths and angles analogous to points and vectors in more easily visualized systems. Namely, •
P + q def
• cp -
def -
( P I q- q I , . . . , P N
+ qN);
( c p l , . . . , cpN), for any real number c;
2.1.
VECTOR
25
SPACES
Vertex
Coordinates
Po
(0,0,0)
Edge to P1, P2, P4 P3, P5 P3, P6 P5, P6
(0,0,1) (0,1,0) (1,0,0)
P1
P2 P4
Vertex P3
P5 P6
P7
Coordinates (0,1,1) (1,0,1) (1,1,0) (1,1,1)
Edge to P7
P7 P7
Table 2.1: Vertices and edges of the three-dimensional unit cube. Vertex
Coordinates
Edge to
Vertex
Qo
(0,0,0,0) (0, 0, 0,1) (0, 0,1, 0) (0,1,0,0) (1,0,0,0) (0,0, 1, 1) (0,1,0,1) (0, 1, 1,0)
Q1, Q2, Q4, Q8 Q3, Q5, Q9 Q3, Q6, Qlo Q5, Q6, Q12 q9, ql0, Q12 Q7, Qll O7, O13 q7, q14
Q9 Qlo Q12 Q7 Qll Q13 Q14 q15
Q1
Q2 Q4 Os Q3 Q5 Q6
Coordinates (1,0,0,1) (1,0,1,0) (1,1,0,0) (0,1,1,1) (1,0,1,1) (1,1,0,1) (1,1,1,0) (1,1,1,1)
Edge to Qll, Q13 Qll, Q14 Q13, Q14
Q15 Q15 Q15 Q15
Table 2.2: Vertices and edges of the four-dimensional unit cube.
• lipli doj V#;~I + . . . + ; ~ ; • (p,q}
def
-- Pl ql + " " "P N q N .
The set R N equipped with these operations will be called N - d i m e n s i o n a l E u c l i d e a n space, or E u c l i d e a n N - s p a c e . Note that [[Pl] = v/(P,P), and (p,q) = 1
2
(tip + qii - I L p - qli
2
).
For example, the eight corner vertices of a unit cube in space are listed in Table 2.1, numbered by reading their coordinates in binary. There are 12 edges, one joining each pair of vertices that differ in exactly one coordinate: POP1, POP2, PoP4; P I P 3 , P1P5; P2P3, P2P6; P4P5, P4P6; P3PT; P5P7; P6PT. Similarly, the 16 corner vertices and 32 edges of a unit cube in Euclidean 4-space are listed in Table 2.2. To count edges, we imagine making the 4-cube by sweeping a 3-cube along a fourth axis. That creates eight new edges, joining corresponding vertices of the front and back 3-cubes. The front and back 3-cubes have 12 edges each, for a total of 32. Generalizing R N is the set C N of ordered lists of N complex numbers. In this case, the H e r m i t e a n i n n e r p r o d u c t is used:
(p, q)
def _ -
Plql +'''PNqN.
(2.2)
The complex conjugate on the first vector insures that liPll def v/(p ' p) is a nonnegative real number. C N with the Hermitean inner product will be called c o m p l e x N - d i m e n s i o n a l E u c l i d e a n space, though it may also be regarded as 2N-dimensional Euclidean space simply by treating the real and imaginary parts of each coordinate as separate coordinates in themselves. Note that the real and imaginary parts
C H A P T E R 2. SPACE A N D L I N E A R I T Y
26
of t h e complex-valued inner p r o d u c t are ~ (p, q) 1
"~(P,q)-a(lliP
+qll
2
- lip-ql]
2
a1 (liP + qll 2 - l i p
- qll 2) and
),s°
1
i
(p, q) _ 4 (lip ÷ ql[2 _ lip _ ql[2) ÷ 4 ([lip + ql[2 - I l i p - ql12) • This is s o m e t i m e s called the polarization identity. Note t h a t t h e i m a g i n a r y p a r t vanishes if t h e coordinates of p, q are all purely real or all purely imaginary. Vectors in R N or C i are s o m e t i m e s displayed as columns of n u m b e r s , or column vectors, such as p-
;
q-
.
PN
T h e adjoint p* def (/51
qN
...
P N ) of a c o l u m n vector p is t h e row vector filled w i t h the complex conjugates of t h e coordinates of p. T h e H e r m i t e a n inner p r o d u c t can be w r i t t e n in t e r m s of m a t r i x multiplication, defined in E q u a t i o n 2.41 f u r t h e r on, and this adjoint: (p, q) -- p*q. (2.3)
This is also a special case of E q u a t i o n 2.47. F r o m this point on, we will use E N to d e n o t e b o t h real a n d complex N dimensional Euclidean space, with the u n d e r s t a n d i n g t h a t E N - R N if the coordinates are real n u m b e r s a n d E N - C N if t h e y are complex numbers.
2.1.2
Abstract
vector
spaces
A vector space is the f u r t h e r a b s t r a c t i o n and generalization of E u c l i d e a n N - s p a c e . It consists of a set X of vectors t h a t can be a d d e d t o g e t h e r a n d multiplied by scalars (real or complex numbers) to form linear combinations, which are again elements of X. For example, if x, y are vectors in X a n d a a n d b are two fixed scalars, t h e n the linear c o m b i n a t i o n a x + by also belongs to X. It follows by i n d u c t i o n t h a t a linear c o m b i n a t i o n of finitely m a n y vectors from X m u s t also belong to X. T h e following rules, as in Euclidean space, apply to all vectors x, y, z a n d scalars a, b: Vector Space Axioms Associativity: Commutativity:
x + (y + z) = (x + y) + z. x + y - y + x.
I d e n t i t y : T h e r e is a unique element 0 c X called the identity, satisfying x + 0 = 0 + x = x for all x E X. I n v e r s e s : E a c h x C X has a unique inverse - x fying x + ( - x ) = - x + x = 0. Distributivity:
def
-
( - 1 ) x C X , satis-
a ( x + y) = a x + ay.
Scalar multiplication
associativity:
(ab)x = a(bx).
2.1.
VECTOR
SPACES
27
A subspace Y of a vector space X is any n o n e m p t y subset Y c X which is closed u n d e r a d d i t i o n a n d scalar multiplication: u + cv c Y for any u, v E Y a n d any scalar c. For example, X is a subspace of itself• T h e zero subspace {0} is a n o t h e r example• E v e r y subspace Y c X contains 0, since we m a y take c = - 1 a n d u = v. Likewise, t a k i n g u = 0 a n d c = - 1 proves t h a t - v c Y w h e n e v e r v c Y . T h e s u m of subspaces Y , Z of a vector space X is t h e set of sums: Y + Z def {y + z"
y E Y , z C Z}.
(2.4)
We can have sums of m a n y subspaces, such as Y1 + Y2 + " " + y m . If X is a vector space a n d { V l , . . . , v ~ } is any finite set of vectors from X , t h e n t h e linear span span { V l , . . . , vn} is a subspace of X , consisting of all linear c o m b i n a t i o n s of V l , . . . , Vn"
•
•
•
aivi
--
"
al,
• • • ,
a n
(2.5)
a r e scalars.
i--1
We observe t h a t span {Vl,
• • • , Vn
}
--
(2.6)
span {v I } -~- • • • nt- span {Vn }.
A set of v e c t o r s {Vl, • • ' , Vn} in a vector space X is called linearly dependent if t h e r e are scalars a l , . . . , a n , not all zero, for which a l V l + - • . + anVn -- O• This nontrivial linear c o m b i n a t i o n r e p r e s e n t i n g zero is called a dependency relation. Otherwise, if no such relation exists, t h e n we say t h a t t h e set { V l , . . - , vn} C X is linearly independent. Given linearly i n d e p e n d e n t vectors { V l , . . . , vn} a n d told t h a t a l V l + .• "+anVn -- 0 for scalars a l , . . . ,an, we m a y conclude t h a t al . . . . . an - 0. T h e scalars C l , . . . , Cn in t h e linear c o m b i n a t i o n x - ClVl -t- . • . -~-CnVn C X are called t h e expansion coefficients of x in t e r m s of t h e set { V l , . . . , vn}. Linear i n d e p e n d e n c e g u a r a n t e e s t h a t expansions are unique: if x ClVl + . . • + cnvn l C~Vl + . . . + CnVn, we m a y conclude t h a t ck - c~ for all k - 1 , . . . , n. T h e N standard basis vectors of E N are linearly independent" 1 def e l
--
0
0 •
def ,
e2
--
0
0
1 •
def ,
.•.,
e N
0
--
.
0
.
(2.7)
i
Here en has a single 1 in row n, a n d zeroes in all o t h e r rows. T h e vector ale1 + • . . + a N e N has an at position n, a n d linear i n d e p e n d e n c e is an i m m e d i a t e conclusion. A m o r e c o m p l i c a t e d e x a m p l e is: 1 fl
def --
1
0 •
0
def ,
f 2 -
1 •
0
1 ,
...,
fg-
def
1 .
i
.
(2.8)
CHAPTER
28
2.
SPACE AND LINEARITY
Thus fl = e l , f2 - e l + e2, and fN = e l + e2 + . - - + eN. If a l f l + ' ' - + a N f N -- 0, we i m m e d i a t e l y conclude t h a t a N ~ 0, SO in fact a l f l + . . . + a N - l f N - 1 -- O. B u t t h a t inductive step reduces the p r o b l e m to the case of N - 1 vectors, and the case N = 1 is evidently true, so linear i n d e p e n d e n c e follows. T h e d i m e n s i o n of a vector space X is the largest n u m b e r of vectors in any linearly i n d e p e n d e n t subset of X. If there are linearly i n d e p e n d e n t sets of N vectors for any N , t h e n the space is called infinite dimensional.
Finite dimensions An N - d i m e n s i o n a l vector space X must contain a set { b l , . . . , bN} of N linearly i n d e p e n d e n t vectors. Any such set is called a basis for X.
T h e o r e m 2.1 Suppose ( b l , . . . , bN} is a basis f o r the N - d i m e n s i o n a l vector space X . T h e n each vector x c X can be expressed as a linear combination of vectors {bn} in one and only one way. That is, f o r each x C X there is a unique set of N scalars C l , . . . , CN , depending on x, giving the expansion N X--
E cnbn. n--1
Proof: For existence, suppose t h a t there is a vector x C X not expressible as such a linear combination. We can be sure t h a t x ~= 0 - ~ n Obn, and so {x} U ( b l , . . . , bN} C X m u s t be a linearly i n d e p e n d e n t set of N + 1 vectors. This contradicts the a s s u m p t i o n t h a t X is N-dimensional. T h e uniqueness of the expansion follows from the linear i n d e p e n d e n c e of the set {bn}" if x - E n c n b n - ~-~.n C~nb n ' t h e n ~-~n(c" - c n ) b n - O, so C~n -- Cn for all n- 1,...,N. [:] Not surprisingly, N - d i m e n s i o n a l Euclidean space has dimension N , but this fact requires proof. T h e N s t a n d a r d basis vectors are linearly i n d e p e n d e n t , so the dimension is at least N , but we must show t h a t no larger linearly i n d e p e n d e n t set exists. Since Euclidean N - s p a c e is span { e l , . . . , e N } , it suffices to show:
T h e o r e m 2.2 Suppose that V l , . . . , VN are N vectors in some vector space. T h e n any set of N + 1 or more vectors in span { V l , . . . , VN} m u s t be linearly dependent. Proof: We first note t h a t if all sets of M vectors are linearly d e p e n d e n t , t h e n any set of more t h a n M m u s t also be linearly dependent: the d e p e n d e n c y relation for the first M can be p a d d e d with zero coefficients for the r e m a i n i n g vectors. We proceed by induction on N . For N - 1, given x , y c span {v}, write x - a v and y - by. I f a , b are not b o t h zero, we can put a ~ - b and b~ - - a to get a~x + b~y - ( a b - ba)v - 0 with a ~, b~ not b o t h zero. Otherwise if a - b - 0, t h e n a ~ - b~ - 1 gives a d e p e n d e n c y relation. Thus, every set of two (or more) vectors in the span of a single vector is linearly d e p e n d e n t . For N _> 2, we m a k e the inductive hypothesis t h a t every set of N or m o r e vectors in the span of N - 1 vectors is linearly d e p e n d e n t . Now suppose t h a t the
2.1. VECTOR SPACES
29
N + 1 vectors W d J { W l , . . . , WN+I} belong to span { V l , . . . , VN}. Then we may write Wl
--
a(1, 1)Vl + . . . + a(1, N)VN,
WN
z
a(N, 1)vl + . . . + a(N, N)vg, a(N + 1, 1)Vl + . . . + a(N + 1, N)vN,
WN+ 1
where each a(i,j) is a scalar. If the last column of scalars is all zero, namely a(i,N) = 0 for i = 1 , . . . , N + 1, then in fact W C s p a n { v l , . . . , V N _ l } and must be linearly dependent by the inductive hypothesis. Otherwise, we may suppose, by renumbering if necessary, that a(N + 1, N) ¢ 0, and eliminate the VN terms as follows: W ' def { t a(i,N) } -
w i-wi-
a(N+I,N)WN+I"
i-l,...,N
.
(2.9)
This set W ' C s p a n { v 1 , . . . , VN-1} is linearly dependent by the inductive hypothesis. But any dependency relation ClW~ + . . . + CNW'N -- 0 for W ' gives a dependency relation ClWl + .-. + CNWN -Jr-bWN+I 0 for W , where b = :
- E i cia(i, N ) / a ( N + 1, N).
[]
Any subspace of an N-dimensional vector space X is finite dimensional with dimension at most N. For example, the set of vectors in E N with zero first coordinate is an ( N - 1)-dimensional subspace of E N. Vectors e 2 , . . . , eN are a basis for that subspace. Norms
A norm in a vector space X is a nonnegative real-valued function x H the following: Norm
S u b l i n e a r i t y : ]lx+yll and any scalar a.
<_ lixll+llyll
IlxI] satisfying
Axioms
and
Ilaxl[- lal []xlL for any x , y
CX
N o n d e g e n e r a e y : Ilxll -- 0 if and only if x = 0, the additive identity, or zero vector; otherwise, IIxLI > 0. Any N-dimensional vector space X can be equipped with a norm. Start by fixing a basis b l , . . . , bN, so that any x E X is expressible in one and only one way as X - EnN=I x(n)bn. Then, let
Ilxlll
def
-
Ix(1)l +-..
+ Ix(g)l,
(2.10)
where x = }-~-nx(n)bN is the unique expansion of x. It is a straightforward exercise to show that this satisfies the norm axioms. Alternatively, we can mimic the formula from Euclidean N-space: ilxl[2 def V/ix(1)l: + . . . + ix(N)12.
(2.11)
C H A P T E R 2. SPACE A N D L I N E A R I T Y
30
In fact, for any p _> 1, there is a so-called p-norm:
Ilxllp de_f (ix(1)lP + . - . +
ix(N)lp)l.
(2.12)
' ix(N)l}.
(2.13)
The formula extends to the limit p --, oc: ilX]lcc de f m a x { l x ( 1 ) r , . . .
But the choice of norm does not matter too much in a finite dimensional vector space. For example, the norms I1" II1, rJ. 112,Ir. I1~ defined on E N in terms of the standard basis vectors {en} satisfy the following system of inequalities:
IlXl[1 ~ ~ IlXll2 [IXl]l < N Ilxllo~ Ilxll2 _< v/Nllxll~
IlXll2 < [IX[ll Ilxllo~ < [[xl[1 I[xl[o~ _< Ilx[]2
(2.14) (2.15) (2.16)
In fact, all norms on an N-dimensional vector space satisfy similar inequalities: T h e o r e m 2.3 Any two norms II " lip and I]" ]lq for an N-dimensional vector space X are comparable. That is, there are positive numbers A, B, C, D such that for all xCX,
AlJxll~ _< Ifxll~ ___ BIIxlJ~,
and
Clfxllq __ Ilxll~ < Dlfxll~.
Proof: Fixing a basis { b n : n = 1 , . . . , N} C X, we will show that the norm [1" II~ defined by Equation 2.13 is comparable to all others. Let I1" II be any other norm on X. Then by its sublinearity, IIx]l -< E n=l
IIx(n)bnll- E n=l
Ix(n)l Irbnll -< (l
I]bn[I
.
(2.17)
n=l
So Ilxll ~ BIIxllo~ for B = Ilblll + " " + IIbNll > 0. We know that B > 0 because I1" II is nondegenerate and basis vectors are nonzero. For the other inequality, suppose toward contradiction that there is no A > 0 such that AllxlI~ <_ Ilxll for every x. Then there must be an infinite sequence of vectors {Xl,X2,...} C X with the property that rlxkll~ - 1 for all k = 1, 2 , . . . , but Ilxk If -~ 0 as k -~ o~. We may suppose without loss of generality that the expansion coefficients ( X k ( 1 ) , . . . , x k ( N ) ) Of Xk -- EnN=I x k ( n ) b n , k -- 1, 2, ... are real numbers and define a point in R N, since N complex scalars are the same as 2N real scalars. These real coordinates are at most 1 in absolute value, so {xk : k = 1, 2 , . . . } gives an infinite sequence of points confined to the unit hypercube [-1, 1] N c R N. Cutting this hypercube in half along each axis gives 2 N subcubes, at least one of which must contain infinitely many 1 of the points {Xk}. For notational convenience, let us suppose without loss of generality that it is the subcube [0, 1] y of nonnegative 1 How can we be sure that such a packed subcube exists? W h y does this proof fail in infinite dimensional space?
2.1. VECTOR SPACES
(o,1)
31
~,
(1,1)
j--o
j=3
,/ j=4
!~!i!~!~!!~!~!ii!~!~!i~!i~!~:!~i~ii!~i~i~!~i~!~!J~i!i~!;i~!i~i~i!~i~i~!~!~i~i!;i~i~i~i~!~i~!~i~!i;!~i~i~;~i
(0,o) f
Figure 2.1: Nested subcubes at stages j dimensional case of T h e o r e m 2.3. coordinates. Call this the
-
0, 1,2,3,4, to illustrate the two-
stage 0 subcube, and let Y0 6 R N be one of its points,
say xk(0).
We next define the stage j subcube for j > 0 by cutting the stage j - 1 subcube in half along each axis and picking one of its 2 N subcubes, making sure t h a t the chosen one contains infinitely many of the points {xk}. An example with N = 2 and j = 0, 1, 2, 3, 4 is depicted in Figure 2.1. We define yj to be one of those points, say xk(j). We can make the choice such t h a t k(0) < k(1) < k(2) < .-.. Now notice t h a t the n th coordinates of the points Y0, y l , y 2 , . . , form a Cauchy sequence, since the first j binary digits of yj(n), yj+l (n),... are all the same. By the completeness of the reals, T h e o r e m 1.9, there is a unique real number y(n) = limj__,~ yj(n) for n - 1,2...,N. P u t t i n g x def - ~ =Nl Y (n)b~ E X, we see t h a t Ilxll~ Ilxkll~ = 1 for all k, including k = k(j), and
I IIxk<j>ll~ -Ilxtl~ [ ~ IIx~<j>- xll~ -- l <max n
1 since
lyj(n)-y(n)l--~o,
as j -+ ec. Therefore x ¢- 0. On the other hand, we have the contradiction Ilxll - 0, since Ilxk(j)II-+ 0 as j -+ ec by assumption, and
I Irx~(/)lr- Ilxll I ~
liNk(j) -
xll ~ BIIx~(/) - xll~ - B max
l
lYj(~)
-
Y(~)I -~ 0,
as j --+ oc, using Inequality 2.17. Hence II" II cannot be arbitrarily small relative to I1" II~" there must be some A > 0 such t h a t AIDxllo~ _< IIxPI for every x. To finish the proof, given any two norms I1"lip and I]" lie we find Ap, Bp, Aq, Bq > 0 such t h a t
Apllx[Io~ ~ Ilxllp ~ Bvllx[l~,
and
Aqllxl[~ ~ Ilxllv ~ Bvllxll~.
CHAPTER 2. SPACE AND L I N E A R I T Y
32
B u t t h e n A = Aq/Bp, B = Bq/Ap, C = Ap/Bq, and D = Bp/Aq satisfy t h e theorem• [] If X is an N - d i m e n s i o n a l vector space a n d B = {bn : n = 1 , . . . , N } C X is a basis, t h e n every x = Y~'~nc ( n ) b ~ C X corresponds to one a n d only one c = (c(1), • • •, c(N))C EN: X
(
B
)
n N•
(2.18)
Having the freedom to choose B can sometimes simplify calculations in X, which in practice must be done by m a p p i n g vectors x to points in EN•
Infinite d i m e n s i o n s We will only consider a simple kind of infinite dimensional vector space X , one which has a n o r m a n d a basis B = ( b n : n = 1, 2 , . . . ) C X satisfying the following:
Schauder Basis A x i o m s Linear i n d e p e n d e n c e : Any finite subset of the vectors in B is linearly independent.
C o m p l e t e n e s s : E a c h x E X has a B - e x p a n s i o n x -
E
c(n)bn.
n
U n i q u e representation: If x = E n c ( n ) b n a n d x = E n c ' ( n ) b n , t h e n c(n)= c'(n) for all n• C o m p l e t e n e s s in an infinite dimensional vector space X is i n t e r p r e t e d to m e a n t h a t for every x c X, there is a sequence {c(n) : n = 1, 2,•• •} of expansion coefficients such t h a t N
lira N---+c~
x-
Ec(n)b~
- O•
n=l
Alternatively, a set of vectors B c X is called dense in X if, for every fixed vector x E X a n d ~ > 0, t h e r e is a finite linear c o m b i n a t i o n x~ of vectors in B satisfying ]ix - x~l] < ~• It is clear t h a t a Schauder basis B is dense, but a set which is not a basis m a y also be dense. We m a y e x t e n d the definition of linear span to a r b i t r a r y subsets of a r b i t r a r y vector spaces X: for any B C X,
spanB
a~_f
a ( n ) b n " N _> 0; b~ E B, a(n) scalar, all 1 _< n _< N . .
(2.19)
n--1
It is easy to verify from the vector space axioms t h a t span B c X. This definition agrees with E q u a t i o n 2.5 for finite sets B, a n d yields all finite linear c o m b i n a t i o n s of elements of B in the general case. Notice t h a t span X = X. Different n o r m s for an infinite dimensional X need not be comparable, so a fixed n o r m must be chosen before t h e Schauder bases axioms can be verified. Also, t h e ordering of Schauder basis vectors is i m p o r t a n t in the infinite dimensional case since the same vectors t a k e n in a n o t h e r order m a y lose the completeness property. If a
2.1.
VECTOR
33
SPACES
set of vectors is a Schauder basis in every order, then it is called an u n c o n d i t i o n a l S c h a u d e r basis.
Any subset of a Schauder basis is linearly independent and has the unique representation property. However, proper subsets of Schauder bases are never complete. In an N-dimensional vector space, linear independence implies unique representation, and completeness requires taking no limits • [Ix -- E n N = l c(n)b~[I - 0 for any expansion, regardless of norm. Thus, every basis for a finite dimensional vector space is a Schauder basis. But this is not so in infinite dimensions. Consider the following examples, each of which generalizes Euclidean N-space: 1. g2, the space of square-summable infinite sequences x = {x(k) : k = 1, 2 , . . . } , namely, those for which c~ N E ]X(Tt)[2 de__f lim E Ix(n)12 N---~cx~ n=l n=l
is a finite number. We use the norm (3<)
Ilxll For example, x ( k ) -
de__f
E n=l
Ix( )l
1 belongs to e 2 , with ] l x l [ -~
(2.20) ~. v'-6
Addition is term by
term, and the constant zero sequence 0 de f {0, 0 , . . . } is the additive identity. The s t a n d a r d basis vectors in this space are sequences e~ whose terms are all zero except for en(n) = 1. It is easy to prove t h a t for any positive integer N, the vectors el, e 2 , . . . , eN are linearly independent. It is not much harder to show t h a t {en} is in fact a Schauder basis for g2. However, the set {el; gl, g2,...} defined by 1
1
gn = - e n - ~ e n + l , n n+l
n = 1, 2 , . . . ,
is linearly independent and complete but does not satisfy unique representation: el = gl + g2 + ' " ". 2. P o l y , the space of polynomial functions defined on the interval [-1, 1], such as p ( x ) - x 4 - 7rx 2 + 3. Addition is t e r m by term, and the constant zero polynomial 0 is the additive identity. The monomials 1 , x , x 2 , . . . , x ~ are linearly independent for any n, and form an unconditional Schauder basis in the norm [la(0) ÷ a(1)x + - . . + a ( N ) x N l ]
de__f v/[a(0)l 2 ÷ . . . + la(N)12.
(2.21)
It is left as an exercise for the reader to find a linearly independent and complete set of polynomials t h a t nonetheless fails to be a Schauder basis with respect to this norm.
CHAPTER 2. SPACE AND L I N E A R I T Y
34
J-~' 1 a 2
1/7
2/7
4/7
517
6/7
I
I
I
3/7
'~
I 1
a4 °
0
"
°
I
(k-1)/(n+l)
k/(n+l)
°
"
"
a 5
1
(k+l)/(n+l)
Figure 2.2: Left" Graph of the hat function hk. Right" Polygon graph of the piecewise linear continuous function E k = l a(k)hk, defined on [0, 1], for n - 6. n
3. Lip, the space of complex-valued continuous functions f = f(t), defined on the interval [0, 1], that satisfy a Lipschitz condition: there is some number C such that If(s) - f(t)l _< c I s - tl for all s, t c [0, 1]. Vectors in this space are added pointwise: [f + g](t) = f(t) + g(t). The constant zero function, f(t) = 0 for all t, is the additive identity. There is no maximal finite set of linearly independent functions in this space. Given any integer n > 0, there are n continuous hat functions hi,..., hn, as depicted at left in Figure 2.2, defined by 0,
hk(t) --
(n + 1 ) t - ( k - 1) (k+l)-(n+l)t
if t < if ~k - - 1 if ~ k
k-1
k+l
h--47 ° r t > < t <
--
< t< --
k
~+1," .
__ n + l ~
(2.22)
k+l
-
-
n+l"
Such functions satisfy a Lipschitz condition with C = n + 1. The superposition a(1)hl + ... + a(n)h~ is the piecewise linear function whose graph is the polygon passing through the points ( 0 , 0 ) , { ( ~ + l , a ( k ) ) • k - 1 , . . . ,n}, and (1, 0). An example is depicted at right in Figure 2.2. It is the zero function if and only only if a(1) . . . . . a(n) = 0. Since n can be as large as we like, L i p cannot be finite dimensional. In the norm II/ll
de__f ~ ~ 0 1
f (t) 2 dt,
(2.23)
the functions {cn: n = 0, 1 , . . . } by cn(t) = cos(Trnt) are a Schauder basis for Lip, although the proof of this fact is beyond our scope. 4. L2(R), also denoted just L e, is the space of square-integrable complex-valued functions f = f(t) defined at all t E R. Vector addition is pointwise, and the constant zero function is the additive identity, as in Lip. The norm is similar to the one in Lip:
,,f. d e f l f R , f ( t ) , 2 d t ,
(2.24)
2.1.
VECTOR SPACES
35
and a function f belongs to L2(R) if and only if Ilfll is finite. Thus the nonzero constant functions, and more generally the nonzero polynomials, are not members of L2(R). Since Ilfll 2 is called the energy of a function, L 2 is sometimes called the space of finite-energy signals. L 2, like Lip, is infinite dimensional. Since there is no continuity assumption, we may build a simple set of basis functions from the indicator function of the unit interval [0, 1): l(t) dJ
~ 1, [ 0,
if 0 < t < 1; ift<0ort_>
(2.25) 1.
Given any integer k, put ek(t) de f l ( t - k) to get the characteristic function of [k, k + 1). The functions {ek : k E Z} are clearly linearly independent in Le(R), and there are infinitely many of them. We can also introduce a scale index j and put ejk(t) de__f 2_J/el(2_Jt - k), which is normalized to guarantee II~jkll - 1. The set {ejk: j, k E Z} is dense in L 2, but it is clearly not linearly independent. However, the fixed-scale functions Ej = {ejk : k E Z} are linearly independent, and given a function f E L2(R) and c > 0, we can find a scale J and a function f j C span E j C L2(R) satisfying ] I f - fJll < c. 2.1.3
Inner
product
spaces
An inner product space X is a special kind of vector space in which there is also an inner product. This is a scalar-valued function on pairs of vectors u, v E X, denoted by (u, v}, that must satisfy the following: Inner Product Axioms H e r m i t e a n s y m m e t r y : For any u, v E X, (u, v} = (v, u}. If all coordinates and scalars are real numbers, this reduces to the ordinary symmetry condition (u, v) = (v, u}; N o n d e g e n e r a c y : If u E X and u ~- 0, then (u, u} ~: 0. Equivalently, ifuEXand (u, v} = 0 for all v E X, t h e n u = 0 ; L i n e a r i t y : For any u, v, w E X and any scalars c, d, (u, cv + dw} =
+ d in, w>. Hermitean symmetry implies that (u, u} is a nonnegative real number; nondegeneracy implies further that this real number is positive whenever u -¢ 0. Of course (0, 0} - 0. This allows us to define a nondegenerate derived norm by the formula
ilul clef 4{U, U}, just as in Euclidean N-space. By linearity and Hermitean symmetry, (cv + dw, u} - e
CHAPTER
36
2.
SPACE
AND
LINEARITY
Euclidean N-space, w h e t h e r real or complex, is an e x a m p l e of a finite dimensional inner p r o d u c t space. Any p r o o f using just the a b s t r a c t inner p r o d u c t axioms works for every N at once because no dimension N is specified. T h e r e are intlnite dimensional inner p r o d u c t spaces, too, such as the three examples i n t r o d u c e d previously: 1. T h e vector space g2 has an inner p r o d u c t
(x,y/ def
oo
(2.26)
k=l T h e derived n o r m is t h e same as the one in E q u a t i o n 2.20. 2. P o l y m a y be e q u i p p e d with the following inner product: (p, q)
p ( x ) q(x) dt,
de__f
(2.27)
1 V/1--X 2 where the integral is i n t e r p r e t e d as the limit of integrals on [ - 1 + e, 1 - e ] as e ~ 0+. T h e derived n o r m is different from, a n d not c o m p a r a b l e to, the one in E q u a t i o n 2.21. To see why, consider p ( x ) = x n. T h e n the E q u a t i o n 2.21 n o r m is [[pll = 1 for all n, whereas the change of variable x ~-- sin 0 yields (p, p) -
fl
x 2n 1 v/1 - x 2
dx -
/~ ~
sin an 0 dO -
2
(2n-1)" "" Tr (2n)!!
(2n)' " 7r, 22n(n!) 2
as e v a l u a t e d i n Zwillinger's S t a n d a r d M a t h e m a t i c a l Tables and F o r m u l a e , page 399, E q u a t i o n 633. B u t Stirling's a s y m p t o t i c formula n! ~ 2v/)--~-~(n/e) n as n ~ oc, which is also in Zwillinger on page 496, Section 6.11.7, gives t h e a p p r o x i m a t i o n (p, p ) ~ X / ~ / n as n ~ oc, so the derived n o r m of x n t e n d s to zero as n ~ oc. 3. T h e vector space L i p has an inner p r o d u c t
(U, V) def - ~01 u ( t ) v ( t ) d t ,
(2.28)
for u = u(t) and v = v(t). It is left as an exercise to prove t h a t this inner p r o d u c t is H e r m i t e a n symmetric, n o n d e g e n e r a t e , and linear. T h e derived n o r m is the same as the one in E q u a t i o n 2.23. 4. T h e vector space L 2 ( R ) has an inner p r o d u c t
(u , v) doff? -
u(t)v(t)dt,
(2.29)
oo for u = u(t) and v = v(t). E q u a t i o n 2.24.
T h e derived n o r m is the same as t h e one in
2.1.
VECTOR SPACES
37
There may be a choice of inner products in a vector space. For example, (p, q) = f l I p(z)q(z) dx is an alternative inner product for P o l y , and (x, y} - :;ely1 -~-17z2Y2 is another inner product in E 2. The inner product must be specified when the space is defined, but we will use the original choices unless we say otherwise. Two important inequalities hold for all inner product spaces, including L 2, Lip, P o l y , and ~2 as well as all finite dimensional Euclidean spaces: 2.4 Suppose X is an inner product space with inner product (., .) and derived norm [1.1. Then we have the following inequalities for all vectors u, v c X"
Lemma
Cauchy-Schwarz:
I(u, v ) l < Ilulb IIvLI;
Ilu + vii < Ilull + livll, (This is also called the triangle inequality.)
Minkowski:
Proof." For the Cauchy-Schwarz inequality" define a nonnegative real-valued function on real or complex scalars c by
g(c)
def Ilu - ~vll ~ -
(u - cv, u - cv> - Ilull ~ - c - ~
The inequality holds, with both sides zero, if v - 0. Otherwise, let c - (u, v}/ILv 12, which is a critical point g'(c) - 0 identifying the m i n i m u m of g. Since g(c) >_ 0 even at this c, we compute
0 < Ilull ~ - 21 [2 I [~ /ivll~ + flvll~
I i~. < ilullZllvll 2
Taking square roots on both sides gives the Cauchy-Schwarz inequality. For Minkowski's inequality, note that for any real or complex scalar c, c + ~ _< 21cl. Thus,
Llu + vii ~
-
Ilull ~ + + + Ilvll 2
~<
Ilull ~ + 2t < u , v > l +
<
Ilu I~ + 211ullllvll + Ilvll ~
Ivll ~ -
(llull + Ilvll) ~.
Take square roots again to complete the proof. In a real inner product space, the Cauchy-Schwarz inequality guarantees that <_ ]lu[I]]vl[ -< 1 , so that an angle 0 between nonzero vectors u and v may be defined by -1
COS 0 def
U, V}
Ilull Ilvll
~,
Ilu + vii 2 - I l u l l ~ +[vIL 2 + 21lull Ilvll c o s 0 ,
generalizing the Law of Cosines from two-dimensional Euclidean space.
38
C H A P T E R 2. S P A C E A N D L I N E A R I T Y
Orthonormal
bases
In any inner product space, vectors u, v are said to be orthogonal if (u, v> - 0. The zero vector is orthogonal to all other vectors, and no vector except 0 is orthogonal to itself. If Y is any subset of an inner product space X, then its orthogonal complement in X is a subspace, denoted Y ± and defined as follows: y±
de____f{X E X "
(X, y> - - 0 for all y C Y.}
(2.30)
For example, X ± - {0} and {0} ± - X. Also, i f 1 _< m < N and we let Y span { e l , . . . , era} C E N, then Y ± - s p a n { e r a + l , . . . , eN}. It is left as an exercise to prove the following facts: Lemma
2.5 Suppose Y is a subset of an inner product space. Then Y A Y ± - {0},
and Y C ( Y ± ) ± .
0
L e m m a 2.6 Suppose that Y - span {Yn " n - 1 , . . . , N} .... I f <X, yn> -- 0 for all n, then x E Y ± . [] A basis {bn } in an inner product space is called an orthogonal basis if the vectors are pairwise orthogonal, that is, if (bi, bj> = 0 when i # j, and an orthonormal basis if the vectors are pairwise orthogonal and also have unit length:
if i -- j; otherwise.
(2.31)
The vectors { e l , . . . , eN} defined previously form an orthonormal basis for E g . Any subset of an orthogonal or orthonormal basis inherits orthogonality and orthonormality, respectively. Linearly independent vectors can be orthonormalized: T h e o r e m 2.7 ( G r a m - S c h m i d t ) Suppose X is an inner product space and B = {bl,...,bg} c X is a set of N linearly independent vectors. Then there is an orthonormal set A = { a l , . . . ,aN} C X with span { a l , . . . ,ak} = span { b l , . . . , bk} for all k = 1 , . . . , N . In particular, span A = span B. Proof:
First note that the dimension of X is at least N, and that bl 7~ 0. We 1 bl. Then Ilal][ - 1, construct ak from bk inductively, starting with al def = IIblll span {al } = span {bl } since the two vectors are proportional, and the single-vector {al } is an orthogonal set. Now suppose that we have constructed an orthonormal set Ak de___f{ a l , . . . , a k } vector
with the same span as Bk de__f { b l , . . . , b k } . k /
def bk+1 - E
a k + 1 --
i=1
Then the
2.1.
39
VECTOR SPACES
cannot be zero since that would imply bk+l C s p a n A k -- s p a n B k , contradicting 1 the linear independence of B. Thus we may put ak+l -- ila~c+llla~+l • But then def
Ak+l
-- { a l , . . . , a k + l } is an orthonormal set since Ak is orthonormal and k
(aj, ak+l) -- (aj, bk+l) - E
(hi, bk+l) (aj, hi) -- (aj, bk+l) - (aj, bk+l) -- 0,
i--1
for j ak+l
C
1 , . . . , k. Finally, span Ak+l -- s p a n B k + l since bk+l E s p a n A k + l and span B k + l . [:3
Note that for all n, an e span { b l , . . . , b n _ l } ±, since an _L span {al, • • •, a n - l } . An important consequence of Theorem 2.7 is: C o r o l l a r y 2.8 Every finite dimensional inner product space has an orthonormal basis, rn The Gram-Schmidt algorithm works on infinite sets, too. If B is a Schauder basis for an infinite dimensional inner product space, then the algorithm produces an infinite sequence {a,~ : n = 1, 2 , . . . } of orthonormal vectors. Orthonormal bases are useful because the derived norm of a vector can be computed from its expansion coefficients in any orthonormal basis: L e m m a 2.9 Suppose that X is an N-dimensional inner product space and B { b l , . . . , bN} is an orthonorrnal basis for X . Then any vector x C X may be written uniquely as a linear combination from B, and we have N
x -- E
N
x(n)bn
=~
lixll 2
n-=l
-
Ix(n)l 2 n--1
Proof." Expand, using the linearity of the inner product:
Ilxll 2 - ( x , x ) -
x(n)bn, E =
x(m)bm
m=l
The result now follows from Equation 2.31.
- E
E
x ( n ) x ( m ) ( b n , bin).
n=l m=l
[]
Two subspaces Y, Z of an inner product space X are said to be orthogonal subspaces if every vector in Y is orthogonal to every vector in Z, namely, if (y, z) = 0 whenever y c Y and z c Z. We then write Y _L Z. For example, Y _L Y ± for every subspace Y. If Y _L Z, then Y A Z = {0}, but the converse does not hold: consider Y = span { (1, 1) } and Z = span { (1, 0) } in X = E 2. L e m m a 2.10 Suppose X is a finite dimensional inner product space with subspace Y c X . Then any x C X can be written uniquely as x - y + z, where y C Y and z c Y ±.
CHAPTER 2. SPACE AND LINEARITY
40
Proof: To show existence, let B = {yj } C Y C X be an orthonormal basis for Y. Then the vector y - ~ j (yj, x} yj C span B belongs to Y. It remains to show that def
z -- x - y
belongs to Y ± . But for any basis vector Yi, we have
(Yi,Y)-- lYi, E ( Y j , X ) y j ) = ~ j j
{yj,x}(Yi,YJ}=E(Yj,X}5(i--J)--(yi,x}" "
j
Therefore, (yi,z} = { y i , x - y} = (Yi, x ) - (Yi, Y) = 0. Since this is true for all basis vectors yi of Y, we conclude from Lemma 2.6 that z E Y ± . To prove uniqueness, suppose that x = y + z = yt + z t are two such decompositions. T h e n y - y ~ = z ~-zEYAY±={0}byLemma2.5,soy=ytandz=z ~. []
Consequently, if Y is a subspace of the inner product space X, then Y = X if and only if Y ± = {0}. A sum of subspaces Y, Z of an inner product space X is called an orthogonal sum, or a direct sum, if Y ± Z, and then it is written Y ® Z. If more than two subspaces Y 1 , . . . , Yn C X are pairwise orthogonal, then their sum is also called direct. If the direct sum is all of X, then we have a direct sum decomposition of X into orthogonal subspaces. An example of such a direct sum decomposition is E N = span {el } ® span {e2} ® . . . ® span {eN}.
(2.32)
Recall that span {e2 }, for example, is those N-tuples whose only nonzero coordinate is number 2.
Biorthogonal dual bases Suppose X is an N-dimensional inner product space with basis B - ( b n : n = 1 , . . . , N } , not necessarily orthogonal. Then there is another basis B ~ - {b~n " n - 1 , . . . , N} C X, called the biorthogonal dual to B, satisfying
(bi, b~) - {b'i, by} - 5(i - j),
i, j - 1 , . . . , N.
(2.33)
To construct it, let Xk -- span (b~ : n ~ k} for each k - 1 , . . . , N. Then Xk ~ X, since X is N-dimensional, so X~- ~= {0}. Hence there must be some vector Vk e X~for which (bk, vk} 7~ 0. Let b~ = ( b k ,1v k } Vk; then b~ e X~-, and it is easy to check that B and B ' -
{b~" k -
1 , . . . , N} satisfy Equation 2.33.
L e m m a 2.11 Every basis B = {b~ : n = 1 , . . . , N} for an N-dimensional inner product space has a unique biorthogonal dual basis.
Proof: We have existence by the construction given previously. Suppose now that {bin} and {b~} are biorthogonal duals. Then for fixed n we have (b~ - b~, bin} - 0 for all m - 1 , . . . , N. Since B is a basis, we conclude that b~ - b~. [] Consequently, B = B t if and only if B is an orthonormal basis. Biorthogonal dual bases are used to compute expansion coefficients:
2.1.
V E C T O R SPACES
41
Lemma2.12 Suppose that B {bn " n 1 , . . . , N } and B' - {b" • n 1 , . . . , N } are biorthogonal dual bases for an N-dimensional inner product space X . Then for any x E X, we have N
N
x - ~ (b'~,x} b n
-
E
n=l
(bn, x)b'~.
n=l
In other words, the expansion coefficients of x in B are {c(n) = (b~,x}}, and the expansion coefficients of x in B' are {c' (n) = (bn, x} }. N
Proof." Let x -
}-~'-~n=lc(m)bm be the expansion of x in basis B. Then N
N
c(m) (b~, b ~ ) - E
(b~,x) - E m--1
c ( m ) a ( n - m) - c(n).
m~l
The proof for c'(n) is similar. Consequently, we can expand each basis in terms of the other: N
N
b~ - Z
(bln' b ~ ) b n ;
bm-
E
n=l
(bn, bm} bZn;
form-
1,...,N.
n=l
For example, consider the basis {fn - el + ' " + en • n - 1 , . . . , N } defined by Equation 2.8. It is left as an exercise to check that its biorthogonal dual is {f~n def -en -e n + l " n -1,..., N}, or 11 f~ --
0
0
,
---,
f N' - 1
;
--
;
0 f~v--
,
11
0
,
(2.34)
01
where for notational convenience we write eN+l de__f 0. To use Lemma 2.12, we first compute (fi, fj} -- rain{i, j} and
(f~, f~} -
Then, using fo
for m -
def
0 and fN+l
f/T/Z
---
--fro-1
G
-
f
1 . . . . . N.
2, -1,
if i - j ; ifli-jl-
0,
ifli-jl
1; > 1.
def
-- 0 for notational convenience, we have
nt- 2 f r o - - G + I ,
+2f;+ . . . .
1 ) f' r o - l +
+ - " + f N' ] ,
42
C H A P T E R 2. SPACE A N D L I N E A R I T Y
2.2
Linear
Transformations
A linear transformation is a function T : X ~ Y between vector spaces X and Y t h a t preserves linear combinations: for vectors u, v C X and scalars a, b, we can expand T(au + bv) = aTu + bTv. Some examples are: 1. X = E 1, Y = E l ; Tx = 5x. [Note: Tx = 5x + 1 is not a linear transformation.] 2. X = E 1, Y = E3; Tx - (x, 2x, 3x). [Note: Tx transformation.]
(X, X2,X 3) is not a linear
=
3. X = E 2, V = E3; T(Xl,X2) = (0, Xl + x2,xl - x2). 4. X = E 2, Y = E2; T(Xl,X2)= (XlCOS0 + x2sinO,-xlsinO + x 2 c o s 0 ) f o r some fixed 0. 5. X = t~2, Y = g2; T ( X l , X 2 , X 3 , . . . ) = ( X l , 2 X 2 , 3 x 3 , . . . , n x n , . . . ) . Systems of simultaneous linear equations are one concrete source of linear transformations. Suppose t h a t numbers x ( 1 ) , . . . ,x(N) are sought satisfying the M linear equations A(1, 1)x(1) + . . . + A(1, N)x(N) A(2, 1)x(1) + - . - + A(2, N)x(N)
A(M, 1)x(1) + . . - +
A(M,N)x(N)
= =
b(1), b(2),
=
b(M),
where{A(m,n): m= 1,...,M;n= 1 , . . . , N } and { b ( m ) : m = 1 , . . . , M } are given scalar parameters. This m a y be rewritten as the problem of finding a vector x = ( x ( 1 ) , . . . , x ( g ) ) in X = E N such t h a t A x = b, where b = ( b ( 1 ) , . . . , b ( M ) ) is a vector in Y = E M, and
A de_f
T M
l
A(1,1) A(2, 1)
N A(1,2) A(2,2)
.
.
... ... •
A(M, 1) A(M, 2)
...
A(1, N ) A(2,N)
(2.35)
•
A(M, N)
is an M × N matrix, an array with M rows and N columns t h a t defines a function from E N to E M by the formula A(1,1) A X
z
"
A ( M , 1)
--. "..
...
A(M, 1 ) x ( 1 ) +
A(1, N ) / "
A(M,N)
x(1) x(2) .
x(N)
+ A(M,N)x(N)
2.2.
43
LINEAR TRANSFORMATIONS
Namely, the m-th coordinate b(m) of b - - Ax is b(m) not hard to verify that A is a linear transformation. 2.2.1
Matrix
--
N
~n--1
A(m, n)x(n).
It is
algebra
M x N matrices can be added componentwise: A + B - C
~
C(m,n) - A(m,n) + B(m,n),
I < m <_ M , I < n < N.
They can also be multiplied by scalars: cA - {cA(re, n)}. Thus they form a vector space, which is denoted M a t ( M x N), satisfying the axioms of Section 2.1.2. This space is N M dimensional, with one basis being the elementary matrices {e/j" 1 < i < M; 1 <_ j <_ N} C M a t ( M x N), defined by eij(m, n) -
1, 0,
5 ( i - m ) 5 ( j - n) -
if m - i and n otherwise.
j,
(2.37)
The inner product M
(A, B)
N
d¢j ~
~
m=l
(2.38)
A ( m , n) B ( m , n)
n--1
satisfies the inner product axioms, and makes M a t ( M x N) an NM-dimensional inner product space. The elementary matrices are in fact an orthonormal basis in this space. Likewise, linear transformations T " X ~ Y can be added together and multiplied by scalars to give other linear transformations, so they too form a vector space which we shall denote by Lin (X, Y). When X and Y are N-dimensional and M-dimensional vector spaces, respectively, then every choice of bases for X, Y defines a one-to-one correspondence between Lin (X, Y) and M a t ( M x N)" T h e o r e m 2.13 Let T " X --~ Y be a linear transformation between finite dimensional vector spaces X and V . Let P - {pn " n - 1 , . . . , N } and Q - {qm " m 1 , . . . , M} be bases for X and Y , respectively. Then there is a unique M x N matrix {A(m, n)} representing T with respect to the bases P, Q, in the following sense: N
1. For any x - ~-~n=l x ( n ) p n • X we can compute T y by the formula
M ~-'~m=l y(m)qm
• Y
N -
n--1
2. If any other matrix {A' (m, n)} satisfies N
N
~A'(m,n)x(n)-~A(m,n)x(n), n--1
for all x • X and all m - 1 , . . . , M , 1 , . . . , N and all m - 1 , . . . , M .
n=l
then A ' ( m , n ) - d ( m , n )
for all n -
C H A P T E R 2. SPACE A N D L I N E A R I T Y
44
Proof: Using linearity, if x E X has the expansion x - ~ n N 1 x ( n ) p n , then T x e Y has the expansion
n=l
n=l
m=l
=
n---1
where for each n = 1 , . . . , N, the matrix coefficients {A(m, n ) : m = 1 , . . . , M } give the expansion of T p ~ in the basis Q. We ma~. therefore c o m p u t e the expansion coefficients {y(m) : m - 1 , . . . , M } of T x - Y ; ~ I y ( m ) q ~ by the formula y(m) = N
E n = l A(m, n)x(n). For the second point, use x = e~ to extract column n of the matrices, for fixed n e {1,...,N}. T h e n A ' ( m , n ) = A ( m , n ) for all m = 1 , . . . , M . Since n was arbitrary, the two matrices must be equal. [] Thus every linear t r a n s f o r m a t i o n T between finite dimensional vector spaces can be represented by a matrix A whose matrix coefficients d e p e n d on the bases P , Q, so the correspondence may be pictured as follows: T P'q A
(2.39)
Using the s t a n d a r d bases {en} from Equations 2.7, the previously-defined examples of linear transformations have the following matrices:
1. T x = 5x has the 1 × 1 matrix A = (5) with respect to the s t a n d a r d bases P = Q = {el};
2. T x - (lx, 2x, 3x) has the 3 x 1 matrix A -
(1) 2 3
with respect to the s t a n d a r d
bases V = {el} and Q = { e l , e 2 , e3};
3. T ( x l , x2) - (0, Xl + x2,xl
-
X2)
has the 3 x 2 matrix A -
(0 0)
1 1 1 -1 respect to the s t a n d a r d bases P = {el, e2} and Q = {el, e2, e3}; -
with
4. T ( x l , x 2 ) = (XlCOS0 + x 2 s i n O , - x l s i n O + x 2 c o s 0 ) has the 2 x 2 m a t r i x A -
( cos0 \ - sin 0
s i n 0 ~ with respect to the s t a n d a r d bases P - Q - { e l , e 2 } . cos 0 ]
On the other hand, with respect to the bases {fn} of E q u a t i o n 2.8, we get the following matrices: 1. Since el = fl, the vector x = x e l = xfl, so T x = 5x has the same 1 x 1 matrix A = (5) with respect to P = Q = {fl}; 2. Again, x = x e l = xfl, but the o u t p u t T x = x e l + 2xe2 + 3xe3 = - x f l xf2 + 3xf3, so the matrix of T with respect to P = {f l} and Q = {f l, f2, fa} is A -
--1
;
2.2. LINEAR TRANSFORMATIONS
45
3. Note that x = x l e I ÷ x 2 e 2 = (Xl - x 2 ) f l ÷ x2f2, while the output is ( 0 ) e l ÷ (Xl ÷ x2)e2 ÷ (Xl -- x2)e3 -- --(Xl ÷ x 2 ) f l ÷ 2x2f2 + (xl - x2)f3. Now, --(Xl ÷ X2)
---
(--1)(Xl
2X2
--
(0)(Xl
-- X2) ÷ ( 2 ) ( X 2 ) ,
=
(1)(Xl
-- x 2 ) ÷
(Xl--X2)
-1 0 1
so T has the 3 x 2 matrix A =
-- X2) ÷ ( - - 2 ) ( X 2 ) ,
-2) 2 0
(0)(x2),
with respect to P = {fl, t"2} and
q =
def
def
In example 4, the vectors gl - (cos O,- sin 0) and g2 - (sin O, cos 0) form an orthonormal basis for E 2 for any fixed 0. Thus the linear transformation T x (Xl cos0 + x2 sin fl,-Xl sin 0 + x2 cos0) - Xlgl + x2g2 has the simple matrix A (10
0)1 w i t h r e s p e c t t o P - { e l , e 2 } a n d Q - { g l , g 2 } .
Example 5, T ( x l , x 2 , x 3 , . . . ) = (Xl, 2x2, 3 x 3 , . . . , nxn,...), may be said to have an "infinite matrix" with respect to the bases of elementary sequences P = Q = { e n : n = 1, 2 , . . . } : 1 0 0 ... 0 2 0 0 0 3 A
.
.
.
Except in such simple cases, though, we cannot perform computations with infinite arrays, and must rely on other formulas to represent linear transformations on infinite dimensional vector spaces. If X and Y are finite dimensional inner product spaces with respective bases P = {Pn} and Q = {qra}, then matrix coefficients can be computed using the inner product and the biorthogonal dual {q~m} of {qra}:
A(m, n) - (q~, Tp~}.
(2.40)
In the special case X = Y = E N with orthonormal basis P = Q = {en}, the formula simplifies to A(m, n ) = <era, Ten}.
Composition Linear transformations can be composed like any other functions. If X, Y, Z are vector spaces, and T : X ~ Y and S : Y ~ Z are linear transformations, then their composition S o T : X ~ Z, which is usually written just ST, is defined by x H S T x = S ( T x ) . This is a linear transformation: for all vectors x, y C X and all scalars a, b, we have
ST(ax + by) = S(aTx + bTy) = aST(x) + bST(y).
CHAPTER 2. SPACE AND LINEARITY
46
For example, the linear transformations of examples 1 and 2 defined previously have composition x H (5x, 10x, 15x). The composition of linear transformations on finite dimensional vector spaces defines a matrix product of their respective matrices. Suppose that P, Q, R are bases for the spaces X (of dimension N), Y (of dimension K), and Z (of dimension M), respectively, and we make the correspondences S Q'~ A c M a t ( M x K);
P,Q T,~ ; B C M a t ( K × N ) .
Then ST P'~ A B c M a t ( M x N), where K
AB(m, n) dej E A(m, k)B(k, n),
1 < m < M;1 < n < N.
(2.41)
k--1
Namely, the m-th coordinate of ABx is N
N
K
ABx(m) - E AB(m, n)x(n) - E E A(m, k)B(k, n)x(n). n--1
n--1 k--1
The set Lin (X) def Lin (X,X) of linear transformations T • X --~ X from an inner product space X to itself is preserved by composition. If X is finite dimensional with basis {bn : n = 1 , . . . , N} for X, the corresponding set M a t ( N x N) of square matrices is likewise closed under matrix multiplication. Lin (X), and thus M a t ( N x N), form a special kind of vector space called an associative algebra (with 1), having the following properties for all vectors U, V, W and scalars s, t: A s s o c i a t i v e A l g e b r a ( W i t h 1) A x i o m s A d d i t i v e a s s o c i a t i v i t y : U + (V + W ) = (U + V) + W . A d d i t i v e c o m m u t a t i v i t y : U + V - V + U. A d d i t i v e i d e n t i t y : There is a unique vector 0 satisfying U + 0 0 + U = U for all U. A d d i t i v e inverses: U + ( - 1 ) U = ( - 1 ) U + U - 0. Scalar m u l t i p l i c a t i o n d i s t r i b u t i v i t y : t(U + V) = tU + tV. Scalar m u l t i p l i c a t i o n a s s o c i a t i v i t y I: (st)U = s(tU). Multiplicative associativity: U ( V W ) =
(UV)W.
M u l t i p l i c a t i v e i d e n t i t y : There is a unique vector 1, different from 0, satisfying U 1 = 1 U = U for all U. Distributivity: U(V + W) = UV + UW. Scalar m u l t i p l i c a t i o n c o m m u t a t i v i t y : (tU)V = U(tV). Scalar m u l t i p l i c a t i o n a s s o c i a t i v i t y II: ( t U ) V -
t(UV).
2.2.
47
LINEAR TRANSFORMATIONS
Note that the first six of these are just the vector space axioms for the operations of matrix addition and scalar multiplication. In L i n (X), the additive identity 0 is the transformation x ~ 0 and the multiplicative identity 1 is x H x. In M a t ( N x N), these are respectively the zero matrix 0(m, n) - 0 for all 1 < n, m <_ N, and the N x N identity matrix Id
de__f
(1) "..
.
(2.42)
1
We may also write Id(rn, n) Equation 2.31, or even
n), where 5 is the Kronecker symbol of
5(m-
N
/d -
enn~ I
n=l
where each enn is one of the elementary matrices defined in Equation 2.37. It is not true that A B = B A for all A, B c M a t ( N x N), nor can we conclude from A B = 0 that either A = 0 or B = 0. Examples are readily obtained from M a t ( 2 x 2): (1 0) (0 0) A0 0 ; B1 0 " Evidently A B - O, even though A ¢- 0 and B ¢ 0. Likewise, B A - B ¢ A B . 2.2.2
Adjoints
and
projections
If x and Y are inner product spaces, then every linear transformation T : X ~ Y has an adjoint linear transformation T* : Y --+ X, or simply adjoint, defined by the relation (x, T ' y } = (Tx, y}, for all x E X and all y e Y. To compute z = T * y for a given y C Y, it is necessary to find z E X such that (Tx, y) = (x, z} for all x E X. If such a z exists, it must be unique, for if Z 1 and z2 both satisfy (X, Zl} = (x, z2) = {Tx, y) for all x E X, then {X, Zl - z 2 ) = 0 for all x, so z l = z2 by the nondegeneracy of the X inner product. The domain of T* is defined to be the subset of Y for which such z's exist. If the inner product spaces X and Y are finite dimensional, then the domain of T* is all of Y. It follows that (T*)* = T. The adjoint can then be computed from the matrix representing T: Lemma X ~ V then T* 1 , . . . , N;
2.14 Let X and Y be finite dimensional inner product spaces. I f T : is given by the matrix {A(m, n)} with respect to some fixed bases P, Q, : Y ~ X is given by the adjoint matrix { A * ( n , m ) = A ( m , n ) : n = m = 1 , . . . , M } , with respect to the biorthogonal dual bases Qt, p~.
Proof: Fix bases P - {Pn} and Q - {qm} for X and Y, respectively, and let / P ' - {P~}, Q' - {qm} be their respective biorthogonal duals. Note that the
48
C H A P T E R 2.
SPACE AND LINEARITY
biorthogonal dual to the basis { p ' } is {Pn}. We can use Equation 2.40 to compute A*(n, m ) , the matrix coefficient of T* with respect to the dual bases: •
!
A* (n, m) - (pn, T*q~m} - (T q ~ , p~} - (q~m, Tp~) - A ( m , n), where the second equality follows from the Hermitean s y m m e t r y of the inner product. [] The adjoint matrix is the transpose of the original matrix, wherein the i-th row becomes the i-th column and the j - t h column becomes the j - t h row, with all coefficients replaced by their complex conjugates. If the inner product spaces X, Y are real, then the adjoint matrix is simply the transpose. Lemma
2.15 I f T " X ~ Y and S " Y ~ Z are linear transformations on finite dimensional inner product spaces X , Y , Z, then their composition S T " X ~ Z has an adjoint ( S T ) * " Z ~ X satisfying ( S T ) * - T ' S * .
Proof: Compute ( ( S T ) * z , x ) - (z, S T x ) - (S*z, Tx) - ( T * S * z , x ) . Since this holds for all x c X and all z c Z, the result follows from nondegeneracy of the inner product. []
A linear transformation T • X --+ X is called selfadjoint if T* - T. For example, if X - E N and { A ( m , n ) - ( e r a , T e n ) } is the matrix of T with respect to the standard basis of Equation 2.7, then T is selfadjoint if and only if A ( n , m ) A(m,n).
Selfadjoint linear transformations arise from certain natural compositions: Lemma
2.16 Suppose X , Y are finite dimensional inner product spaces and T • X --+ Y is a linear transformation with adjoint T*. Then T * T • X ~ X and T T * • Y ~ Y are selfadjoint linear transformations. Proof: From L e m m a 2.15, we have ( T ' T ) * (T*)*T* - T T * .
Note that if T Y ' ~ A E M a t ( M
T*(T*)* -- T * T and ( T T * ) * = []
x N) using bases P , Q, then T * T p,P'~ A * A
Q',Q M a t ( N x N) and T T * ~ " AA* c M a t ( M
E
x M), where P ' , Q' are the respective
biorthogonal dual bases. Boundedness A linear transformation T : X --+ Y on normed vector spaces X, Y is said to be bounded if there is some upper bound, a number c, such that Ilrxll ___ ~llxll for all x c X. All the examples except number 5 are bounded linear transformations. The smallest upper bound c that works is called the operator n o r m of T, and is denoted by IITllop. Not~ that it depends on the norms chosen for X and Y. It indicates how much T can stretch a vector: For every x C X, IiTxi[ _~ [ITi[op IixlI,
(2.43)
2.2. L I N E A R T R A N S F O R M A T I O N S
49
and for every c < IIT{{op there is some vector x0 c X for which []Tx011> cllx0ll. The function I].]lop is not derived from any inner product, but it satisfies the Norm Axioms on page 29, plus one more:
Extra Operator Norm Axiom Submultiplicativity: }lSTllop _< IIS[)op)lTl}op for any bounded linear transformations S, T that can be composed. The proof is left as an exercise. Not all linear transformations are bounded, but all the ones corresponding to matrices are bounded: T h e o r e m 2.17 Suppose X and Y are finite dimensional inner product spaces. If T : X --+ Y is a linear transformation, then T is bounded with respect to any norms on X, Y.
Proof: First consider the derived norms [1" II- Choose any orthonormal bases P = {p~} and Q = {qm} for N-dimensional X and M-dimensional Y, respectively, and l e t A = { A ( m , n ) = {q,~,Tp~}: m = l , . . . , M ; n = 1 , . . . , N } be the matrix representing T in those bases. By Lemma 2.9, we have [Ixl[2 = E n [x(n)l 2 for any x = Y~n x(n)p~ E X. Using the Cauchy-Schwarz inequality for E N, we estimate IITxll 2
x ( n ) A ( m , n)
m=l
-<
q,~
-
n=l
E
[x(n)[2 n=l
E
E
m=l
n=l
]A(m, n)[ 2
x ( n ) A ( m , n)
= s Ilxll 2,
m=l n=l
where s - ~ , , ~ ]A(m, n)] 2 > 0. Thus ][Tx][ < ~ ]lx][, showing boundedness with respect to the derived norms of X and Y. Now let ]1" Ilx and ll" ]iv be arbitrary norms for X and Y. By Theorem 2.3, there are positive constants A and B such that (Ix]{ < B{lxllx and ]lTxllv < dllTxl] for all x ¢ X. Therefore, ]lTxlly < dBx/-s {Ix{ix for all x e X, so T is bounded with respect to those norms as well. [] The upper bound c = ~ used in the proof is called the Hilbert-Schmidt norm of the matrix A, and is computed directly by: def A[ M
I{A{{HS --
N
E ~ IA(m,n)(2.
(2.44)
m=l n=l
The relation between IIAllHs and liTllop depends on the bases and norms. particularly simple for the choices made in the proof of Theorem 2.17:
It is
Corollary 2.18 Suppose T
__ ]lAll.s
___
v/MN IITl]o
.
CHAPTER 2. SPACE AND L I N E A R I T Y
50
Proof: On the right, use the Cauchy-Schwarz inequality and Inequality 2.43: IIAII~IS
=
EiA(m'n)[ ?Tt ~f t
<
2 -
E[(qm,Tp~}
12
~ n
Eilqm[12iITli2p [Ipnl]2 -
]ITIIo2pE1 -
m,n
]]T[12pMN.
m,n
On the left, the inequality follows from the proof of Theorem 2.17.
[::1
It is left as an exercise to show that ]]'IIHs is sublinear and nondegenerate and satisfies the product inequality ]IABIIHS < IIAIIHsIIBIIHs. Bounded linear transformations T : X ~ Y form a normed vector space B d d (X, Y) C L i n (X, Y), with the norm I]'I]op- Equivalently, matrices A E M a t ( M × N) form a normed vector space with I]']]HS. If X and V are N and M-dimensional, respectively, and respective orthonormal bases P C X and Q c Y are chosen, then the correspondence T P ' Q A can be used to define IITIIHs -- IIAIIHs and IiAliop = IITilop. Bounded linear transformations T : X --+ Y are uniformly continuous functions on X: Given e > 0, take any 5 > 0 satisfying 5IiTilop < c, where ]]Ti]op is the bound computed using the norms II" Iix and ]]. ]lY- Then for any u, v e X,
Ilu- vtlx
< 5 ~
IITu- TvIIY --IlT(u-
v)llY _< IITIIopllU- vllx
_ 511TIIop< ~.
The special case X - Y defines the set B d d (X) de__f B d d (X, X) of bounded linear transformations from an inner product space X to itself. L e m m a 2.19 Suppose X is a finite dimensional inner product space. B d d (X), then T* C B d d (X) with I}Tllop -liT*[lop.
If T O
Proof: I ( T ' y , x} [ = I (Y, Tx) I -< IITIIopIlyll Ilxll for every x, y e X, by the CauchySchwarz inequality. Now fix an arbitrary y and put x = T * y to conclude that []T.y[[2 < [[TiiopiiT.iiop [[yi[2. Since y was arbitrary and liT[lop > 0, this implies that [[T*I]op _< [[Ti[op. A similar argument shows that [ITiIop < [[T*liop, so in combination these inequalities force [[Tilop = lIT* [[op[] Trace The trace of a square matrix A E M a t ( N along the main diagonal:
× N) is the sum of just its coefficients
N
A(n, n).
tr A de___f E
(2.45)
n----1
It is evident that tr (A + B) - tr A + tr B, tr (cA) - c tr A, and tr (A*) - tr A. We also have tr (AB) - E n
E A(n, k)B(k, n) - E k
k
E B(k, n)A(n, k) - tr (BA), n
(2.46)
2.2. LINEAR T R A N S F O R M A T I O N S
51
so tr (AB - BA) = 0 even for n o n c o m m u t i n g A, B C M a t ( N Even for nonsquare matrices, some products are square:
x N).
A , B C M a t ( M x N) =~ ~ B * A , A * B E M a t ( N x N);
(
BA*, AB* c Mat(M x M).
We can write the E q u a t i o n 2.38 inner product (A, B} in terms of the m a t r i x adjoint, m a t r i x product, and trace: (A, B} = tr ( A ' B ) = tr (BA*) = tr (AB*) = tr (B* A) The proof is straightforward. As a result,
IlAllgs
(2.47)
= v / t r (A'A) = v / t r (AA*).
Orthogonal p r o j e c t i o n Let X be an inner p r o d u c t space and suppose t h a t P : X --+ X is a linear transformation. P is called a projection if p2 = p , namely, if P ( P x ) = P x for every x c X. The range of P, P X de_f { P x " x C X}, is thus preserved by P. Also, P X is a subspace of X: if u = P x C P X and v = P x C P X , then u + v = P ( x + y) E P X . The name suggests visualizing P x as the shadow cast by x on the ground P X , the place of all shadows. The shadow may be longer t h a n x, depending on the angle of the light. For example, the projection on E 2 defined by P(Xl,X2) = (0, 5Z 1 -Jr-X2) lengthens (1, 0) five times: liP(l, 0)II = I[(0, 5)II = 5 = 511(1, 0)II. In the infinite dimensional case, there are projections which can stretch vectors an a r b i t r a r y amount. For example, take X = t~2 and define P x ( 2 k) = x ( 2 k ) + x ( 2 k 1) + . . . + x(2 k - k + 1) for k = 1, 2 , . . . , while P x ( n ) = 0 for all other indices n. T h a t is, P x = (0, x(2), 0, x(4) + x(3), 0, 0, 0, x(8) + x(7) + - - - + x(5), 0 , . . . ) . Clearly p2 = p . However, for x = ( 0 , . . . , 0, 1, 1 , . . . , 1, 0 , , . . . ) , where the ones are at indices 2 m + 1 t h r o u g h 2 m + 2 m, we get Ilxll- ~ while IIPxll- 2 m. We make m as large as we like, so P is an u n b o u n d e d projection. A projection P is said to be orthogonal if, for every u C X, the vector u - P u is orthogonal to every vector P v in P X : ( P v , u - P u ) = 0,
for all u, v c X.
(2.48)
Orthogonal projections P are b o u n d e d by P y t h a g o r a s ' Theorem: 2.20 If P is an orthogonal projection on an inner product space X, then IIPxll <_ Ilxll for all x C X.
Lemma
Proof." Write x = P x + (x - Px) and compute the length of b o t h sides: Ilxll 2 -IIPxII 2 + I I x - Pxll 2 + (Px, x - Px) + ( x - Px, Px>.
C H A P T E R 2. SPACE A N D L I N E A R I T Y
52
But the last two terms are zero since ( x - P x )
_1_P x . The inequality follows because
Ilx- rxll _> 0.
[]
The inequality is sharp if P ¢ 0, for then there is some x0 E X for which def Y0 - Px0 ¢ 0, and then IlPy01l- IIp2x011- Ilpxoll- ly0ll. In particular, this means IlPllop = 1 unless P = 0. There is an easy way to check whether a projection is orthogonal: orthogonal projections are selfadjoint. Lemma
2.21 A projection P : X
~ X is orthogonal if and only if P* = P.
Proof:
If P is an orthogonal projection, then (Pv, u - P u ) = 0, so ( P v , u) = ( P v , P u ) = ( P * P v , u). Since this is true for all u c X, it must be that P v = P * P v for all v C X. But then P = P*P. Since P* = (P'P)* = P ' P , this means that P = P*. The converse is evident: if P is a projection and P = P*, then ( P v , u - P u ) - (v, P u - p 2 u } - (v, 0) - 0, so u - P u is orthogonal to P v for any u, v. [] If Y {Yl,..., YN} is any finite orthonormal subset of an inner product space X, then we may define N def Py E (Yk, x)Yk. (2.49) k=l x
-
It is left as an exercise to show that this formula gives an orthogonal projection onto span Y. For example, the point (x, y, z) C R 3 is m a p p e d to the point (x, y, 0) C spaIl {el, e2}, t h e xy-plane, by P x = (el, x) el nu (e2, x) e2. Another example, with infinite dimensional X = Lip, is the one-vector set Y = {1} c L2(R), where 1 = l ( t ) is the indicator function of the interval [0, 1) as defined in Equation 2.25. The projection P y f ( t ) = (1, f) l ( t ) gives a multiple of the indicator function, with (1, f) -- f l f ( t ) d t being the average of f over the interval [0, 1). The Gram-Schmidt orthonormalization algorithm (Theorem 2.7) is a sequence of such projections: start with al i]-B-~bl, and then define a~ - b k - P s p a n Ak-1 bk 1 and a k - ~ a t for k > 1. __
1
Perspective projection Since a projection P is a linear transformation, it maps the line E de__f { 0 x + ( 1 - - 0 ) y " 0 C R} to another line P E = {OPx + (1 - 0 ) P y : 0 C R}. Hence, to draw a threedimensional geometric object consisting of points connected by lines, we project the points to some plane and then connect t h e m with lines. To draw the same object with perspective, we fix the viewpoint at (x0, yo, z0), distinct from any point on the object, and then compute a different projection" the intersections with the xy-plane of rays from the viewpoint through the points of the object, as depicted in Figure 2.3. Using similar triangles and elementary geometry, we get the formula for the image point (x', y', 0) in the xy-plane, where the object point (x, y, z) is seen from
2.2. L I N E A R T R A N S F O R M A T I O N S
53
z
(xl , Y1, Y
~~(X'l,
Y'l, Z'l) b~2' Y2' ~2j
F i g u r e 2.3" P e r s p e c t i v e p r o j e c t i o n f r o m t h e v i e w p o i n t (xo, yo, zo) to t h e x y - p l a n e .
t h e v i e w p o i n t (x0, Y0, zo)" x I - Xo Z/-
x - Xo = ~ ;
Z0
Z - - Z0
YP - Yo Z/-
Z0
Y - Y0 = ~ ;
z~
-0.
(2.50)
Z - - Z0
T h e t r a n s f o r m a t i o n (x, y, z) H (x', y', z') also preserves lines, d e s p i t e n o t b e i n g a linear t r a n s f o r m a t i o n , b e c a u s e t h e line t h r o u g h (Xl, yl, Zl) a n d (x2, Y2, z2), t o g e t h e r w i t h t h e v i e w p o i n t (Xo, yo, zo), d e t e r m i n e a p l a n e in R 3, a n d t h a t p l a n e i n t e r s e c t s t h e x y - p l a n e in a line.
2.2.3
Linear independence and invertibility
S u p p o s e t h a t T • X ~ Y is a linear t r a n s f o r m a t i o n . G i v e n y E Y , t h e r e is an x E X solving T x - y if a n d only if y b e l o n g s to t h e range of T, which we m a y d e n o t e by T X clef { T x " x C X } . In t h a t case, t h e s o l u t i o n is u n i q u e if a n d only if T is a o n e - t o - o n e function: T u - T v ~ u - v. B y linearity, this is e q u i v a l e n t to t h e c o n d i t i o n t h a t T x - 0 ~ x - 0. We will say t h a t T is invertible if for e v e r y y c Y t h e r e is a u n i q u e x E X solving T x - y. In t h a t case we m a y define a f u n c t i o n T -1 • Y ~ X such t h a t T ( T - I ( y ) ) - y for e v e r y y e Y a n d T - I ( T ( x ) ) - x for e v e r y x E X. T h i s T -1 is a linear t r a n s f o r m a t i o n since for a n y Yl, Y2 E Y a n d scalars a, b, once we find Xx, x2 E X satisfying TXl - Yl a n d Tx2 - y2, we will have T-l(ayl
+ by2)
-
T - l ( a T X l + bTx2) -
=
a x l d- bx2 -
aT-l(yl)
T - l ( T ( a X l + bx2)) -t- b T - I ( y 2 ) .
If X a n d Y are finite d i m e n s i o n a l v e c t o r spaces, w i t h r e s p e c t i v e d i m e n s i o n s N, M a n d bases P - {Pn} a n d Q - {q,~}, we m a y e x p l o r e t h e s e e x i s t e n c e a n d
C H A P T E R 2. SPACE AND L I N E A R I T Y
54
P,Q
uniqueness issues from the m a t r i x side of the correspondence T ~. " A, where A E M a t ( M x N). For existence, notice t h a t every vector x = ~-~n c(n)pn E X, expanded in P, determines a coefficient vector e = ( c ( 1 ) , . . . ,c(N)) E E N, and we may compute the expansion coefficients b = ( b ( 1 ) , . . . , b(M)) E E M of T x = y = }-~m b(m)qm E Y by b -
Ac
-
(A(1,1)c(1)
\ A(M, 1 ) c ( 1 ) + =
I
+..-+A(1,N)c(N) + A(M, N ) c ( N )
•
A(M, 1)
]
/ / •
,
A(M,N)
which is a linear combination of the N vectors ( A ( 1 , 1 ) , . . . , A ( M , 1)) through (A(1,N),...,A(M,N)) of E M formed from columns of A. The set of all such linear combinations is called the range or column space of A, and has the form {Ax : x E EN}. It is a subspace of E M, since it is a linear span, and its dimension is no more than the smaller of N and M. Obviously, the linear system of equations Ae = b of has a solution e if and only if b lies in this column space, so if N < M, there will certainly be some b E E M for which Ae = b has no solution. For uniqueness, notice t h a t there will be some c ¢ 0 for which Ae = 0 in Equation 2.51 if and only if the N columns of A are linearly dependent in E M. T h e y will certainly be linearly dependent if N > M , by Theorem 2.2, and e will give a nonzero x E X for which T x - 0 through the correspondence X ~ P ~ E N . Hence T x = y can have a unique solution x E X for every y E Y only if X and Y have the same dimension, which means t h a t T P ' ~ A is a square matrix. But just because its matrix is square doesn't guarantee that a linear transformation is invertible. On the other side of the correspondence, we will say t h a t A E M a t ( N x N ) is invertible if there is a matrix B E M a t ( N x N) satisfying B A = Id. Invertibility is equivalent to the columns forming a basis: 2.22 Matrix A E M a t ( N x N) is invertible if and only if the columns of A are linearly independent. In that case, Lemma
1. there is a unique matrix B such that B A = Id; 2. the columns of B are linearly independent; 3. B also satisfies A B = Id. Proof: By Equation 2.51, any linear combination of the column vectors of A can be expressed as Ac for some column vector c = ( c ( 1 ) , . . . , c(N)) of expansion coefficients. If A is invertible, then Ac = 0 implies c = B A c = 0, so the columns of A are linearly independent.
2.2.
55
LINEAR TRANSFORMATIONS
Conversely, since the N columns of A are linearly independent, they form a basis for E N. By Lemma 2.11, this has a unique biorthogonal dual basis, so let A t be the matrix whose columns are the dual vectors. Then B de_f (AI). satisfies B A = Id, so A is invertible. For 1: the matrix B is unique because the biorthogonal dual basis that determines A I is unique. For 2: note that any b E E N can be written as b = Ac for some c E E N since the columns of A form a basis. T h u s B b = 0 ~ c = B A c = 0 ~ b = 0 , so the columns of B are linearly independent. For 3: note that B is also invertible, since the columns of B are linearly independent. So let C E M a t ( N × N) satisfy C B = Id. Then by the multiplicative associativity axiom, A B = ( C B ) A B = C ( B A ) B = C B = Id. [] Since the inverse of an invertible matrix A is unique and works on both sides, it is denoted by A -1 and is called the multiplicative inverse of A. The proof gives us a construction for the biorthogonal dual to a basis written as a matrix A of column vectors: it is the column vectors of ( A - l ) *. L e m m a 2.23 Suppose A is a square matrix. Then A is invertible if and only if A* is invertible, and we have (A*) -1 = ( A - l ) *. Equivalently, the columns of A are linearly independent if and only if the rows of A are linearly independent. Proof: If A is invertible, then I d = Id* = ( A A -1)* = (A -1)* A*, so A* is invertible and (A*)-I = ( A - l ) * . The same argument applied to A* proves the converse because (A*)* = A. The two statements are equivalent since the rows of A are the columns of of A*, and A* is invertible if and only if A* is invertible. []
C o r o l l a r y 2.24 I f T P'Q A, then T is invertible if and only if A is invertible, with T -1 Q'P A -1. [] Determinant There is a simple formula for the inverse of a 2 x 2 matrix: =a
A-1-
ad-bc -c
ad-bc
ad-bc a
ad-bc
_
(~..~p~ ad-
bc
-c
a
'
whenever ad ¢ bc. The quantity det(A) def a d - bc is called the determinant of A, and is nonzero if and only if the two columns of A are linearly independent vectors. More generally, for each N > 0, there is a determinant function det = det(A) defined on matrices A E M a t ( N x N) satisfying det(A) ~= 0 if and only if A is invertible. Specifying enough extra conditions to construct it recursively ensures its uniqueness. One of these conditions is that det(AB) = d e t ( A ) d e t ( B ) for any matrices A, B E M a t ( N x N). From these two properties, for example, we conclude
C H A P T E R 2. SPACE A N D L I N E A R I T Y
56
t h a t det(Id) = 1 and det(A -1) = 1 / d e t ( A ) . We will also require t h a t det(A*) = det(A). A square matrix g E M a t ( N x N) is called upper triangular if g ( i , j ) = 0 whenever i > j. Such U is invertible if and only if there are no zeroes on the main diagonal, so we may define det(U) = U(1, 1 ) U ( 2 , 2 ) . - . U ( N , N ) . It is left as an exercise to show that if U1, U2 are upper triangular, then their product is upper triangular with diagonal elements U1 (n, n)U2(n, n), n = 1 , . . . , N , and thus det() is multiplicative. Id is upper triangular, and this formula gives det(Id) = 1, as required. We likewise call a square matrix L E M a t ( N x N) lower triangular if L(i, j) = 0 whenever i < j, and extend the definition of det() to this case by putting det(L) =
L(1,1)L(2,2)...L(N,N).
Rotations
and rigid motions
Suppose X is an inner product space and T • X ~ X is an invertible linear transformation satisfying T * T - Id will be length preserving. This i m p o r t a n t subclass of linear transformations, for which T* - T - I , is called the unitary transformations. Imagine for a moment how any linear transformation T acts on points in X. TO - 0 is a fixed point, so T is origin-preserving. Also, any subset K C X gets transformed into the subset T K def { T x " x E K } . For example, T maps the line segment K - {0x + (1 - 0 ) y • 0 _< 0 _< 1} between x and y to the set {OTx + (1 - O)Ty • 0 _< 0 < 1}, which is the line segment between T x and T y . Thus T is line-preserving; it sends lines to lines. Now suppose t h a t T is unitary. Since IITxll - (Tx, Txl - (x,T*Tx) Ix, x / - Ilxll 2, we have IITxll - Ilxll for all x E X. Then T is length-preserving. Also, for any two vectors u, v E X, the inner product (Tu, T v ) - {u, T*Tv} - (u, v} is preserved by T. Specifically, if u is perpendicular to v, then T u is perpendicular to T v . More generally, since (u,v}, Ilull and Ilvll determine the angle between u and v, it follows t h a t unitary transformations are angle-preserving as well as length-preserving. Therefore, applying a unitary transformation T produces a rigid motion which fixes the origin, and can be called a rotation about the origin 2. The inverse of a unitary transformation is also unitary: using T -1 - T*, we compute (T -1)* - (T*)* - T - (T - 1 ) - 1 . In particular, the inverse of a rotation is also a rotation, but in the reverse direction. Composing two rotations yields another rotation. In general, for any unitary transformations S, T, if S* - S - 1 and T* - T - 1, then (ST)* - T* S* - T - 1S - 1 (ST) -1, so S T is unitary. If T • X --. X is a unitary transformation on an N-dimensional inner product =
space X with orthonormal basis P, then T P ' P A where A E M a t ( N x N ) is a square matrix satisfying A* - A -1. We will call such matrices unitary matrices. 2 T h e o n l y o t h e r k i n d of rigid m o t i o n is translation, w h e r e x ~-, x + c for s o m e fixed c. However, t r a n s l a t i o n by c 7~ 0 is n o t a l i n e a r t r a n s f o r m a t i o n b e c a u s e it does n o t fix 0.
2.2. L I N E A R T R A N S F O R M A T I O N S
57
Conversely, any unitary matrix gives a unitary transformation, once an orthonormal basis P is chosen. For example, any two elementary basis vectors ei, ej G R N, i 7~ j, determine a plane, and the Givens rotation through an angle 0 in that plane is given by the unitary matrix
Gij(O)
de__f I - (eii + ejj) + cosO ( e i i + ejj) + sinO ( e i j - e j i ) ,
(2.53)
which is the identity matrix modified at the four intersections of rows i , j and columns i, j to resemble the 2 x 2 plane rotation cos 0 -sin0
sin 0 ) cos0 "
Straightforward computation shows that C i j ( O ) - 1 - C i j ( - O ) - Cji(O) - CiS(O), proving that Givens rotations are unitary. The determinant of a unitary matrix is a complex number if the scalars are complex, but it will have absolute value 1 since I det(A)l 2 = d e t ( A ) d e t ( A ) = det(A*)det(A) = det(A*A) = det(Id) = 1. 2.2.4
Solving
linear
systems
of equations
To find the multiplicative inverse of a matrix A c M a t ( N x N), it is enough to find N vectors xn, n = 1 , . . . , N such that Axn = en, where en is an elementary basis vector• Then the matrix B C M a t ( N x N) whose columns are x l , . . . , XN satisfies A B = Id, so B A = Id and B is the inverse of A. One standard method of solving the N x N system of linear equations Ax = b, for an invertible matrix A, is to reduce A to upper triangular form A': A(1,1) A(2,1) A
A(1,2) A(2,2)
... ...
A(1, N) A(2, N)
...
A(N, N)
_~ •
i
A(N, 1)
A(N, 2)
A' -
"
A'(1,1) 0 .
A'(1,2) A'(2,2)
0
...
... ... ".
A'(1, N) A'(2, N) .
0
A'(N,N)
.
(2.54)
The same operations applied to the vector b produce b', and Ax = b if and only if A ' x = W. But the primed system is easily solved by back substitution, starting with x ( N ) = b ' ( N ) / A ' ( N , N ) , as long as all the diagonal elements of A', namely {A'(n, n ) : n = 1 , . . . , N } , are nonzero. The reduction procedure is called Gaussian elimination, and it was introduced as Equation 2.9 in the proof of Theorem 2.2. In step one of this ( N - 1)-stage
CHAPTER 2. SPACE AND LINEARITY
58
process, we find a row index rr(1) such that A(rr(1), 1) 7~ 0. This can always be done, since the N rows of A are linearly independent. If ]A(rr(1), 1)1 is the largest absolute value of all in column 1, then finding rr(1) is called partial pivoting a. We then replace A(i,j) by A ( i , j ) - A(Tr(1),j)A(i, 1)/A(rc(1),l) for all i = 2 , . . . , N except i = rr(1), and all j = 2 , . . . , N . Thus A(i, 1) = 0 for all i # rr(1). Row rr(1) is then interchanged with row 1 to put the sole nonzero at the top of column 1. The coefficients are then renamed as the new matrix A1, completing stage 1: A(1,1) A(2,1) •
A(1,2) A(2,2)
... ..O.o
A(N, 1) A(N, 2) ...
A(1, N) A(2, N)
AI(1,1) 0
°
A(N,N)
A1(1,2)... A1(2,2) ...
o
o o
0
A1(2,2)
o
AI(1,N) AI(2, N) °
•
°.
-..
AI(N,N)
To preserve the linear system, we do the same to b" replace b(i) by b ( i ) b(Tr(1))A(i, 1)/A(Tr(1), 1) for all i # 7r(1), and then interchange b(1) with b(Tr(1)). Denote the result by bl; then A x - b ~ A l x - bl. The same procedure is then applied to the ( N - l ) x ( N - l ) submatrix {Al(i,j)" 2 <_ i,j <_ N}, determining 7r(2) and {A2(i,j)" 3 <_ i,j <_ N}. After a t o t a l of Nb,
1 stages, the final matrix A'
def
AN-1 is upper-triangular, and the vector
_ _ bN-1 is prepared. Finally, the solution x to A'x - b' is found by back substitution. Combining all steps gives the following algorithm: def
Gaussian E l i m i n a t i o n with Partial P i v o t i n g gepp( b [ ] , A[], N )[ 1] For k=l t o N,1, do [2] t o [10] [ 2] Find the largest value IA[m,k]l, for m in k,...,N [ 3] If A[m,k]==O, then print "A is singular" and stop. [ 4] If m!=k, then do [5] to [6] [ 5] For j=k to N, interchange A[m,j] and A[k,j] [ 6] Interchange b[m] and b[k] [ 7] For i=k+l to N, do [8] to [I0] [ 8] Replace A[i,k] /= A[k,k] [ 9] For j=k+l to N, replace A[i,j] -= A[i,k],A[k,j] [I0] Replace b[i] -= A [i ,k] ,b [k] [ii] For k=N down to I, do [i2] to [13] [12] For j=k+l to N, replace b[k] -= A[k,j]*b[j] [13] Replace b[k] /= A[k,k] Forward elimination with partial pivoting takes place in steps 1-10, while steps 11-13 are the back substitution. At the end, the coordinates of the solution vector 3Full pivoting seeks to put the largest absolute value of all at position (1, 1), by finding a column index u(1) with IA(~(1),~(1))I maximal among IA(i,j)l. With full pivoting, the solution vector comes out in the order x(v(1)),... ,x(v(N)).
2.2. L I N E A R T R A N S F O R M A T I O N S
59
x are left in b [1] . . . . ,b IN]. They do not need to be re-ordered since no column interchanges were performed on A. The input matrix A[] is modified in stages until it is upper-triangular 4 and must at the end have nonzero elements on its diagonal. If this is cannot be done, the program will stop at step 3 with an error message claiming t h a t A is singular, which means t h a t for some b, A x = b cannot be solved for x.
Inverses and LU decompositions G E P P can be extended to find A -1 C M a t ( N × N), whenever A is nonsingular. In the following implementation, lines with changes from the G E P P algorithm are marked with primes:
Matrix Inversion Using Partial Pivoting mipp( [ 0'] [ I ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6'] [ 7 ] [ 8 ] [ 9 ] [I0'] [ii ] [12'] [13'] [14']
B[], h[], N ): Initialize B[i,j]=O, and for i=l to N, let B[i,i] = i For k=l to N-I, do [2] to [I0'] Find the largest value ]A[m,k]l, for m in k,...,N If A[m,k]==O, then print "A is singular" and stop. If m!=k, then do [5] to [6'] For j=k to N, interchange A[m,j] and A[k,j] For j=k to N, interchange B[m,j] and B[k,j] For i=k+l to N, do [8] to [10'] Replace A[i,k] /= A[k,k] For j=k+l to N, replace A[i,j] -= A[i,k],A[k,j] For j=l to N, replace B[i,j] -= A[i,k],B[k,j] For k=N down to I, do [12'] to [14'] For n=l to N, do [13'] to [14'] For j=k+l to N, replace B[k,n] -= A[k,j].B[j,n] Replace B[k,n] /= A[k,k]
The inverse of A will then be found in the double array B []. Actually, most of the information needed to reduce b to b' during forward elimination is written into the lower-triangular part of A [], rather than zeroes. If we also keep track of the interchanges 7r(1), 7r(2)..., and apply t h e m across entire rows of the matrix, then the operations on A may be performed in advance, preparing it for separate solution of A x = b with b to be named later. The result is called the LU decomposition of A. It is another encoding of A's inverse, somewhat cheaper to compute t h a n A -1, and with other advantages. In the implementation below, differences from the forward elimination part of G E P P are marked with double primes: 4At step 8, for efficiency, the subdiagonal element t [ i , k ] gets the precomputed multiplier t [ i , k ] / t [ k , k ] , needed many times thereafter. It should then be set to zero, if we insist that the returned array t actually be upper-triangular.
CHAPTER 2. SPACE AND LINEARITY
60 LU Decomposition
with Partial Pivoting
l u p p ( h i ] , p i [ ] , N ): [0"] For k=l to N, initialize pi[k] = k [1 ] For k=l to N-I, do [2] to [9] [2 ] Find the largest value [A[m,k] 1, for m in k, .... N [3 ] If A[m,k]==O, then print "A is singular" and stop. [4 ] If m!=k, then do [5"] to [6"] For j=l to N, interchange A[m,j] and h[k,j] [5"] [6"] Interchange pi[m] and pi [k] [7 ] For i=k+l to N, do [8] to [9] [8 ] Replace A[i,k] /= A[k,k] [9 ] For j=k+1 to N, replace h[i,j] -= A[i,kJ,A[k,j] The pivot array p i [1] . . . . p i [N], which defines i H 7r(i), stores the interchange information. To use it, we re-index an input array b into the order b [ p i [ 1 ] ] , . . . , b [pi IN] ], matching the partial pivoting rearrangement of rows of A. This is N equivalent to multiplying b by the matrix P - ~ i = 1 ei,zr(i), expressed here as a sum of elementary matrices. In other words, coefficient P(i, j) is one if j = 7r(i), but zero otherwise. If we apply P to a vector b, we get a new vector P b whose ith coordinate satisfies P b ( i ) = b(zr(i)). If no interchanges are needed, we will have 7r(i) = i for all i = 1, 2 , . . . , N, which is the identity permutation. The array A returned by LUPP, which we shall denote by A" to distinguish it from the original matrix A, contains an upper-triangular part U. Let us identify it as follows: A"
u(1, 1 ) u ( 1 , 2) l(2,1) u(2,2)
-
-.. ...
•
.
•
,
-.
l(N, 1)
I(N, N-1)
... u(1,1)
u
u(1, N) u(2, N)
def
u(1,2)
...
u(1, N)
2)
-..
N)
0
N)
0 0
u(N, N)
...
.
(2.55)
But we obtained U from the row-interchanged matrix PA by applying a sequence of N - 1 forward elimination steps: L N - I ' " L2LIPA = U, where the factors L 1 , . . . can be written as matrices, using coefficients read directly from A": 1 -Z(2, 1) L 1
_-
- / ( 3 , 1) •
- I ( N , 1)
1 "'.
,..., 1
1
2.2• L I N E A R T R A N S F O R M A T I O N S
61
1 1 LN-1
--
".
. 1 -l(N, N-1)
(2.56)
1
Every coefficient not written out explicitly, or at least indicated by an ellipsis (dots), is zero. Now note that Lk-1 is just Lk with the off-diagonal terms changed in sign: -1
(
L~-1 --
1 -l(k+l,k)
l(k+l,k)
-l(N,k)
l(X,k)
1
(2.57)
It is left as an exercise to prove that these formulas hold for all k - 1 , . . . , N If we now define the product L def L 1 1 L 2 1 . . . LNI_I,
1.
(2.58)
then we may write P A = LU, with all the information needed to determine P, L, U returned in the arrays p i and h. It is left as an exercise to prove that L is in fact lower-triangular. To solve Ax = b with this decomposition, we apply the interchanges, forward elimination, and back substitution steps only to b:
Linear S y s t e m S o l u t i o n from L U and P i v o t i n g D a t a sslu( b[], hi], pi[], [10] Permute b[1] . . . . . [11] For k=l t o N - l , [12] For i=k+l t o [13] For k=N down t o [14] For j=k+l t o [i5] Replace b [k]
N ): biN] t o g e t b [ p i [ 1 ] ] , . . . , b [ p i [ N J ] do [12] N, r e p l a c e b [ i ] -= h [i , k] , b [k] 1, do [14] t o [15] N, r e p l a c e b[k] -= h [ k , j ] , b [ j ] /= h [k,k]
This is equivalent to solving P A x -
LUx-
P b in three stages:
1. Apply all interchanges to b at once: b ~ P b de__f b p . 2. Apply f o r w a r d elimination: b p ~-~ L l b p ~--~... ~ L N - 1 . . . L l b p
3. Solve the upper-triangular linear system U x -
de_f bL.
b c by back substitution.
CHAPTER 2. SPACE AND LINEARITY
62
After factoring A = LU, we may use Equation 2.58 and the multiplicative property of determinants to compute: det(A) = d e t ( L 1 ) - I
.,,
d e t ( L N _ l ) - I det(U) = det(U),
since det(Li) = 1 for every i = 1 , . . . , N -
1. But U is upper triangular, so
det(A) = det(U) = U(1, 1 ) . . - U ( N , N). Pivoting information is not needed; the determinant is just the product of the main diagonal elements left in the array A [] after LUPP: Compute the Determinant
of a S q u a r e M a t r i x
d e t ( A [ ] , N ): [10] Compute lupp(A [] ,pL [] ,N) [11] Let D = 1 [12] For n=l t o N, r e p l a c e D .= A[n,n] [13] R e t u r n D This may also be done by appending lines [ii]-[13] to lupp(). 2.2.5
Sparse
matrices
Suppose that A E M a t ( M x N) is the matrix representing some linear transformation with respect to fixed bases. To specify the transformation may require listing all M x N coefficients, if A is a so-called full matrix. To compute y = Ax in this case requires finding y(m) - EnN=I A(m, n)x(n) for m - 1 , . . . , M, a total of O(MN) operations of multiplication and addition. However, any zero matrix coefficient contributes nothing, and some useful matrices that are mostly zeroes, or sparse, can be specified with simple formulas. In the examples below, we will denote by N either the index set {1, 2 , . . . , N} or the set {0, 1 , . . . , N - 1}. This is to accommodate the two different programming language conventions without duplicating formulas. Thus }-]neN is implemented N
N-1
either a s E n = l or ~ n = 0 , depending on the language. A similar interpretation will apply to the set M. Diagonal Matrix. Suppose N = M. If A(m, n) = 0 unless n = m, then only the diagonal elements A(n, n) for n c N need to be stored: ".
A-
0
A(n, n) 0
- ~ ...
A(n, n)enn.
(2.59)
nEN
Computing Ax(m) = A(m, m)x(m) for m C N costs only O(N) operations. The product of two diagonal matrices {A(n, n ) : n ¢ N}, {B(n, n ) : n e N} is another
2.2. LINEAR TRANSFORMATIONS
63
(liagonal m a t r i x A B - {A(n, n)B(n, n ) ' n E N}. A diagonal m a t r i x A is invertible if a n d only if A(n, n) ~=0 for all n E N . Permutation Matrix. Suppose N - M a n d A(m, n) c {0, 1} 5 for all n, m E M . A is called a permutation matrix if A has a single 1 in each row and a single 1 in each column. In t h a t case t h e r e will be a one-to-one a n d onto function 7r : M M which gives t h e c o l u m n index n = 7r(m) of the 1 in row m. We m a y write T~ > A< ~ 7r. T h u s T x ( m ) = x(Tr(m)) for m C M costs only O(M) operations. T h e associated m a t r i x is A = ~-~.mcMem,Tr(m). For example, t h e 3 × 3 m a t r i x associated to 7r(1) = 2, 7r(2) = 3, 7r(3) = 1, which we m a y write (1, 2, 3) H (2, 3, 1), is A-
(010) 0 1
0 0
1 0
.
(2.60)
T h e p r o d u c t of two p e r m u t a t i o n matrices A < >TrA a n d B < >TrB is a n o t h e r p e r m u t a t i o n m a t r i x AB < >7rB o 7rA. Note t h a t the order is reversed. T h e inverse of a p e r m u t a t i o n m a t r i x is its transpose, which is also its adjoint since all coefficients are real, so a p e r m u t a t i o n m a t r i x is a u n i t a r y linear t r a n s f o r m a t i o n . This t r a n s p o s e is also a p e r m u t a t i o n matrix. Tridiagonal Matrix. Suppose N - M . If A(m, n) - 0 unless - 1 < n - m < 1, t h e n only t h e three diagonals in the middle of the m a t r i x need to be stored. This takes O ( 3 N ) m e m o r y locations. We c o m p u t e A x ( m ) = A ( m , m - 1 ) x ( m - 1 ) + A(m, m ) x ( m ) + A(m, m + 1 ) x ( m + 1) for m E N , handling the b o u n d a r y t e r m s with the convention x(n) = 0 if n ~ N and A(m, n) = 0 if m ~ N or n ~ N . This also costs only O ( 3 N ) operations. T h e middle of the associated m a t r i x is "..
A-
...
0
"..
A(m, m - 1 ) "..
"..
A(m, m) "..
A(m, m + l)
0
....
(2.61)
"..
N
We m a y also write A - E n c y A(n, n)enn + A(n + 1, rt)en+l,n -+- A(n, n + 1)en,n+l. Neither the p r o d u c t of tridiagonal matrices nor the inverse of a tridiagonal m a t r i x is necessarily tridiagonal. Banded Matrix. Suppose N - M . If A(m, n) - 0 unless - p < n - m < q, t h e n only the b a n d of diagonals from p below to q above the m a i n diagonal needs to be stored. This takes O ( N [ 1 + p + q]) m e m o r y locations. C o m p u t i n g A x ( m ) Em+q r t = m - - p A(m, n)x(n) for 1 -<- m -<- N also costs only O ( N [ 1 + p + q]) operations. 5Such an A is called a (0, 1)-matrix. Calculations with it require no multiplication operations, which is useful if multiplication circuitry is expensive or unavailable. A (0, 1,-1) matrix has a similar advantage.
C H A P T E R 2. SPACE A N D L I N E A R I T Y
64
The associated matrix in the indexing starting at 1 is /
A(1, 1) A(2,1)
A(1,2) A(2,2)
... A(2,3)
A(1, 1 + q) ...
A ( l + p , 1)
0 (2.62)
"'.
0 \
0 A(2, 2+q)
".
•
The only nonzero elements of a generic middle row m of this m a t r i x are
A(m, m - p ) , • • • , A(m, m), • . . , A(m, m+q). m+q
We can write this in either indexing convention as A -
E
E
A(m, n)e,~n, if
mEN n=m--p
we agree to skip coefficients with out-of-range indices. The product of two banded matrices can have more bands t h a n either factor, and the inverse of a banded m a t r i x need not be banded• Decimated Averages. Suppose N = 2 M is an even number. Indexing from 0, let H C M a t ( M x 2M) be defined by H ( m , n) - 0 unless n - 2m or n - 2m + 1, 1 Then H u ( m ) - l [ u ( 2 m ) + u(2m + 1)] for with H ( m , 2m) - H ( m , 2m + 1) - 3" 0 _< m < M; this is the sequence of averages of adjacent pairs in u. Then 1
~1 0
0 •
H-
0 ~1
0 ~1
0
...
0
•.
• •
0
0
0
...
0
0
~1
0
1 -- 2
E
(ern,2m -~-ern,2m+l)
•
(2.63)
rnEM
1
l i d C M a t ( M × M ) while 2H*H E M a t ( 2 M × 2M) is an Notice t h a t HH* - -~ orthogonal projection from E TM onto the M-dimensional subspace spanned by the rows of H. Decimated Differences. Suppose N - 2 M is an even number. Indexing from 0, let G E M a t ( M x 2M) be defined by G(m, n) - 0 unless n - 2m or n - 2m + 1, with G ( m , 2 m ) - - 1 and G(m, 2m + 1 ) - +1. Then G u ( m ) - u(2m + 1 ) - u(2m) for 0 _< m < M; this is the sequence of differences of adjacent pairs in u. Then 1
O --
1 0
0 -1
0 1
•
0 0
... ...
•.
0 0 •
•
0
0
0
...
0
--
E
(em,2m+l
-- e m , 2 m ) •
(2.64)
rnCM
-1
1
Notice t h a t GG* - 2Id E M a t ( M x M ) , while 1 G * G C M a t ( N x N ) is an orthogona! projection from E 2M onto the M-dimensional subspace spanned by the rows of G. W i t h the decimated averages matrix H, we have two properties:
2.3.
65
EXERCISES
Independence: G H * = H G * = 0 c M a t ( M x M). Thus the column space of G* is orthogonal to the column space of H*. As a consequence, for all x C E TM, we have G * G x _J_ H * H x . 1 • Completeness: 2 H * H + -~G G - I d c M a t ( 2 M x 2M). Thus every x E E TM may be written as x = s + d, for some s in the Mdimensional column space of H* and some d in the M-dimensional column space of G*.
Running Averages.
FixK>landfor0_<m<_N-Kand0
1 K' O,
A ( m , n) -
ifm
-otherwise.
(2.65)
Then A x ( m ) is the average of the K components of x starting with x ( m ) . associated matrix is 1
-~
1
I~ -R
"'" ...
1
0
0
I~ -~
1 -R
0
"
0
"o
0
...
0
~1
...
...
0
0 "
"
~1
...
The
1
-EE mCM
re+K-1
e~,n.
(2.66)
1~
n=m
1
As usual, out-of-range coefficients are set to zero.
2.3
Exercises
1. How many vertices and edges are there in the 5-cube, the unit cube in Euclidean 5-space? Find a formula in terms of N for the number of vertices and edges of an N-cube. 2. Find an example subspace of R N of dimension k for each k - 0, 1 , . . . , N. 3. Show that the system of inequalities 2.14, 2.15, and 2.16 is sharp for every N by finding example vectors in C N that give equality. 4. Prove that the following are equivalent: (i) (ii)
Ilx + yl a;
~
IIxll + Ilyl and
IlaxII -
al IIxll, for all vectors x, y and scalars
IIx + yll <__ [al IIxll + Ibl Ilyll, for all vectors x, y and scalars a, b.
5. Show that for any subset Y of an inner product space X, we have Y Cl Y ± = {0}, and Y c ( Y ± ) ± . (This is Lemma 2.5.) 6. Suppose that Y - span {Yn " n - 1 , . . . , N}. Show that if (x, yn} - 0 for all n, then x c Y ± . (This is Lemma 2.6.)
66
CHAPTER
2.
SPACE AND LINEARITY
7. Find an orthonormal basis for the subspace of E 4 spanned by the vectors x - ( 1 , 1 , 1 , 1 ) , y - (1, 0, 1,0), and z - (1, 0, 0, 1). 8. Let { e l , . . . , eN} be the standard basis vectors of E N (defined by Equation def 2.7) and, for notational convenience, put eN+l -- 0. Show that {f" - en en+l " n - 1 , . . . , N} (see Equation 2.34) is the biorthogonal dual of the basis {f~-el+...+en" n-l,...,N} (see E q u a t i o n 2 . 8 ) . 9. Prove that the inner product given by the Riemann integral (U, V} def 1f 1 u ( t ) v ( t ) dt Jo
is defined for all continuous functions u - u(t) and v - v(t) on 0 _< t _< 1, and is Hermitean symmetric, nondegenerate, and linear. 10. Prove that the operator n o r m [l'[]op satisfies the norm axioms and is submultiplicative. 11. Prove that the Hilbert-Schmidt norm II']]HS defined by Equation 2.44 satisfies the norm axioms and is submultiplicative. 12. Suppose that A, B c M a t ( M
x N). Prove Equation 2.47:
( A , B } - tr ( A ' B ) - tr (BA*) - tr (AB*) - tr ( B ' A ) .
Deduce that
IfAllHs- v/tr
(A *A) - V/tr ( A A * ) .
13. Suppose that Y - { y l , . . . ,YN} is a finite orthonormal subset of an inner product space X. Prove that the transformation P y defined by
Pyx
N def - Z{Yk'X}Yk k=l
is an orthogonal projection onto span Y. (This establishes Equation 2.49.) 14. Suppose that X is an infinite-dimensional inner product space and Y - {Yn " n E Z +} is an orthonormal subset of X. For any x C X and all n - 1, 2 . . . , put c ( n ) - (yn, x} and define the partial sums N
XN ~ E c ( n ) y n , n=l
a. Prove Bessel's inequality: For any N -
N-
1, 2, . . . .
1, 2 , . . . ,
N
E
n--1
Ic(n)l 2 -IIxNI 2 _ IIx 12
2.3, E X E R C I S E S
67
b. Prove Parseval's formula: (X)
lim [IXNl[2 - E
N---+c~
[c(n)12 --Ilxll2
¢---->
IIx- XN[I- 0.
lim
N---+o~
n--1
15. Prove that the linear transformation T" g2 ___,~2 defined by T(Xl,
X 2 , . . .) -
(Xl,2X2,...,nXn,...)
is unbounded. (This is example 5 in section 2.2.) 16. Prove t h a t a i j ( O ) - 1 - a i j ( - O ) - aji(O) - aiS(O), where i ¢- j and Gij(O) is a Givens rotation as defined in Equation 2.53. 17. Prove Equation 2.57, namely, that for all k /1
--1
1,..., N-
1,
1
"..
"..
1 l(k+l,k) • .
l(N,k)
_ ..
1 -l(k+l,k) •
•
.
1
-l(N,k)
.. •
1
18. Prove that the product of two lower-triangular N x N matrices is lowertriangular, and that the product of two upper-triangular N x N matrices is upper-triangular. 19. Write a computer program to visualize the rotated four-dimensional unit cube. Have it perform the following steps: 1. Choose six angles {Oij • 1 <_ i < j <_ 4} from user input. 2. Apply the six Givens rotations {Gij(Oij) • 1 <_ i < j <_ 4}, in a fixed order, to all the vertices Q 0 , . . . , Q15 of the four-dimensional unit cube, as listed in Table 2.2. 3. Find the orthogonal projection into xyz-space of the rotated vertices. 4. Find the perspective projection onto the xy-plane of the points in xyzspace. 5. Connect the vertices in the xy-plane with the edges listed in Table 2.2, and display the resulting graphic.
CHAPTER 2. SPACE AND L I N E A R I T Y
68
2.4
Further Reading Wolfgang Boehm and Hartmut Prautzsch. Geometric Concepts for Geometric Design. A K Peters, Ltd., Natick, Massachusetts, 1994. ISBN 1-56881-004-0. David Holzgang. Understanding PostScript Programming. Sybex, San Francisco, 1987. ISBN 0-89588-396-1. Joan L. Mitchell, William B. Pennebaker, Chad E. Fogg and Didier L. LeGall. MPEG Video Compression Standard. Chapman and Hall, New York, 1996. ISBN 0-412-08771-5.
• Gilbert Strang. Linear Algebra and its Applications. Harcourt, Brace, Jovanovich, San Diego, third edition, 1988. ISBN 0-15-551005-3. • Daniel Zwilllinger, editor. Standard Mathematical Tables and Formulae. CRC Press, Boca Raton, Florida, 30th edition, 1996. ISBN 0-8493-2479-3.
Chapter 3
Time and Frequency 3.1
Fourier Analysis
The amount of work needed to compute a transformation of a function depends quite heavily on the way it is represented by the computer. There are many advantages to using combination of more basic functions. In the early 19th century, Jean-Baptiste Joseph Fourier chose sines and cosines as building blocks because he could obtain easy formulas for their derivatives. His work, augmented by many other researchers, showed that any given smooth function can be approximated arbitrarily well by a finite linear combination of sines and cosines. The number of components depends only on the smoothness of the target function and the desired degree of approximation. Such expansions provide compact descriptions of complicated functions and simplify the transmission and display of multimedia information. In addition, a Fourier sine component such as A sin(27ra~t- 5) has three identifying parameters with physical meaning: its amplitude A, its frequency co, and its initial phase 5. Thus, the analysis of a complicated function into its Fourier sine and cosine components splits it into parts labeled for content. The formulas used in Fourier analysis are the same as those for finding expansions of vectors in an inner product space: let {en = e~(t)} be an orthonormal basis for an inner product space X of functions, and let f = f(t) be an arbitrary function in X. Then
s- EI o,s> o. '#7,
There are various technical difficulties to overcome when the index n ranges over an infinite set such as Z, even though any given Fourier expansion will ultimately be truncated to a finite series for computation. Also, Fourier's choice of sines and cosines for the basis {e~} has certain peculiarities, and some seemingly harmless combinations with other approximations can result in large errors. Still, discrete Fourier transforms are the single most important process applied to digital signals. 69
C H A P T E R 3. T I M E A N D F R E Q U E N C Y
70 3.1.1
Periodic
functions
A function f - f ( t ) defined at all real t is called periodic, or T-periodic, if there is some T > 0 such that
f(t) - f ( t + T),
for every number t E R.
(3.1)
If such a T exists, then f ( t ) - f ( t + 2T) - f ( t + 3T) - f ( t - T) - f ( t - 2T), and so on, for every t c R. Any such T is called a period of f. Some natural examples are trigonometric functions like sine and cosine, which are 27r-periodic. Here it is common to refer to "the" period since 27r is the least positive T t h a t works. Another easy example is any constant function, but this is T-periodic for all T > 0 and has no least period T > 0. All values of a T-periodic function are determined by its values on the interval [0, T), or more generally on any period interval [a, a + T) or (a,a + T]. Thus, computing sin t for 0 _< t < 27r or equivalently for -Tr < t < 7c determines its values at every t. The T,periodization of an arbitrary function f - f(t) is the new function defined by the infinite sum oo
fT(t) -- E
f ( t + kT),
for any number t C R.
(3.2)
k~--OO
If f is continuous and decreases to 0 rapidly enough as t tends to +oc, then the series converges and the result is T-periodic: 3.1 Suppose that f - f (t) is a function defined on R such that the integral f : f ( t ) d t exists on every interval [a, b] c R, and such that If(t)l < C/Itl 2 for some constant C > 0 and all t c R . Then
Lemma
a. The improper integral f_o~ f ( t ) dt exists. b. For any T > O, the T-periodization fT of Equation 3.2 exists at every t, is T-periodic, is integrable on each period interval [a, a + T], and satisfies
// cx~f(t) dt - lIT fT(t) d t - fa+T aa fT(t) dt, Proof:
for every a C R .
Define In - f~-n f ( t ) d t for every n E Z +. Then if m _> n _> N E Z +, we
have
F
IZm-- l
m
<
f (t) dt -
f
f (t) dt n
f_n ]f(t)l dt + f mIf(t)] dt m
<
2C f ;
dt t--ff _- 2 C / N ,
3.1. F O U R I E R A N A L Y S I S
71
so {In " n - 1, 2 , . . . } is a Cauchy sequence. Call its limit I ~ ; then similar estimates show that for every e > 0 there is an N~ C Z + such that I fba f ( t ) d t whenever a, b > N~. Thus f _ ~ f ( t ) d t -
I~] < c
I ~ exists.
For t E [0, T], the series fT(t) de_f ~-~ f ( t + nT) converges absolutely by comparison with }-~n¢0 C/InT] 2" For other intervals [nT, (n + 1)T], the same argument works after a change of summation index. Hence fT is defined on all of R. The same argument also shows that fT is T-periodic. To compare integrals, note that for any two positive integers N, M, we have
fo
T M-1 ~
f (t + nT) dt
~1
=
n=--N
fOT
f (t + nT) dt
n=-N
M-l f(n+I)T E f(t) dt -
=
n - - - N J nT
/MT
f(t) dt.
NT
Taking the limit N, M ~ c~ gives the first claimed equality. Finally, write a - a' + nT, where n - [a/T] is the greatest integer in a/T, and a' - a - n T is the nonnegative fractional part left over. Then since fT(t + nT) -fT(t) at every t C R, we have
faa+T ~aa'+T /aT fT(t) dt --
,
fT(t) dt -
, fT(t) dt +
/~'+T
fT(t) dt --
~0 T
fT(t) dt.
The last step is the change of variable t ~-- t + T followed by recombining the resulting integrals. [] More careful analysis reveals that the weaker condition of absolute integrability, which requires some decrease on average as t ~ +c~, is enough to give the same conclusion. See, for example, Theorem 10.26 on page 309 of Apostol's Mathematical Analysis, in the further readings. For the first example, we consider three periodizations of the hat function h with k - n 0 defined in Equation 2.22: 0,
h(t) -
t + l, l-t,
ift<-lort>l; if-l
This vanishes outside [-1, 1], so it certainly satisfies the decay-at-infinity condition. T-
1.
The l-periodization of h is hi(t) - E
h(t + k) - h(t + kl) -~- h(t + k2),
kCZ where kl, k2 are integers satisfying t + k 1 C [-1, 0) and t -~- k 2 E [0, 1). Thus -1 - t <
~I <
--t and -t _< k2 < -t + i, so ~2
-- [ - - t -
lJ and ~2
--
[-tJ -
kl + 1. But then hi(t) - (t + kl)-[- 1 + 1 - (t + k2) - 1 for all t E R: the l-periodized hat function is the constant function 1.
72
CHAPTER 3. TIME AND FREQUENCY
T-
2. For each t C R, suppose that t + 2k E [-1 ' 1) " Then - 12- t <- - k < 1 2- t - 12- t p 1 ' so there is a unique k0 - [-t2-:l j E Z such that h i (t) - - h(t -]- 2k0) The graph of h2 consists of adjacent, nonoverlapping copies of h.
T-3.
Suppose that t + 3 k c [ - 1 , 1 ) for some integer k. T h e n - 3 k - 1 < t < - 3 k + 1, so t must be within i of an integer multiple of 3. If not, then ha(t) - 0 is given by a sum of zeroes. The graph of h3 thus consists of nonoverlapping copies of h, centered at integer multiples of 3, separated by gaps of the zero function on intervals of the form (3k + 1, 3k + 2), k E Z.
For another example, consider the function
f(t)
_ S 2 -t, 0,
if t>_0, otherwise.
This satisfies the rapid decay condition If(t){ < 1/t 2 as t + +oo, and it is certainly integrable on any interval [a, b]. To compute the 1-periodization, note that t + k >_ 0 ,z---->, k _> - t ¢--> k _> [ - t 1 - - / t ] , so that the substitution k ~ k ' - It] gives oo
E f(t + k) - E kffZ
2-k'+LtJ-t = 2 - 2 LtJ-t
k'=0
which consists of adjacent, nonoverlapping copies of the portion of g(t) = 2 . 2 -t that lies over [0, 1). It is difficult to derive properties of a function from its periodization since every value of a periodized function is the sum of infinitely many values of the original function at arbitrarily distant points. A function f = f(z, y) of two variables may be S-periodized in the first and T-
Em,nCZ
periodized in the second by the formula f ST(X, Y) de__f f (x + roT, y + nS). In general, given a vector of periods W - (T(1), ,T(N)), we may periodize a function f = f ( x ) of N variables x = ( x ( 1 ) , . . . ,x(N)) by fT(X) de_f E kCZ
f(x(1)+ k(1)T(1),...,x(N)+
where the sum runs over all lists k 3.1.2
k(N)T(N)),
(3.3)
N
( k ( 1 ) , . . . , k(N)) of N integers.
Localization
A periodic function f is like the signal from a stuck record, repeating the same notes over and over. A more general signal will change with time and should be localized for study. The simplest way to localize is to restrict to an interval of interest, setting the function to zero outside. Thus, suppose f = f(t) is defined at all real t. The localization of f to a closed and bounded interval I = [a, b] C R is the function f(t), if t E I, (3.4) 1if(t) 0, otherwise.
3.1.
FOURIER ANALYSIS 1 Continuous
-0.2
73
Derivative
2 Continuous
0.8
0.8
0.6
0.6
0.4
0.4
0.2
0.2
0.2
0.4
0.6
0.8
1
1.2
-0.2
0.2
0.4
Derivatives
0.6
0.8
1
1.2
Figure 3.1" Cosine-based window functions with 1 and 2 continuous derivatives In other words, localization to I multiplies f by 1i, the indicator function of the interval. T h e definition m a y also be applied to other kinds of intervals, like I = (a, b) or I = [a, b). In general, a function f = f ( t ) is said to have compact support if there is some closed and b o u n d e d interval I = [a, b] such t h a t f ( t ) = 0 for all t ~ I. Such an f is said to be supported on I. A simple example is the zero function, which has compact support using any I. Less special is 1, which has compact support and _t 2 is s u p p o r t e d on [0, 1]. T h e function g(t) - e , which is never zero and therefore not compactly supported, m a y be described as s u p p o r t e d on all of R. But the restriction of any function f to a b o u n d e d interval I will have compact support, and l i f will be s u p p o r t e d in I. Even if f is continuous, its localization need not be: there m a y be j u m p discontinuities at the endpoints a and b of I. But if f ( a ) = f ( a + ) = 0 and f ( b ) = f ( b - ) = 0 and f is continuous at each t E (a, b), then 1 i f is continuous. If in addition f satisfies a Lipschitz condition on I, t h e n the localization 1 i f will satisfy a Lipschitz condition on all of R. A more sophisticated solution is to s m o o t h the cut by pinching the ends down to zero. Let u = u(t) be a "window function" such as the one defined below, which is called a Hanning window: u(t)
-- { 0,1 1 -~cos27rt,
its graph is plotted in the left tinuous derivative: u ' ( 0 + ) = 0 + 7rB sin(27r-) = 0 = u ' ( l + ) , and t = 1. T h e Harming window is one
u(t) -
if t < 0 or t > 1; if0
(3.5)
half of Figure 3.1. This function u has one con0 + 7rBsin(27r0+) = 0 = u ' ( 0 - ) and u ' ( 1 - ) = so the derivatives of the pieces m a t c h up at t = 0 m e m b e r of a family of functions of the form
A - B cos 27rt + C cos 47rt, O,
if t E [0, 1], otherwise.
Such a u can be m a d e s m o o t h e r by choosing C # 0 as follows: note t h a t for all windows in the family, u(O+) = A - B + C = u ( 1 - ) , u'(O+) = u ' ( 1 - ) = O, and u " ( 0 + ) = 47r2B - 167r2C = u " ( 1 - ) .
74
CHAPTER
3.
TIME AND FREQUENCY
1 0.8
-
iI
,
,
,
_
0.5
0.5
1
1.5
•
l
l
l
I
2
Figure 3.2: Wide H a n n i n g window function.
Since u ( 0 - ) = u ' ( 0 - ) = u " ( 0 - ) = 0 and u ( l + ) = u ' ( l + ) = u " ( l + ) = 0, continuity at 0 and 1 of u and its first two derivatives requires A - B + C = 0 and B - 4 C = 0. It is also convenient for u to have m a x i m u m value 1, but this must occur at the critical point t - 1 where u(t) - A + B + C. T h e resulting s y s t e m of three linear equations has a unique solution A = 0.375, B = 0.500, and C = 0.125, which gives the window illustrated in the right half of Figure 3.1. It has an additional nice p r o p e r t y since cos 4 7 r t - 2 cos 2 2 7 r t - 1" g1 (3 - 4 cos 27rt + cos 47rt) - ~1 ( 1 -
u(t)-
cos 27rt) 2 _> 0,
for all t c [0, 1]. Evidently, this window is the square suggesting a generalization: let un(t) = [(1 - c o s 27rt)/2] n 0 elsewhere. T h e n u n will be continuous and will have n well as being nonnegative with m a x i m u m value 1 at t a sum of cosines; it will have n + 1 t e r m s since - 2-n 2
(-1) k
of the H a n n i n g window, for t C [0, 1], with un(t) = continuous derivatives, as 1 We m a y e x p a n d u n as 3"
cos 27rkt.
k=0
This expansion is called the Fourier series for u n. R a t h e r t h a n pinch off the signal within the interval of interest to get a s m o o t h function, we can mix in parts of the signal just outside the interval by using a wider window. For example, let I = [0, 11 and define w = w(t) by w(t)
_ ;
/
0, (1 + sin 7rt) / 2,
3 _~fi ft <1<-~ <3°rt > 3; "1-2 - 3"
(3.6)
Its graph is plotted in Figure 3.2. This is just the H a n n i n g window composed with 1 and has the same smoothness: continuity and one the substitution t ~ ~l ( t + 3), continuous derivative. Periodic
extension
A function localized to a b o u n d e d interval I can always be periodized since the sum in E q u a t i o n 3.2 will be finite for any T > 0. A n a t u r a l choice of period is T = I I I ,
3.1. F O U R I E R A N A L Y S I S
75
b
Figure 3.3: Top: Graph of an example function f defined on I = [a, b). Bottom: Partial graph of the periodic extension fI of f. Note the j u m p discontinuities and the agreement with f on I.
for which the sum will have exactly one 1 potentially nonzero term. So, define the periodic extension of f from I = [a, b) to be
fi(t) - E
( l i f ) ( t +klII).
(3.7)
kCZ
In fact f i ( t ) = f(to) for all t e R, where to = to(t) e I is the unique number such that t - to is an integer multiple of III = b - a. This relationship may be described by the equation to = t mod I. (3.8) Then f~ is I/I-periodic since for all t e R, f i ( t + III) = f ((t +III) m o d I ) = f (t m o d I ) = fi(t). Also, fI agrees with f on I. Periodic extension is depicted in Figure 3.3. Even if f is continuous, fI need not be unless there are no jump discontinuities at the points t = a + k ( b - a) "between periods," where k is an integer. But continuity is guaranteed simply by requiring f(a) = f(b): L e m m a 3.2 Suppose that f = f ( t ) is defined on [a, b] with f(a) = f(b). I = [a, b) and let f~ be the periodic extension of f from I. Then
Put
1. If f is continuous on [a, b], then f1 is continuous on R. 2. If f e Lip[a, b], then fI e L i p ( R ) . Proof: For 1: Given t E R, let to = t m o d / . Ift0 C (a,b), then f x ( t - ) = f ( t o - ) = f(to) = fi(t), and f i ( t + ) = f(to+) = f(to) = fi(t), since f is continuous at to. Thus f1 will be continuous at t. 1 E n d p o i n t s m a y c o n s p i r e , so we will a l w a y s a s s u m e t h a t one of t h e m is missing: I = [a, b) or I = (a,b].
C H A P T E R 3. T I M E A N D F R E Q U E N C Y
76
Otherwise to - a, and then f i ( t - ) - f I ( b - ) - f ( b - ) - f(b) - f ( a ) - f i ( a ) , and f i ( a + ) - f ( a + ) - f ( a ) - f i ( a ) , since f is continuous from the left at a and from the right at b. Again, f1 will be continuous at t. For 2: Given s, t c R, let so - s mod I and to - t mod I. If Is0 - t01 _< Is - t[, then I f i ( s ) - fi(t)l - I f ( s o ) - f(to)l < C I s o - t o J <_ c l s - t l , where C is the constant in the Lipschitz condition for f. Otherwise, Is0 - t01 > Is - tl. We may assume without loss of generality that a _< So _< to < b, and then I s o - to + ( b - a)l < I s - tl. Since f ( a ) - f(b), we may write I f I ( 8 ) - fl(t)l - If(so) - f(to)l - If(so) - f ( a ) + f ( b ) - f(t0)] <
If(so)- f ( a ) l + l f ( b ) - f(to)l <_ C l s o - a l + C I b - t o l - C l s o - t o + ( b - a ) l < C s - t l . []
To insure that fI has as many derivatives as f, we must match the derivatives at a and b as well" C o r o l l a r y 3.3 Suppose that f - f (t) is defined on [a, b] with f (a) - f (b). Put I - [a, b) and let f I be the periodic extension of f from I. Suppose further that f is d-times differentiable on (a, b), with the endpoint limits agreeing for every 0 < n <_ d as follows:
f(n) (a-~-) de__f
lim f(n)(t) t-,a+
lim f(~)(t) de__f f(n)(b-). t--~b-
Then f1 is d-times differentiable on all of R . Proof." Apply Lemma 3.2 successively to f, f f , . . . , f ( a ) , f(n) (b) -- f(n)(a+) -- f ( n ) ( b - ) for n - 0, 1 , . . . , d.
and define f(n)(a)
[]
A function f - f ( t ) is said to be d-times continuously differentiable on R , or in the class Cd(R), for some nonnegative integer d, if f ( t ) and the derivatives f ' ( t ) , f " ( t ) , . . . , f(d)(t) exist at each t E R and give functions f, f ' , . . . , f(d) continuous on R. Similar definitions can be made for the class c d ( I ) on any open interval I - (a, b). Such functions are also said to be smooth of degree d. If f belongs to Cd(R) for all integers d >_ 0, we say that f is smooth, without qualification, or that f belongs to C ~ (R). Some examples of smooth functions are: polynomials, including constant functions; sine, cosine, and exponential functions; arctangent; hyperbolic sine, cosine, and secant. Products, sums, compositions, derivatives, and antiderivatives of smooth functions are also smooth, as is shown by elementary calculus. In particular, for products of smooth functions, we use Leibniz' rule for the ~tth derivative of a product of two functions:
(fg)(-)-
(3.9)
k=0
Here f(0) def f and g (°) def - g. Otherwise, f(k) is the k th derivative of f, while g (n-k) is the ( n - k) th derivative of g. The binomial coefficient symbol appearing in the sum is the integer coefficient of the x k term in (x + 1) n, expanded out: -
(~) dej
Tt!
k)!
(3.10)
3.1.
FOURIER ANALYSIS
77
S m o o t h local p e r i o d i z a t i o n After localization with a power u n of the Hanning window of Equation 3.5, the function u n f satisfies [unf](d)(o) = [unf](d)(1) = 0 for d = 0 , . . . , n . Hence, its 1-periodic extension will be in Cd(R) by Corollary 3.3. However, a portion of the signal energy within the window is lost, and the operation is not invertible. If instead we use the wide Hanning window of Equation 3.6, then the 1-periodic function fl(t) de__f E [wf](t + n), nCZ
where
wf(t)
def - w(t)f(t),
1 ~]; 3 the parts from contains parts of the signal on [-~, outside [0, 1] are said to be aliased into the period interval by the summation. Notice that there are at most two nonzero terms in the sum for any t. This also makes the operation noninvertible. Periodized, the wide Hanning window by itself becomes identically 1 because
nCZ
1 [2 + sin 7rt + sin rr (t + 1)1
i f 0 < _ t < ~ ;1
~112 + sin rc(t - 1) + sin rrt] '
if ~1 <_t < 1
=1,
since sin 0 + sin(0 -+- 7r) = 0 for all 0. The Fourier series of this periodization has a single trivial term, namely 1 = cos 0t. One consequence is that if f is 1-periodic, then f and the 1-periodization of w f are identical. Powers of the wide Hanning window do not periodize to the constant function, but there is another way to generalize. Take w as in Equation 3.6, put w0 = w, and for m > 0 define
win(t)--
1 W m _ l ( ~ sin rrt),
O,
1 ~], 3 if t E [-~, otherwise.
Using Leibniz' rule, it is possible to show that wm has 2 "~ continuous derivatives on R. Figure 3.4 shows w4 for comparison with Figure 3.2. These smoother wide Hanning windows periodize to the constant function 1 as well: for any m >_ 0, E Wm(t + n) -- 1. nCZ There is a third way to localize a function and make it periodic while preserving any smoothness it had originally. This is done by "fraying" the function around the endpoints of an interval, introducing particular boundary conditions, then "splicing" the pieces back together smoothly after periodic extension. It is done in such a way that the aliased portion of the signal from outside the interval cancels itself during periodization, making the operation invertible. Let r - r(t) be a function in the class Cd(R) for some 0 _< d <_ oo, satisfying the following conditions: Ir(t)l 2 + r ( - t ) I 2 - 1
foralltER;
r(t)-
{0' 1,
if t < - l , i f t >__1.
(3.11)
CHAPTER 3. TIME AND FREQUENCY
78 i
0.8 0.6
-'i
f
-0.5
•
1
0.5
.
,
1.5
" " • i
Figure 3.4" Smoother wide Hanning window function with four continuous derivatives.
f 0
-1
Figure 3.5" Example of a once-differentiable rising cut-off function.
The function r need not be increasing or even real-valued. It is called a rising cut-off function because r(t) rises from being identically zero to being identically one as t goes from - o c to +oc. A general construction for such functions is given in Appendix B. One example of a real-valued, continuous rising cut-off function is the following: 0, if t < - 1 , r(t)sin [ ¼ ( l + t ) ] , if-l
def_ r ( t ) ;
rrn+l(t)
def_
rm(sin-~t).Tr
(3.13)
Proof by induction may be used to show that rm (t) has 2 m - 1 vanishing derivatives at t = +1 and t = - 1 , so that rm C C 2"~-1. The case rl 6 C 1 implemented here is depicted in Figure 3.5.
Once-Differentiable Rising Cutoff Function rl( [0] [i] [2]
t ): If t < - I , then return 0 If t > i, then return 1 Return sin(O.25*PI*(sin(O.5*PI*t)+l.O))
3.1. F O U R I E R A N A L Y S I S
79
Now define a fraying operator F and a splicing operator S as follows:
Fu(t)
-
r(t)u(t) + r ( - t ) u ( - t ) , f(-t)u(t) - f(t)u(-t), u(0),
s (t)
-
{
g(t)u(t) - r ( - t ) u ( - t ) , r(-t)u(t) + ~(t)u(-t), u(0),
if t > O, if t < O, if t - 0;
(3.14)
if t > 0, if t < 0, if t - 0.
(3.15)
Since Fu(t) = u(t) and Su(t) = u(t) if t > 1 or t < - 1 , b o t h m a y be said to have [-1, 1] as their reach interval. T h e r e is nothing special a b o u t the point 0 or the reach 1. F and S can be moved to the reach interval [ a - e, a + e] with the formulas of E q u a t i o n 3.20 further on. T h e midpoint a is t h e n the fraying or splicing point, and e > 0 is the reach. m
Fraying and splicing operators are linear t r a n s f o r m a t i o n s on the vector space of functions on R. If they use the same fixed rising cut-off function r over the same reach interval, then t h e y are inverses. For example, fraying at 0 with reach 1, we have FSu(O) = u(O), SFu(O) = u(0), and for all t 7~ 0,
PSi(t)
_
=
sF (t)
f r(t)Su(t)+ r(-t)Su(-t), ~(-t)Su(t) - ~(t)Su(-t),
r(t)[e(t)u(t) - r ( - t ) u ( - t ) ] +r(-t)[r(t)u(-t) + e(-t)u(t)],
ift >0,
~ ( - t ) [ r ( - t ) u ( t ) + ~(t)u(-t)] -e(t)[ff-t)u(-t) - r(t)u(t)],
if t < 0;
=
(Ir(t)[ 2 + Ir(-t)12)u(t)
_
f f(t)Fu(t) - r(-t)Fu(-t), r(t)Fu(t) + f(t)Fu(-t),
_
=
if t > 0, if t < 0;
-
u(t); if t > O, if t < 0;
~(t)[r(t)u(t) + r ( - t ) u ( - t ) ] -r(-t)[fft)u(-t) - ff-t)u(t)],
ift >0,
r ( - t ) [ ~ ( - t ) u ( t ) - ff t ) u ( - t ) ] + ~ ( t ) [ r ( - t ) u ( - t ) + r(t)u(t)],
if t < 0;
([r(t)] 2 + Ir(-t)12)u(t)
-
u(t),
T h e values F u ( a ) and S u ( a ) at the fraying or splicing point a do not m a t t e r in practice since in any i m p l e m e n t a t i o n using samples of u at integers, we can use a - - 3 1 to avoid using or defining F u or S u there. Likewise, in practice we use a nonnegative integer e as the reach. For greater generality of implementation, we split the array of samples into its two halves: the samples u n e g [ - e ] ,... , u n e g [ - 1 ] to the left of the fraying point, and the samples upos [0] ,... ,upos [ e - i ] to the right of the fraying point. T h e results replace the values in the input arrays:
80
C H A P T E R 3. T I M E A N D F R E Q U E N C Y
-.( Figure 3.6: Action of fraying on the constant function u(t) - 1.
F r a y i n g at a P o i n t B e t w e e n T w o A r r a y s of S a m p l e s fray(
u n e g [ ] , u p o s [ ] , e ): [0] For k=0 t o e - l , do [1] t o [4] [1] Let t = ( k + 0 . 5 ) / e , l e t rp = r l ( t ) , l e t rn = r l ( - t ) [2] Let up = upos[k], let un = uneg[-l-k] [3] [4]
Let Let
upos[ k ] = rp*up uneg[-1-k] = rp,un
+ rn*un - rn*up
Splicing is implemented in virtually the same way, with just a change of sign in steps 3 and 4: Splicing at a P o i n t B e t w e e n T w o A r r a y s of S a m p l e s s p l i c e ( u n e g [ ] , u p o s [ ] , e ): [0] For k=0 t o e - l , do [l] to [i]
Let
[3']
Let
[2]
[4']
Let
Let
t =
up
(k+O.5)/e,
= upos[k],
upos[
let let
k ] = rp*up uneg[-l-k] = rp*un
[4'] rp
un
= rl(t),
let
= uneg[-l-k]
rn
= rl(-t)
- rn,un + rn,up
Figure 3.6 shows F u for the example u(t) - 1, using the cut-off function rl defined in Equation 3.13. Notice how fraying introduces a very particular discontinuity at 0. Splicing takes any function with such a break and repairs it into a smooth function. L e m m a 3 . 4 Suppose r E Cd(R) for some O < d < ce. If u E Cd(R), then F u has d continuous derivatives in R \ {0}, and for all 0 ~_ n ~ d there exist limits [Fu](n)(o+) and [Fu](~)(0 - ) which satisfy the following conditions: [Fu] (n) (0-~-) - 0
fo~" odd n;
[Fu] (n) ( 0 - ) - 0
for even n.
(3.16)
Conversely, suppose that u belongs to C d ( R \ { 0 } ) a n d has limits u(n)(0+) and u(n)(0 - ) for all 0 <_ n < d satisfying the equations u (n) (0+) - 0
for odd n;
u (n) ( 0 - ) -
Then Su(0+) - S u ( O - ) , and if we define Su(O) belong to Cd(R).
0
for even n.
(3.17)
limt_~oSu(t), then S u will
3.1. F O U R I E R A N A L Y S I S
81
Proof: The smoothness of F u and Su on (0, oc) and ( - o c , 0) is elementary. To prove Equation 3.16, calculate the one-sided limits of the derivatives of F u with Leibniz' rule, Equation 3.9. Since r(~-k)(0+) -- r(~-k)(0--) -- r(n-k)(0), the resulting expressions factor as follows:
r(n-k)(O) [u(k)(0+) + ( - 1 ) n u ( k ) ( 0 - ) ] ;
(3.18)
(-- X)kr(~-k> (0) [ (-x)"u(k>(0-> --u(k>(0+)] "
(3.19)
[Fu] (n) (0+) -- E k=0
[Fu] (") ( 0 - ) -
E k=0
If n is odd, with 0 _< n < d, then u(k)(0+) - u(k)(0 - ) - 0 in the right-hand side of Equation 3.18 since u (k) is continuous at zero for all 0 _< k < d. If n is even, then u(k)(0 - ) - u (k) (0+) - 0 in the right-hand side of Equation 3.19 for the same reason. To prove that defining Su(O) - Su(O+) gives Su(t) all d continuous derivatives at t - 0, use Leibniz' rule and Equation 3.17 to evaluate the following one-sided limits for 0 < n < d:
[s~] (~) (0+)- [s~] (~) (0-) -- E
-
r(n-k)(O)u(k)(O+) - (--1)nr(n-k)(O)u(k)(O--)
k=0
_ ( _ l ) ~ - k r ( ~ - k ) ( 0 ) u ( k ) ( 0 _ ) _ (--1)kr(n-k)(0)u(k)(0+)] = E
{1 - ( - 1 ) k} r(~-k)(0)u(k)(0+)
k--0
- ( - 1 ) n {1 + ( - 1 ) k } r(n-k)(O)u(k)(O--)]. But { 1 - ( - - 1 ) k } u ( k ) ( 0 + ) _
-- 0 and {1 + (--1)k}u(k)(0--) -- 0 for all k, so the
difference is zero. Thus limt__,o [Su] (n) (t) exists for 0 < n < d, since the one-sided limits agree. Call it [Su] (n) (0). The special case n - 0 yields [Su] (°) (0) - Su(O) -
s ~ ( o + ) - s~(o-). It remains to show that [Su] (n+l) (0) -
(
[Su] (n)
)'
(0) for each 0 _< n < d. But
by the Mean Value Theorem, for each t -¢ 0 there is some to between 0 and t such that
[s~l (~) (t)- [s~] (~) (0) t
= [s~] (~÷1) (to)
Letting t ~ 0 in this equation yields the result.
[]
Notice that the constant zero function f ( t ) - 0 satisfies Equation 3.17 at every point.
C H A P T E R 3. TIME A N D F R E Q U E N C Y
82
Fraying may be performed over an arbitrary reach interval [0/- e, 0 / + el, using the formula: +
F(r, 0/,e)u(t) -
-
t)
~i~-~A~t)u(t)- ~( t-~-T-)u(20/- t),'
if 0 / < t < 0/+e,
if 0 / - e < t < 0/,
(3.20)
otherwise. The formula for S(r, 0/, e), or splicing over [ 0 / - e, 0 / + el, is similar and left as an exercise. It is mostly shown in Equation 3.23 further on. The boundary conditions at 0/will be the same as the boundary conditions at zero described in Lemma 3.4. Likewise, splicing over this reach interval undoes the boundary conditions at 0/. Every e > 0 will yield the same boundary conditions. Suppose El = g(?~l, 0/1, e l ) and F2 = F(r2,0/2,e2) are fraying operators with reach intervals B1 -----[0/1- el, 0/1 ÷ el] and B2 --[0/2 --e2, 0/2 ÷ 62], respectively. If B1 and B2 are disjoint, then F1 and F2 can be evaluated as follows: i f t E B1; if t E B2; otherwise.
(3.21)
The same formula may be used to evaluate F2FlU(t), so the operators F1 and F2 commute. Likewise, splicing operators S1 -- ~ ( r l , 0/1, e l ) and $2 - S(r2, 0/2, e2) will commute with each other:
{
~lV(t),
SiS2v(t) -
S2v(t),
i f t E t31; if t E B2; otherwise,
-- S2~lV(t).
(3.22)
Similar formulas show that S1 commutes with F2 and $2 commutes with/71. The remaining pairs $1, F1 and $2, F2 commute because they are inverses. Let 0 / < / 3 define an interval, and choose 0 < e < 31 ( / 3 - 0/). A smooth function u frayed at t - 0/ and t - /3 with reach intervals B~(0/) and B~(/3), respectively, may have its ends spliced together with the loop operator: -7-
L(r, [0/, 31, e)u(t)
-
-
u(t), S(r, 0/, e)u/(t),
=
- - v - ) u ( 2 0 / - t),
r(~-t)u(t) + ~(t=--~)u(23- t),
S(r, 3, e)ui(t), u(t),
i f 0 / < t <_ 0 / + e , if 3 - e < t < 3, otherwise;
if 0 / < t < 0/+ e, if 3 - e < t < 3, otherwise.
(3.23)
Here u1 is the periodic extension of u from its localization to I, as defined in Equation 3.7. The smooth local periodization of a function is a combination of fraying at two points and splicing into a loop. Namely, suppose u = u(t) is a smooth function and I = [0/, 3] is an interval. Choose a smooth rising cut-off function r and a positive
3.1. FOURIER ANALYSIS
83
1 1 reach e satisfying e _< 3(/3 - c~) - 31II. The smooth periodization of u to I is the function (LIFaFou)I, (3.24)
where F~ = F(r, a, e), F z = F(r,/3, e), LI = L(r, [c~,/3], e), and the result is localized and periodically extended over the interval I. This is a smooth I/I-periodic function. For example, a smooth locally periodized segment of a sampled signal, with valid sample indices n E [a, b) C Z, may be obtained with the following algorithm: Local Periodization .
°
o n [a, b)
°
[1] Compute f r a y ( g~u[a], gin[a], e ) [2] Compute f r a y ( g~u[b], g~u[b], e ) [3] Compute s p l i c e ( g~u [b], g~u[ a ] , e ) °
.
Here g~u[a] signifies the shifted array whose element at index 0 is u [ a ] , and so on. The positive integer reach e must be at most half the distance b - a, and of course 1 then splice we must have b > a. These steps fray u at c~ - a - 31 a n d / 3 _ b _ 3, the positive a-end to the negative b-end. 3.1.3
Fourier
series
A Fourier series is one way to represent a periodic function f - f(t) of one real variable as a superposition of sines and cosines. We start with a fixed set {a(0); a(n), b(n), n - 1, 2 , . . . } of Fourier coefficients and define f as the limit of partial sums f N -- f N(t)"
fN(t)
N de__~_f a(0)-+- ~ a(gt)[V/2COS(271-nt)] rt:l N
[e sin(
;
n=l
f(t)
dem-f
lim fN(t), N--+OO
when this limit exists.
(3.26)
The finite sum fN(t) makes sense for every N. In fact it is a smooth 1-periodic function of t, belonging both to L i p and C °°. The limit f(t), on the other hand, may not exist at any t, and even if f(t) exists at every t, the resulting function may not be smooth, or even continuous. A Fourier series separates f into sine and cosine components with frequencies n and amplitudes a(n) and b(n), respectively. We may find these amplitudes by integration since sines and cosines are orthonormal 2 with respect to the inner product ( u , v ) - f l ft(t)v(t)dt on Lip. For fixed N, put FN -- { c 0 ( t ) - 1 ; c n ( t ) 2The strange factor x/~ is needed to get unit vectors.
C H A P T E R 3. T I M E A N D F R E Q U E N C Y
84
x/~cos(27rnt), S n ( t ) - v/2sin(27rnt) • n - 1 , . . . , N}. It is an exercise to show that F N C L i p is an orthonormal subset. Since f g belongs to span FN C Lip, the expansion coefficients are obtained by inner products" a(n) - (cn, f N} ,
a(O) -- (Co, f N) ;
b(n) - (sn, f N} ,
n-
1,2...,N.
This establishes a one-to-one correspondence between finite sequences of Fourier coefficients and partial sums of Fourier series"
FN) fN < {a(0); a(n), b(n), 1 < n < N}. The energy in the a(n) or b(n) component over one period is Ila(n)c,~[] 2 - l a ( n ) ] 2 or IIb(~D~nll ~ -Ib(~)l ~, respectively, using the norm derived from the inner product. L e m m a 2.9 says that these account for all the energy in the partial sum function: 1
N
IIZNII~-- A Ifg(t)12 dt -[a(0)l 2 + ~
(la(n)l 2 + Ib(n)L2).
(3.27)
n=l Note that for fixed n, a(n) - (cn, fN} and b(n) - (sn, fN} for any N > n. We may therefore construct an orthogonal projection 3 on L i p by M
pM u
M
(CO,U)-~ E (Crn,U)Crn nt- E (Srn,u)Srn,
dJ
m=l
(3.28)
m=l
which satisfies P M f N -- fM, for any M < N. This has the effect of truncating a Fourier series, approximating the limit f with fewer terms. Any f C L i p generates a set of Fourier coefficients"
1
~0
a(O)
-
(co, f )
-
a(n)
--
(c~, f )
-- x/2
b(n)
-
(sn, f} -
x/2
f (t) dt;
(3.29)
~01 f
(t) cos(27rnt)dr,
(3.30)
f (t) sin(27rnt) dt,
(3.3~)
for n C Z +. The partial sums then satisfy f N -- P N f for every N, and for all 0 < M < N we have Bessel's inequality: II/MII <_ II/gll--< II/LI. Therefore, EnN=I la(~)] 2 and EnN=I ]b(n)l 2 both converge as N ~ ec. We will prove in L e m m a 3.5 further on that I l f - f g l l ~ o as N ~ ~ , so that we have Parseval's formula for the infinite series:
I]fl] 2 - jr01 [f(t)l 2 d t -
]a(0)l 2 + EOO ( ]a(n).12 + Ib(n)12) " n--1 3Why is this a projection? Why is it orthogonal?
(3.32)
3.1. FOURIER ANALYSIS
85
These results follow from abstract properties of inner product spaces; see Section 2.3, Exercise 14. In other words, expanding in the orthonormal system F = {1; s,~, Cn, n C Z + } maps functions in L i p to sequences in 62. The mapping is one-to-one since any f, g C L i p giving (f - g, v) = 0 for all v C F will satisfy [If - g[[ = 0 by Parseval's formula. But then f = g since the derived norm is nondegenerate. Hence there is some subset of ~2 which is in one-to-one correspondence with Lip. Each Fourier sequence taken from this subset converges to some unique f C Lip: f(
F
~ {a(0),a(1),...;b(1),...}.
There is nothing special about the period 1. If g - g(t) is T-periodic, then
f(t) - STy(t) de_f v ~ g ( t T ) is 1-periodic. This 5T is the so-called dilation operator, which is a linear transformation from Lip[0, T] to Lip[0, 1], or more generally from functions on R to dilated functions on R. Thus g is represented by the Fourier series gN(t)--a(O)
+
a(n)
cos
27r~-
n=l
b(n)
+
sin
27r-~-
n=l
with g(t) = l i m N _ ~ gN(t) whenever the limit exists. This is an expansion in terms of orthonormal basis functions 5TC~ and 5TSn. The Fourier coefficients a(n), b(n) are again given by inner products, which in this case are the scaled integrals
a(O)
-
(hTco, g) --
g(t) dt;
a(n)
-
(hTc~, g) -- ~
b(n)
-
(hTSn, g) --
foT g(t) cos (27rT ) dt,
~/21
(ltt)
g(t) sin 2zr-~-
at,
for n C Z +. Because of the factor v/T, f has the same energy in one period [0, 1] that g has in [0, T], so Parseval's formula applies: IIg - ggll -~ o ~s N ~ oo, so
~0T Ig(t)l 2 dt - [ a ( 0 ) l 2 + ~oo (la(n)l 2 + Ib(n)l ). n--1
The integral giving 11g[[2 adds up energy over a single period, which may be considered a time interval. Energy per unit time is called power, and thus the listing {[a(0)12; [a(nD[2 + [b(n)[ 2, n = 1, 2 , . . . } of power by frequency index is called the power spectrum of g.
Exponential Fourier series Another basic 1-periodic function in L i p is en - en(t) de_f e2,i~t ' where n is an integer. This complex-valued function is unimodular in the sense that len(t)l - 1
C H A P T E R 3. TIME A N D F R E Q U E N C Y
86
for all n and all t. It has uniformly b o u n d e d derivative le~ (t)[ - 12~in e, (t)l - 27r[nl for every t C R, so it belongs to L i p ( R ) . It is also smooth, with d th derivative
~(d) (t) - (2~in) d ~.(t) for ~very d > 0 ~nd t e R, so ~. e C ~ ( r t ) for every n e Z. We can use the functions {en : n C Z} to define exponential Fourier series from partial sums a d e t e r m i n e d by a sequence { c ( n ) : n E Z} c C: N
1
fN(t) -- E c(n)e2~int; n=-N
c(n) -- {en, fl -- fo f(t)e-2~int dt.
(3.33)
T h e complex n u m b e r s (c(n) : n e Z} are also called the (complex exponential) Fourier coefficients of the function f . We will say t h a t the Fourier series converges if f (t) = limN--.c~ fN (t). Since e,~(t) - e 27tint - c o s ( 2 7 r n t ) + isin(27rnt) - -~2c,(t) + i~2s,(t), the exponential Fourier series is c o m p u t a b l e from the sine-cosine Fourier series of E q u a t i o n s 3.25, 3.29, 3.30, and 3.31. For n = 0, we have co = 1 = e0, and for n > 0 we have Cn(t) - x/~cos(27rnt) = [ e ~ ( t ) + e_~(t)]/x/~ and sn(t) = x/~sin(27rnt) = [en(t)- e-n(t)]/iv/2. Thus, given c(n) and c ( - n ) for n > 0, we recover a(n) and b(n) by the formulas
a(n)
=
1 v~~ (an, f}
=
c(n) + c ( - n ) ; x/2
b(n)
=
1 v~~ (sn, f}
=
~(~) - ~(-n) _iv/~
(3.34) =
~
c(n) - c ( - n ) V~
.
(3.35)
If we define {a(0); a(n), b(n), 1 _< n <__ N } this way from a given sequence {c(n) • - N <__n _< N}, we will have
N E
c(n)e27rint--a(O)+
n--N
N N E a(n)[V~cos(27rnt)] + E b(n)[x/~sin(27rnt)] . n=l
n-1
(a.a6) Conversely, for n > 0, 1
c(n) - --~ (on + isn, f) Vz
a(n) - ib(n)
v~
(3.37)
Since - n < 0 and sin(27r[-nlt) - - s i n ( 2 7 r n t ) and cos(27r[-n]t) - cos(27rnt), the negative-indexed coefficients satisfy
1 a(n) + ib(n) c(-n) - - ~ (Cn - i s n , f} -
(3.3s)
T h e remaining case of n - 0 gives c(0) - (1, f} - a(0). If we define (c(n)" - N <__ n <_ N } in this way from given {a(0); a(n), b(n), 1 _< n _< N}, we will again have E q u a t i o n 3.36.
4Reuse of the notation f N is justified by Equation 3.36.
3.1. FOURIER ANALYSIS
87
With matrices, for n > 0 we get
c(n) c(-n))
1
~(1
1 -i i ) (a(n)
a(n)
c(n)
1
i
--ilk
"
)"
It is not hard to check that these matrices are unitary. Complex exponential Fourier coefficients are computed via the formula c(n)
-
(e~, I} -
f0ef(t)e
(a.ag)
dt aoj
We can regard the computation f ~ f as a transformation from functions to sequences. It is a linear transformation with a domain containing Lip. By Parseval's formula, the range is a subset of ~2. The underlying functions superpose neatly to give everything in Lip: L e m m a 3.5 basis for Lip.
Proof:
The functions {e~ - en(t) de__fe 2 7 r i n t
. Tt C
Z}
are
an orthonormal
For orthogonality, note that if n, m are integers, then ( e n , era}
--
--
j~01 e2rrinte 2rrimt
{ ~ 0 =i e27ri(m_n)
t
1
dt
-0,
-
]£1
e 2rri(m-n)t dt
ifn¢m.
For completeness, it suffices to show that an arbitrary l-periodic piecewise linear function f c X satisfies IIf- fNII--~ 0 as N ~ ~ , where fN is the partial sum of f ' s exponential Fourier series, defined by Equation 3.33. But it is enough to show this for the general hat function determined by 0 _< a < b < c <_ 1"
-
f(t)
0,
i f t < a or t >
(t-a)/(b-a),
ifa_
(c- t)/(c- b),
c,
ifb_
That is because all piecewise linear functions are linear combinations of such f. The explicit approximation is left as an exercise. [] If e~(t) is replaced with e~(t/T)/x/~ for each n, then the same formulas work for T-periodic functions. In fact, the complex exponentials superpose to give all square-integrable functions, although in that case the Fourier series may not converge at every point 5 in the domain [0, 1]. Bessel's inequality, Parseval's formula, and Lemma 3.5 may be combined to yield the following, which is proved as Theorem 11.4, page 309 of Apostol's Mathematical Analysis:
5In 1966, Lennart Carleson showed that the Fourier series of a square-integrable function converges at almost every point in the domain.
88
CHAPTER 3. TIME AND F R E Q U E N C Y
C o r o l l a r y 3.6 A function f belongs to L2([0, 1]) if and only if the Fourier coefficients {c(n) " n C Z} for f belong to [2. In that case, the partial sums fN of f ' s Fourier series satisfy limN-~o~ I l f - fYll -- O, with the estimate I l f - fNl[ 2 =
El l>
[]
Suppose we reverse the construction. Starting with an infinite sequence c { c ( n ) ' n E Z} C/2, let us define its inverse Fourier transform to be the i-periodic function given by the following infinite sum:
cx:) (~(X) de__f E c(k)e2~ikx" k----o~
(3.40)
Then c ~ ~ is a linear transformation from sequences to 1-periodic functions. By Corollary 3.6, its domain is all of [2 and its range is L2([0, 1]). But there is a simple condition on c that suffices to guarantee ~ C Lip: T h e o r e m 3.7 If there is some fixed constant M such that the sequence c - {c(k) • k E Z} of complex numbers satisfies
N
Ikl Ic(k)l
M,
all integers N,
(3.41)
k=-N
then a. the partial sums ~y(X) dej ~-~kN=_yc(k)e27rikx converge absolutely to the inverse Fourier transform 5(x) de_f l i m N _ ~ ~N(X) of C; b. the function ~ belongs to Lip, with I~(x)-~(y)l < 27rMIx-yl, for all x, y e R. Proof: For (a), note that at any x E R, the Fourier series with coefficients c converges absolutely"
N E
N Ic(k)e2~ikXl- E
k=-N
N Ic(k)l -< Ic(°)l +
k=-N
E
Ikl Ic(k)l -< Ic(°)l + M,
k=-N
so since these sums increase with N and are bounded above, they must converge to a limit no greater than Ic(0)I + M, and independent of x. Absolute convergence of a series implies convergence, so the Fourier series ~(x) converges at every x. For (b), observe that for any t C R,
leu -
11 -- i ~0 t e ix dx
__ ~0 t I
ldx-ltl.
Thus Ie2~ikz - e2~ikY I - - I e2~ik(x-y) --11 _< 27rlk I Ix - Y l , for any x , y c R and any integer k. T h a t imposes a Lipschitz condition on the partial s u m Cg at any
3.1. F O U R I E R A N A L Y S I S
89
x, y C R: N
I~(x) - ~ ( y ) l
-
~
~(k)[ ~ : ' ~ - ~:'~]
k---N N
<__ 2~-Ix- yl Y~ Ikl [~(k)l
<_ 27rMIx
-
YL.
k=-N
But then by part (a), we may take limits as N ~ oc to get
I~(x)-~(y)l <_ 2~MIx-yl. []
S m o o t h n e s s and rapid decrease If f - f ( x ) is differentiable on [0, 1], then integration by parts gives the following formula for its (complex exponential) Fourier coefficients" i
if(n)
--
~01 fZ (X)C -21rinx dx
--
=
[e-2~inXf(x)]o1 + (27tin)
=
f(1)-
c -27rinx df (x)
/o 1 f ( x ) e
-2~i~xdx
f ( 0 ) + (27tin)](n).
Using induction, this extends to a formula for the Fourier coefficients of derivative d + 1 in terms of the d TM derivative"
f(d+~l)(n) -- f ( d ) ( 1 ) - f(d)(o) + (27tin)f(d~)(n).
(3.42)
The first application is an estimate for the rate of decrease of Fourier coefficients of a function in terms of its degree of smoothness:
L e m m a 3.8 Suppose that f(d) is continuous and l-periodic for some integer d >_ O. Then ](n) - O(In -d) as n --+ ±oc. Proof: If f is l-periodic and has a continuous d th derivative on all of R, then f(k)(1) - f(k)(0) for all k - 0 , 1 , . . . , d , so we may iterate Equation 3.42 without the boundary terms to get f(d~)(n) -- (27tin)dr(n). any continuous function g are bounded:
10(~)1 -
~0
1 g(X)C -27rinx dx
But the Fourier coefficients of
-< f0 1 Ig(~)~-~'~"xl d ~ - f01 Ig(~)l d~ < ~ ,
(3.43)
independently of the frequency n. P u t t i n g g - f(d) shows that the quantity 127rn[d f(n)[ must remain bounded as n ~ oc, so f ( n ) - o(1~1-~). D In other words, the more derivatives a periodic function has, the faster its Fourier coefficients tend to zero with increasing frequency. This principle applies to both
CHAPTER 3. TIME AND FREQUENCY
90
sine-cosine and exponential Fourier series. Consequently, if the Fourier series of a smooth function is truncated to a finite partial sum involving only frequencies In I < N, then the resulting error will tend to zero as N ~ ~ at a rate like 6
if(x) _ fN(x)l _ O ( ~_~ ~.nl>NInl-d) -- O(N-d+l)' which we obtain using the integral test to sum the series. The smoother the function, the faster the error will go away or, from another perspective, the fewer terms will be needed for a desired accuracy. Recall that if f E L i p satisfies f(0) = f(1), then f has a continuous 1-periodic extension which satisfies the Lipschitz condition on all of R. T h a t in fact is enough to guarantee that the Fourier series for f(x) converges at every x C [0, 1], though we get no error estimate. The proof is beyond our scope, but may be found in Apostol as Theorem 11.9 on page 316. Fourier coefficients can be computed over any period interval [a, a + T]:
1 [a+T f (t)e -2Èikt/T dt.
f (k) - - ~ ~,a
They thus depend on f ' s behavior as a periodic function on the whole line, not just in the interior of one period interval such as [0, T]. In particular, discontinuities hiding at the endpoints of a period interval can affect the rate of decrease of Fourier coefficients because they can affect the cancellation of the b o u n d a r y terms in Equation 3.42. Even without any derivatives, an integrable function f must have some decrease in its Fourier coefficients ] ( n ) , as n ~ +oc, although we get no rate estimate: L e m m a 3.9 ( R i e m a n n - L e b e s g u e )
/f f e Lip,
then f (k) --+ 0 as Ikl --~ oc.
Proof: For simplicity of notation, we will denote the 1-periodic extension of f by f as well. We will write C > 0 for the constant in the Lipschitz condition, so If(x) - f(Y)l <- C l x - Yl for all x, y • [0, 1]. The 1-periodic extension might not satisfy this condition, but there is still some constant M > 0 such that If(x)l <_M for all x C [0, 1], hence also for all x e R, so I f ( x ) - f(Y)l <- 2M for all x, y C R. Now f(k) may be computed in two ways, using the fact that e +i~ = - 1 :
/o 1f (t)e -27rikt dt
==~ 2](k)
-
f
t+ f
t+~-~
e -2~ik*-i~ dt e-
dt
-
-
--
Ji I [ f ( t ) - f (t + ~----£) e-2~iktdt
6The e s t i m a t e d , or worst-case error, is i n d e p e n d e n t of x, t h o u g h of course for certain x it could be much smaller.
3.1. F O U R I E R A N A L Y S I S
91 dt.
Thus, we will have I f ( t ) - f ( t + ~ ) l < 2@kl for every k :/: 0, as long as both t E [0,1] a n d t + ~ C [0,1]. Now suppose e > 0 i s g i v e n . We choose ~1 > 5 > 0 such that 5 < ~-~M, and we put K - m a x { ~ , ~ } . Then Ikl > K will guarantee t C [5, 1 - 5 ] ~ (t + ~ ) E [0, 1], and also ~ < e. Hence, the Fourier coefficient
f ( k ) may be estimated as follows: 2 f (k)l
<_
~05 2 M
<
2 M 5 + (1 - 25)e + 2M5
dt +
/51-5 C2t~, ,[ dt + /11 2 M -5
dt
< 2~.
Since c was arbitrary, it follows that If(k)l ~ 0 as Ik I ~ oc. More careful analysis shows that the Lipschitz continuity hypothesis may be replaced by simple continuity on [0, 1], giving a strict improvement over Equation 3.43. In fact just absolute integrability of f on [0, 1] is enough. The same proof works, but the last step is to show that fo If(t) - f ( t + x)l dt --~ 0 as x ~ 0 for any absolutely integrable f. That, however, is beyond the scope of this text. The converse problem is to estimate the number of continuous derivatives of a function, given just the rate of decrease of its Fourier coefficients. That is an easy generalization of Theorem 3.7: C o r o l l a r y 3.10 If d >_ 0 and there is some fixed constant M such that the sequence c - {c(k)" k C Z} of complex numbers satisfies
N Ikl d+l Ic(k)l < M,
all integers N ,
(3.44)
k---N then a. the partial sums 5N(X) dej
N C(k)e27rikx converge absolutely Ek---N
verse Fourier transform 5(x) de___f l i m N ~
to the in-
CN(X) of C;
b. the function f - f ( x ) dej 5(x) may be differentiated d times, and f(d) C Lip, with If(d)(x) -- f(d)(y)I <_ 2 7 r M i x - Yl, for all x , y c R . [] A finite Fourier series, or trigonometric polynomial, results if ](k) - 0 for all sufficiently large ]k]. This is just a linear combination of sines and cosines, so it has a d th derivative for every d. Similarly, if the Fourier coefficients of f satisfy ](k) <_ Crlkl for r, C > 0 with r < 1, then (2:rik)df(k) ~ 0 as Ik] ~ cc for every d, and we may conclude that f is smooth.
92
CHAPTER
3.
TIME AND FREQUENCY
Figure 3.7: Part of the graph of sinc (~).
Fourier integrals If u - u ( x ) is a complex-valued function of one real variable x, the Fourier integral transform of u is another complex-valued function, denoted 9 C u - 9Cu(~), depending on one real variable ~, defined by the following integral:
f~(¢) -
F
~-:-~¢~(~) d~,
(3.45)
(X)
whenever this improper integral converges. It is possible to compute the Fourier integral transform of certain simple functions exactly. For example, let u - 1~ be the characteristic function of the balanced 1 unit interval I - [-~,1 ~]"
li(x) -
1 ~X~ 1 1, i f - ~ _ _ ~; O, otherwise.
(3.46)
An elementary calculation shows that if ~ J: 0, then 9r1i (~) --
e -~i¢
l i ( x ) e -27rix~ dx --
e
dx
-
-
e ric
sin(~-~)
-
-27ri~
7r~
If we put JCli(0) de__f 1 for continuity, the resulting function is called sinc: sine (~) dJ
{ sin(~-¢) --~ , 1,
if ~ ¢- 0; i f ~ - 0.
(3.47)
A similar calculation, left as an exercise, shows that the Fourier integral transform T T sin(TTr~) of 11(x/T), which is the characteristic function of [--if, y], is Tsinc (T~) ~ . Figure 3.7 shows part of the graph of sinc; notice the many local maxima to either side of the global maximum at 0, and the zero-crossings at all other integers.
3.1.
FOURIER
ANALYSIS
93
The Gaussian f u n c t i o n g(x) - e -~x2 is another function whose Fourier integral transform can be computed exactly. We start with the fact 7 that f n e-~X2 dx - 1 and change variables:
F
-
F
e -~y2 dy -
O0
=
e ~2
e -~(x+i~)2 dx
O0
/?
e-2~ix~e -~x2 dx
-
e~2Yg(~),
(8.48)
OO
where we make the substitutions y ~-- x + i~ and dy = dx. s Multiplying by g(~) = e - ~ 2 shows that 9Cg - g. The Fourier integral transform can be applied to any square-integrable function, although the proof of this is beyond our scope. 9 It may therefore be applied to any vector in the space L2(R), whose inner product and derived norm are given in Equations 2.29 and 2.24, respectively. In fact, ~- : L2(R) --+ L2(R) is a unitary transformation: Theorem
3.11 ( P l a n c h e r e l )
Suppose u = u(t) and v = v(t) are square-integrable
functions, and let (u, v} dJ f ft(t)v(t) dt. Then JZu and JZv are square-integrable and satisfy (.Pu,.Pv} = (u, v}. [] A sketch of the proof may be found in Section B.6 of the appendix. We may expand the integrals and change their order to get another useful result: C o r o l l a r y 3.12 I f u = u(t) and v = v(t) are square-integrable functions, then
F
(t(t)v(t) dt -
e 2~i~(x-y) f t ( x ) v ( y ) dxdyd~.
cx:)
Proof."
.
By Plancherel's theorem,
f
~t(t)v(t) dt (2O
-
?
(u, v} -
(~u,~v}
e-2~iY~v(y) d y ) d~,
and the complex conjugation passes through to the first integrand.
[]
The inverse Fourier integral transform of a square-integrable function v = v(~) may thus be determined from the formula (u, v} = (Yu, bt-v} = {u, Jc*gt-v}, which holds 7This is proved as Equation B.6 in Appendix B, page 286. 8See Apostol's Theorem 16.12, page 424 for a rigorous version of this informal calculation. 9See Stein and Weiss, Introduction to Fourier Analysis on Euclidean Spaces, Chapter 1, for a nice exposition of the theory of Fourier integrals.
94
CHAPTER
3.
TIME
AND
FREQUENCY
for all u C L2(R). From the nondegeneracy of the inner product, we conclude t h a t 9c - 1 = 9c*, and this may be calculated by interchanging the order of integration:
<~, f . ~>
-
< f ~, ~> -
~-~x~(x)
dx
~(~) d~
co
Identifying the integrand factor other than ~ with 9C*v gives . ~ - l v ( x ) -- 2 * v ( x ) --
e27rix(v(~)
d~,
(3.49)
oo
where v = v(~) is any square-integrable complex-valued function of the real variable ~c and oP-1 = ¢'* are practically the same transform. A change of variable in the integrands shows that )Cu(x) = ) C - l u ( - x ) , so in particular for the balanced 1 interval I - [ - 51, 5], we have .)c-1 l / ( x ) = . ) C l i ( - x ) = sine ( - x ) = sine (x), since sinc is symmetric with respect to x ~ - x . Thus sinc is also the inverse Fourier integral transform of 1i. Likewise, the symmetric function l i is both ¢ ' - l s i n c and Ysinc, and the symmetric Gaussian function g ( x ) - e -~x2 satisfies g = .T'g = .T'- l g.
3.2
Discrete
Fourier
Analysis
To compute Fourier coefficients requires evaluating integrals of rapidly varying functions: the factor e 2~ikx oscillates rapidly when Ikl is large. In rare cases, such integrals can be computed analytically by calculus, but the Fourier transform is far too useful to be restricted that way. For the majority of cases, numerical integration must be used. To do that, fix a large integer N and put tn = n / N for n = 0, 1 , . . . , N. These form a grid of N + 1 equally spaced points in the interval [0, 1], with Atn de__f t~+l tn __ 1 for all k. Now suppose that u - u(t) is a 1-periodic function that is to be approximated by its Fourier series at the points { t n } . Since u ( t o ) = u(tN), the Riemann sum approximating the integral for the kth Fourier coefficient may be taken over just n = 0, 1 , . . . , N 1:
def E
~(k) ~ v~ -
n=0
~ (t~)
e_27rikt n
1 ~ 1 (n) zxt~ - ~ ~ ~
~xp
(
kn - 2 ~ i N-
)
,
(a.50)
n=0
for k C Z. The approximation improves as N --~ oc, that is, with a denser sampling of u on [0, 1].
3.2• DISCRETE FOURIER ANALYSIS Notice that
Pk+N
{Pk : k E Z}
95
is actually an N-periodic sequence since
(k +NN)n ) -exp(-27rin)exp(-27rik-~)
-
exp ( - 2 7 r i
=
exp(-27ri-~)
(3.51)
-- pk.
For fixed N, the computation u ~ p defined by Equation 3.50, which maps a 1periodic function to an N-periodic sequence, is called the N-point discrete Fourier transform, or DFT. Computing the D F T using N sample points is equivalent to applying an N x N matrix to a vector. For a general matrix, this costs O(N 2) arithmetic operations and becomes burdensome rather rapidly as the number of sample points increases. However, we will see how the Fourier matrix can be factored into a product of just a few sparse matrices, and the resulting factors can be applied to a vector in a total of O(N log N) arithmetic operations, lowering the cost for large N. This factored, speedier implementation is the so-called fast Fourier transform, or FFT.
3.2.1
D i s c r e t e Fourier t r a n s f o r m
To fix notation, let v C C N be a vector , indexed as v -- {v(n) }~=0" N-1 The discrete Fourier transform of v is the vector ~? C C N defined by
1
(
N-1
,
rt=O
for m - 0, 1 , . . . , N 1. The factor ~NN normalizes the output and makes the transform unitary. The matrix form of this equation is ~? - -~Fv, where F • C N --, C g is defined by
F(m, n ) -
mn
exp ( - 2 7 r i - ~ )
.
(3.52)
The subscript N in FN will be added when necessary to emphasize the dimension of the range and domain. Also, writing cv~ - exp (-27ri ~ ) gives 1
i
F
--
1. 1
1
1
... •
~1
022
w2 .
.
•
a)N_
w~
1
.
" .
"'"
"
1
(.d~V_ 1
• • •
0j1N-1
02 N - I
;
F(?Tt, n)
--
(~)~nn)N-1 m,n:O
"
(3.53)
N--1 CdN_ 1
Such a matrix is called a Vandermonde matrix: its mth row is the successive powers 2 {1,a~m,a&~,...} of a~m. Induction on N proves that det F -
H O
(a~,~ - aJn),
96
C H A P T E R 3.
TIME AND FREQUENCY
and since 02~ # 02~ for n :/: m, FN is nonsingular. Also, 02n - Cam, so F is a N _ 1 for all m - 0, 1 , . . . , N symmetric matrix; &m - 02~7n1 , since 102-~I -- 1; and 02m 1. Thus ~ N F is unitary: m
N-1 FF*(m,n)
-
E
N-1
Z
02m k -02 kn
N,
(
(m-n)k 021
N6(m-
n),
if m -- n,
I 1--w[m-n)N . . . .
=
0
-
k=0
k=O
n
l_Wl
:::> ~ r
r
if m ¢- n,
n
-
F F * - Id.
The formula for ~?(m) makes sense at any integer m, and satisfies 5(m + N) = ~?(m) for every m, since e x p ( - 2 7 r i ( m + N ) n / N ) = e x p ( - 2 7 r i m n / N ) for every integer n. Thus, the discrete Fourier coefficients are N-periodic and no additional information is contained in them beyond the first N. Since ~?(-m) = ~ ? ( N - m ) , the discrete Fourier coefficients ~?([N- 1 ] / 2 ) , . . . , ~ ? ( N - 1) duplicate the Fourier coefficients 5 ( - [ N - 1 ] / 2 ) , . . . , ~)(-1) at negative frequencies, when N is odd. When N is even, it is coefficients ,)(N/2), ~ ( N / 2 + 1 ) , . . . , ~ ) ( N - 1) that may be regarded as duplicates of the negative-frequency coefficients ~?(-N/2), 5 ( - N / 2 + 1 ) , . . . , ~?(-1). Note the similarity with the division of bit strings into positive and negative integers for twos-complement arithmetic, shown in Figure 1.1. Since v - ~NNF*~?, it lies in the column space of the adjoint matrix F*. These columns are the discrete Fourier basis functions exp (27ri~-~). Figure 3.8 shows the real and imaginary parts of an example with N = 256 and m = 3. Notice that with so many sample points it is difficult to distinguish the graph from that of a smooth function. |
Real part (Cosine) ..... Imaginary part (Sine) .....
0.05
._ .. ",, ,.'" , '~'"
',, ..."' :," ',\ ,,. ,\
// /
:' \ ,' \ ," \
',
',
,/ ,' ,l
.-. N
.. "'.. \ , \\
/
//"
:/ ,"
, ,.,,
................. ......................... ................... ...... i ............ ....... iii:: ...... i \',
-0.05
,
0
, '
"; //",.
,
,
,"
! _.
,,'',,. ,' . .'
,"
'
,X.
/
..
,
"......."
I
I
I
I
I
50
i00
150
200
250
Figure 3.8: Real and imaginary parts of a Fourier basis function 1 exp (27ri an
3.2. D I S C R E T E FOURIER A N A L Y S I S
97
The "fast" discrete Fourier transform Every coefficient of the matrix F(m, n) has absolute value one, so F is not sparse. However, algebraic properties of the exponential function may be exploited to reduce its cost of application, using the following:
Lemma 3.13 (Danielson-Lanczos, 1942) Suppose that N is an even positive integer. Then the N-point discrete Fourier transform FN splits into two parts: for m -- 0, 1 , . . . , N -
1,
FNv(m) -- F.~ v ~(m) + exp (-27tim~N) F~ v ° (m). Here ve(n) def v(2n) and v°(n) def (2n + 1) for 0 < n < yN, and the two N2 point discrete Fourier transforms FN are considered -~ N-periodic for purposes of _
2
evaluation at
TN
< - m
Proof." For any 0 < m < N, the sum in n defining FNv(m) splits into the even-n and odd-n parts" N-1 -
n--0
N/2--1
=
Z n=0
N/2-1
+
E
v ( 2 n + l ) e x p (-27ri(2n+1)m/N)
n=0
N/2--1
=
E
v(2n)exp
(-27cinm) N/2
n--0
N/2--1
+ e x p (-2Trim~S)
E
v ( 2 n + l ) exp
(-27rinm) N/2 "
n=0
The two sums are evidently F ~ v e ( m ) and F_~v°(m). What does this achieve? Since the number of operations needed to compute FNV equals the total number of nonzero matrix coefficients, FN costs N 2 while the split version costs 71N 2 plus about 3N for preparing v e and v ° and later reassembling the pieces. Thus the split version is cheaper for N > 6. When N is big and ~1N 2 >> 3N, the savings become significant. For N - 2 q, the lemma may be applied recursively for further savings:
98
C H A P T E R 3.
TIME AND FREQUENCY
"Fast" Fourier T r a n s f o r m , or F F T , on N fft( v, N ). [0] If N>I, then do
[1] [2] [3] [4] [5] [6] [~]
[i] to
2q P o i n t s
[9]
For k=0 t o N/2-1, l e t ve[k] = v[2*k] Compute f f t ( v e , N/2) For k=O to N/2-1, let vo[k] = v[2*k+l] Compute fft (vo, N/2) For m=O to N/2-1, do [6] to [9] Let w.Re = cos(2,PI,m/N) Let w. Im = - s i n ( 2 * P I , m / N ) Let v[m] = ve[m] + w,vo[m] Let v[m+N/2] = ve[m] - w,vo[m]
[8] [9]
The i n p u t / o u t p u t array v [ ] , the temporary arrays ve[] and v o [ ] , and the scalar u are all complex-valued. We denote the real and imaginary parts of u, for example, by u. Re and u. Im, respectively. The operators =, * and + signify complex assignment, complex addition, and complex multiplication, respectively. The total cost of F F T for N - 2 q is O ( N q ) - O ( N l o g 2 N) as N ~ oc. This has low complexity compared with the O ( N 2) cost of applying the dense matrix FN directly to a vector. The inverse discrete Fourier transform has virtually the same matrix as the discrete Fourier transform, only with +i rather than - i in the exponential function: F -1 - F . But F is also a symmetric matrix, so another way of saying this is that F -1 - F*, or that the Fourier transform matrix is unitary. Thus, inverse F F T is obtained from F F T by modifying just the one line defining the imaginary part of w:
[7']
Let u. Im = sin(2*PI*m/N)
F F T plays an enormous role in numerical analysis and signal processing, and as a consequence there exist many specialized and highly-engineered versions. Some of the more exotic variants are described by Walker in his book Fast Fourier Transforms. Our version is a relatively simple F F T implementation, popularized in a 1965 article by Cooley and Tukey. 3.2.2
Discrete
Hartley
transform
The discrete Hartley transform, or DHT, is a more symmetric and purely real-valued alternative to the discrete Fourier transformation. Its matrix H N " R N --+ R g in the N-point case is given by the following formula: H N ( m , n) -- cas
N
--
cos
N
+ sin
N
"
(3.54)
Then DHT is the linear transformation v ~ --~ HNV. Since cas 0 - v ~ c o s ( 0 - ~) v ~ s i n ( 0 + ~), the Hartley basis function cas ( 2 7 r m n / N ) / v / N can be written as a just
3.2.
DISCRETE FOURIER ANALYSIS
99
i
i
Hartley Cosine at Sine at
i
basis function-s a m e f r e q u e n c y ..... s a m e f r e q u e n c y .....
0.05
-0.i I
-0.15
0
I
I
I
I
50
i00
150
200
1
250
2~-3n ] Figure 3.9: Hartley basis function 1 [cos 2~6n + sin 2--~J"
one shifted sine or cosine, with amplitude V / 2 / N . Figure 3.9 compares one example of such a basis function with sine and cosine functions of the same frequency m. D H T can be obtained by slightly modifying the F F T implementation, or else by composing it with a small number of additional low complexity transformations. It can thus be factored in virtually the same way as D F T , using slightly different sparse factors. We begin with the following observation:
cas
(
2rrrnn ' N
-~
e
~
+ie-
~
-~
e
e
~
+ie-
(a.55)
For purely real v c R N, we may therefore compute
H N v ( m ) -- ~ [FNv(--m) + iFNv(m)] - .~ [FNv(--m) + i F g v ( m ) ] .
(a.56)
Thus a "fast" D H T can be had using F F T on these pieces. But the D H T of a real vector f E R N can also be performed purely in real arithmetic, using its own version of L e m m a 3.13" L e m m a 3.14 If N is an even positive integer, then the N - p o i n t discrete Hartley transform HN splits into three parts as follows" for m - 0 , . . . , N - 1,
H N v ( m ) -- H ~ v e ( m ) + cos(27rm/N) H ~ v ° ( m ) + sin (27rm/N) H ~ v ° ( - m ) . Here v¢(n) def -- v(2n) and v°(n) def - v(2n + 1) for 0 < n < TN , and the vN - P °int discrete Hartley transforms H _N are considered -N-periodic. f 2
CHAPTER 3. TIME AND F R E Q U E N C Y
100
Proof: This is left as an exercise.
[]
This lemma may be applied recursively, as in the D F T case. To simplify the N-periodicity and the following identities: implementation, we use 5-
COS 27r
rn+~N
m -- - cos(27r--_);
N
sin
(
27c
m+ N N
-- - sin(27rN).
" F a s t " H a r t l e y T r a n s f o r m , o r F H T , o n N = 2q P o i n t s fht ( v , N ) : If N>I, then do [i] to [11] [0] For k=O to N/2-1, let re[k] = v[2,k] [I] Compute fht (ve, N/2) [2] For k=O to N/2-1, let vo[k] = v[2,k+l] [3] Compute fht (vo, N/2) [4] For m=1 to N/2-1, do [6] to [9] [5] Let c = cos(2*PI*m/N) [6] Let s = sin(2,PI*m/N) [7] Let v[m] = ve[m] + c*vo[m] + s*vo[N/2-m] [8] Let v[m+N/2] = ve[m] - c*vo[m] - s*vo[N/2-m] [9] Let v[O] = ve[O] + vo[O] [10] Let v[N/2] = re[N/2] - vo[N/2] [11]
3.2.3
Discrete
sine
and
cosine
transforms
There are other real-valued transforms similar to D F T and DHT. Eight of these, named as in Rao and Yip's Discrete Cosine Transform, are given in Table 3.1. In each t a b u l a t e d matrix, the indices start at zero. The numbers b(k) in the formulas are weights needed for orthogonality: 0,
b(k) -
ll/V~ ,
if k < 0 or k > N; if k - 0 or k - N; if0
(a.57)
DCT-IV, which needs no weights, is especially useful, so several of its properties will be proved. Theorem
3.15 The N x N matrix CINy is symmetric and orthogonal.
Proof." S y m m e t r y is evident since the (m, n) entry is unchanged when m and n are swapped. To show orthogonality, it remains to establish t h a t for any 0 _< m, n _< N - 1,
cos
k=0
7r(/rt + ~)(k + -~) N
71cos
1 N
0
if m # n.
(a.ss)
3.2. DISCRETE FOURIER ANALYSIS Name
Rank
DCT-I
C I + 1 • R N + I __+ R N + 1 CII
DCT-II
. R N ~
101
Matrix coefficient
R N
DCT-III
CIII
DCT-IV
CINV • R N __~ R N
cos
b(m)b(n)
7rmn
0, 1 , . . . , N - 1
N
~(m+½)n
b(n) cos
Index range 0, 1 , . . . , N - 1 , N
N
.re(n+½)
b(m) cos
. R N -..+ R N
A(rn, n)
O, 1 , . . . , N - 1
N
.(m+1)(~+1)
DST-I DST-II
S/
_
COS
1 • R N - 1 ___+R N - 1
SH
sin
• R N ..__+R N
b ( m + l ) sin
. R N ..._+ R N
DST-III
SIII
DST-IV
SINV . R N -.~ R N
0,1,...,N-1
N
b ( n + l ) sin sin
1,...,N-1
7rmn
N
7r(m+l) (n+ 1 ) N
0, 1 , . . . , N - 1
~-(m+ ½)(n+l) N
0, 1 , . . . , N - 1
~r(m+½)(n+½)
O, 1 , . . . , N - 1
N
Table 3.1" Various discrete trigonometric transforms and their matrices. But 2 cos A cos B - c o s ( A - B) + cos(A + B), so the sum can be rewritten in two parts: N-1
~s E cl o
1
N-1
1
7r(m + n +N1)(k + 7) de__f__I + II.
~-(k + ~)(mN - n) + ~c oEs l
k=0
k=0
Since exp (iO) - cos 0 + i sin 0, each of these can be rewritten as the real part of a geometric series:
_
N 1
1~ E exp
(
1)
i T r ( f f t - n)(]~ -~ 2)
m
2
II
=
1~
N-I~ (
2
k=0
N
k=0
exp
'
1)
irc(m+n+l)(k+-~)N
Suppose first that n C m . T h e n - N + l _ < m-n_< N-l, so ( m - n ) / N i s not an even integer. Likewise, 1 _< m + n + 1 < 2 N - 1, so (m + n + 1)/N is not an even integer. T h e geometric summation formula can therefore be used:
~ exp ( iTr(m - n) ) 2N
=
1 - exp (iTr(m - n) ) 1
-
i(1±1) 2sin (~-(m - n)/(2N))
-
= 0,
102
C H A P T E R 3. TIME A N D F R E Q U E N C Y
and exp (iTr(m + n + 1)) 1 - e x p (ifc(m + n + 1)) 2N 1 ~- e~p (-i~(-m ~- n ~- 1)7N)
II
i(1 :t: 1) 2sin (Tr(rn + n + 1)/(2N))
= 0,
because 2isin0 - exp ( i 0 ) - exp (-i0), and each expression is the real part of a purely imaginary number. On the other hand, if m - n, then Equation 3.58 holds if N-1
E
( ( n - ~ - ~ ) ( k1 - ~ - ~ ) ) 711 -
c°s2
_ N
N
2
k=0 But
for
any integer n and all real O, cos 0 - (-1)
N-1
E
(71"(n-~-1)(k-~-1))
c°s2
N
N
_1
E
n
sin (~(n + 51 ) - 0), so
( 71-(n + sin2
1
1)
~ ) ( N - 1 - k + g) N
k=0
k=0
N-1
E
sin2
( 71"( n + ~1 ) ( k + ~1 ) ) N '
(3.59)
k=0
after the substitution k ~ N - 1 - k. Finally, since sin 2 0 + cos 2 0 - 1 for all O, N-1 Ec°s2
(Tr(n + 1 ) ( k + 1 ) ) 1 N-1 N --2El--
k=0
N 2 '.
k=0
completing the proof. [] 1 Noting that 2 sin A sin B - c o s ( A - B ) - c o s ( A + B ) a n d sin 2 0 - cos2[~(n+7)-O], it is easy to see how the previous proof can be modified to give the following very similar result: C o r o l l a r y 3.16 The N > N matrix S ~ y is symmetric and orthogonal.
3.3
Exercises
1. Find the 1-periodization of the function f ( x ) - e-lXl. 2. For real e > 0 and a, define the dilation operator 5~ and the translation operator ~-~, which act on functions f - f ( t ) of one real variable as follows:
Tau(t)
def__ u(t -- Ol),"
6eu(t) def__ (-1/2u(t/g).
a. Show that these are linear transformations with inverses T~-1 5e-1
-
-
(~l/e"
(3.60) -- ~-_~
and
3.3. E X E R C I S E S
103
b. Compute the compositions ~-a[~wl(t) and ~[Taw](t) on a function w = c. Show that the fraying operator F(r, a, e) over reach interval [a - e, a + e], as defined in Equation 3.20, may be written as F(r, a, e) = Ta~eF~-l~-~-1. d. Derive the formula for splicing over the reach interval [ a - c, a + e] by computing S(r, a, e) = T a ( ~ e S ( ~ - I T g 1. Deduce that F(r, a, e) and S(r, a, e) are inverses. 3. Suppose that u - u(z) is T-periodic. Show that the smooth local periodization of u to the interval [0, T] equals u. 4. Show that the following operators can also be used for fraying and splicing:
_ Fu(t)
-
(fft)u(t) - ff-t)u(-t), I r(-t)u(t) + r(t)u(-t), u(0),
Su(t)
-
r(t)u(t) + ~ ( - t ) u ( - t ) , f(-t)u(t) - r(t)u(-t), u(0),
if t > 0, if t < 0, if t - 0;
(3.61)
if t > 0, if t < 0, if t - 0.
(3.62)
That is, show that (i) Su(t) - u(t) and _Pu(t) - u(t) if Itl > 1. (ii) s a n d / ~ are linear transformations of functions on R. (iii) 6 a n d / ~ are inverses. (iv) If u and r belong to Cd(R), then for 0 <_ n <_ d, [/~u](n)(0 - ) - 0
for odd n;
[/~u](~)(0+)-0
for even n.
(v) If r belongs to C a ( R ) and u belongs to C d ( R \ {0}) and has one-sided limits n(~)(0+) for 0 _< n _< d which satisfy u(~)(0 - ) - 0
for odd n;
u(n)(0+)- 0
for even n,
then defining Su(0) - Su(O+) yields Su E Cd(R). W h a t happens if we substitute r ~ f? W h a t if r - f? 5. Prove, using induction and Leibniz' rule, that the function r,~ (t) defined below has 2 n - 1 vanishing derivatives at t - +1 and t - - 1 , so that rn has 2 n - 1 continuous derivatives:
rn
o(t)
=
(t)
deJ
0, sin[~(l+t)], 1, 0, ~'n-- 1 (sin ~~t) , 1,
if t _< - 1 , if-l
1, ;
CHAPTER 3. TIME AND FREQUENCY
104
6. Show that the set of functions {1, v/2cos 27rnt, v~sin 27rnt • n - 1, 2 , . . . } is orthonormal with respect to the (Hermitean) inner product
/01
(f, g) de__f
f(t)g(t) tit.
That is, show that
( v/2 cos 27rnt, x/~ sin 27rmt }
-
0,
all n , m C Z+;
(3.63)
-
O,
n ~: m C Z + U {0};
(3.64)
o,
n ¢ m c Z+;
(3.65)
(x/~sin27cnt, x/~sin27cmt} 11[] -
I[v/2sin
27rnt I
Ix/"2 cos 27rntll -
1.
(3.66)
7. Compute the sine-cosine Fourier series of the 1-periodic function cos2(27rx). (Hint" use a trigonometric identity.)
f(x) -
8. Compute the complex exponential Fourier series of the 1-periodic function sin(27rkt- d), where d is a constant real number. 9. Show that if Ic(n)l < 1 / n l 3 for all integers n ¢ 0, then the 1-periodic function f - f(t) which is the inverse Fourier transform of the sequence {c(n)} must have a continuous derivative if(t) at every t c [0, 1]. 10. Show that the functions Ck(t) - l(Nt - k), k -- 0, 1 , . . . , N - 1 are an orthogonal collection with respect to the inner product
(f, g) de__fj~01 f(t)g(t) tit. Here 1 - 110,1 ) is the indicator function of the interval [0, 1). How can this collection be made orthonormal? W h a t is the linear span of {¢k " 0 _< k <
N}? 11. Suppose that ¢ has Fourier integral transform )c¢. Let Ck(x) Show that 9 r C k ( ~ ) - e-2~ik~gc¢(~).
dJ ¢ ( x - ~).
12. Suppose that ¢ has Fourier integral transform 9c¢. Let Ca(x) de_f ¢(x/a), for a > 0. Show that 9C¢a(~) - agC¢(a~). 13. Compute the inverse Fourier integral transform of the function
{ ¢(~)-
1, 0,
if-l_<~<-~ otherwise.
1 or ~1 < ~ _ <
1;
1 (Hint: notice that ¢(~) - 1 i ( ~ / 2 ) - 11(~), where I - [ - ~ , 1 ~].)
3.4. F U R T H E R R E A D I N G
105
14. Compute the Fourier integral transform of the hat function
1 - Ix], 0,
i f - 1 < x < 1; otherwise.
15. Show that the vectors a& E C N, n - 0, 1 , . . . , N 1 defined by a~n(k) v~N exp (27rink~N) form an orthonormal basis with respect to the inner product N--1
{f,g} def E
f(k) g(k).
k=0
16. Write out explicitly the matrices for the 2 x 2 and 4 x 4 discrete Fourier and Hartley transforms (F2, F4, H2 and/-/4). 17. What is the matrix of the square of N x N D F T ? Give a formula for every positive integer N. 18. What is the matrix of the fourth power of N x N D F T ? Give a formula for every positive integer N. 19. Write out explicitly the matrices C~ v and C~ v used for the 2 x 2 a n d 4 x 4 DCT-IV, respectively. 20. Prove Lemma 3.14. 21. Prove Corollary 3.16.
3.4
Further
Reading
Tom M. Apostol. Mathematical Analysis. Addison-Wesley, Reading, Massachusetts, second edition, 1974. ISBN 0-201-00288-4. • James W. Cooley and John W. Tukey. An algorithm for the machine calculation of complex Fourier series. Mathematics of Computation, 19:297-301, 1965. • Jean Baptiste Joseph Fourier. Thdorie Analytique de la Chaleur. F. Didot, Paris, 1822. • K. R. Rao and P. Yip. Discrete Cosine Transform. Academic Press, New York, 1990. ISBN 0-12-580203-X. • Elias M. Stein and Guido Weiss. Introduction to Fourier Analysis on Euclidean Spaces. Number 32 in the Princeton Mathematical Series. Princeton University Press, Princeton, New Jersey, 1971. ISBN 0-691-08078-X.
106
CHAPTER 3. TIME AND F R E Q U E N C Y • James S. Walker. Fast Fourier Transforms. CRC Press, Boca Raton, Florida, 1992. ISBN 0-8493-7154-6. • Gregory K. Wallace. The J P E G still picture compression standard. Communications of the A CM, 34:30-44, 1991. Also available from URL f t p : / / f t p . uu. n e t / g r a p h i c s / j p e g / w a l l a c e , ps. gz.
Chapter 4
Sampling and Estimation Multimedia signal processing begins with the taking of physical measurements to acquire sounds or images. To determine what measurements are needed, we use a mathematical model of the physical process. For example, speech recording begins with a model of the sound vibrations that a human being can produce. These result in slight fluctuations of the air pressure that can be measured by a microphone, producing a real-valued function of one real "time" variable. Similarly, taking a picture begins with a model of the light arriving at the camera. The amount that arrives during the acquisition period, or when the shutter is open, is a nonnegative real-valued function of two "space" variables. Finally, video can be modeled by a nonnegative function of one time plus two space variables. There is no general method for representing arbitrary functions of one, two, or three real variables in a computer. That would require an infinite amount of information even in some simple cases. However, the functions produced or consumed by humans as sounds, pictures, or videos are not arbitrary. They are very smooth functions since humans can neither move too fast nor absorb very rapidly changing signals. Hence sampling the functions often enough, or at enough places, will give a reliable approximation. The smoothness, or slow-change assumption, implies that no large fluctuations occur between sample points. We will study methods for recovering a function from its samples, given this assumption. Looking deeper, we see that the physical measurement of a sample contains numerous uncertainties. We will obtain estimates of the errors caused by our fundamental ignorance by modeling our measurements as random variables and using tools from probability theory. The uncertainty and error in physical measurement is actually a blessing in disguise. On the one hand, the data in our computer can never be a perfect representation of reality, and will always be corrupted with noise. On the other hand, our processing algorithms are freed from the tyranny of exactness. We can use fast approximate computation methods in many cases, if we keep the calculation errors small compared to the original measurement errors. 107
C H A P T E R 4. S A M P L I N G A N D E S T I M A T I O N
108
4.1
Approximation and Sampling
We will restrict ourselves to the problem of approximating one real or complexvalued function f - f ( x ) of one real variable x, given its values at discrete points. For the moment, we will assume that the values and the sample points are known exactly. So, let {xk " 0 _< k _< n} be a set of n + 1 distinct real numbers. Then for any real or complex numbers {Yk " 0 _< k < n}, the sampling set S - {(xk, Yk) " 0 < k < n} is a list of n + 1 distinct points. For example, we may take S to be a table of sample p o i n t s y k - - f ( x k ) for f. I f x k - x 0 + k h for s o m e h > 0 a n d a l l k - 0 , 1 , . . . , n , then S is called a regular or equally-spaced sampling of f with sampling interval h. Given S and some assumptions about f, it is often desirable to compute f ( x ) at points x ~ {xk}. This process S ~ f is called interpolation, and has a long history with many applications. For example, one of the earliest kinds of compressed data was tables of sines and cosines recorded to high precision at just a few angles. W i t h high-order polynomial interpolation, any other desired value could be computed with equally high precision in just a few operations. A more recent application is resampling a function at other points, to accommodate new display devices. This can often be done speedily with low-order piecewise approximation. Finally, some operations such as differentiating or integrating f reduce to matrix multiplication, if we know that f belongs to a sampling space, and has an expansion in known basis functions.
4.1.1
Polynomial interpolation
Any single value of a polynomial p - p(x) can be computed in finitely many steps from its formula:
p(x)
.
ao. ~-
a l.x
d-. a2 x 2 -}-
-}- a n - 1 x n - - 1 d- a ~ x n .
(4.1)
The highest power of x, here n, is called the degree of p. Clearly n > 0. The n + 1 numbers {a0, a l , . . . , an} are called the coefficients of p. Given the coefficients {ao, a l , . . . ,an} and a fixed x, it costs O(n) floatingpoint operations to compute p(x) by Horner's method, which works by grouping operations as follows:
p(x) - ao + x(al -~- x(a2 + . . . + X(an-2 + x(an-1 -~- xa~)) . . .)). Below is one implementation:
Polynomial Evaluation by Horner's Method h o r n e t ( x, a [ ] , n )" [0] Let y = a[n] [1] For k=n-1 down t o 0, do [2] [2] Replace y = a[k] + x*y [3] R e t u r n y
(4.2)
4.1.
APPROXIMATION
AND SAMPLING
109
Step 2 consists of one multiplication and one addition. It is e x e c u t e d n times, m a k i n g the cost O(n) o p e r a t i o n s per evaluation. A n y n u m b e r z for which p(z) = 0 is called a root of p, a n d we can write p(x) = ( x - z)q(x), where q(x) is a polynomial of degree one less t h a n p. This implies t h a t if t h e degree is n, there can be at most n distinct roots. A n o t h e r way of saying this is: L e m m a 4.1 If the degree of a polynomial p is known to be n or less, but it is known to have more than n distinct roots, then all of p's coefficients must be zero and thus p(x) = 0 for all numbers x.
Proof:
If zo, Zl, z 2 , . . . , zn are n + 1 distinct roots of p = p(x) = ao + a l x -+- a2x 2 + xn-1 -+- a n x n } t h e n the following m a t r i x e q u a t i o n holds:
• . . -1- a n _ l
1 1 1
Z0
Zg
• • •
Zl
Z2
•""
Z2
Z2
...
1
Zn
2 Zn
z~ zp z?
ao al a2
_
0 0 0
.
(4.a)
0
I n d u c t i o n on n is next used to prove t h a t the d e t e r m i n a n t of the m a t r i x is II
(Zj
-- Zi).
O<_i<j<_n
Since zi ~ zj for i ~= j, the m a t r i x is nonsingular, so the only solution to the linear s y s t e m is ao - a l . . . . . an - O. [] T h e q u a d r a t i c formula gives all the roots of p(x) - ao + a l x -t- aex 2 w h e n the degree is two: --al
+
Zl z
v/a21 2a2
4aoa2 ;
Z2-
--al -- v/a21 2a2
4aoa2 •
This formula uses only + , - , x, +, a n d x/-" T h e r e are also the more c o m p l i c a t e d C a r d a n o formulas for roots of t h i r d a n d f o u r t h degree polynomials, which use higher-order radicals as well, but it is a deep fact discovered in the 1820's t h a t no formula using just the four basic o p e r a t i o n s plus radicals of any ortl(~r can represent the roots in all cases w h e n the degree is five or more. Lagrange
interpolation
If f = f ( x ) is a p o l y n o m i a l of degree n, t h e n its coemcients {a0,..., a~} are uni(l,~ely d e t e r m i n e d by the values f ( x ) at n + 1 distinct points { x 0 , . . . ,x~}. T h e algoritl~,n for finding the coemcients is called Lagrange interpolation, a n d is based on the following identity for polynomials of degree n: n
An(x) - E k=O
yk)~k(x),
(4.4)
C H A P T E R 4. S A M P L I N G A N D E S T I M A T I O N
110 where for every k = 0, 1 , . . . , n,
• Yk = f ( x k ) are the fixed evaluations of f at xo, X l , . . . , Xn, and Ak(x)
1-1 • 1
X--Xj
is a polynomial of degree n.
j~k
T h e o r e m 4.2 If f = f ( x ) is a polynomial of degree n or less, and An is defined by Equation #.#, then f ( x ) = An(x) for every x.
Proof: Notice that Ak(Xk) = 1 while Ak(Xj) = 0 for j # k, so that An(xk) = f ( x k ) for k = 0, 1 , . . . ,n. Thus the polynomial f ( x ) - An(x), which has degree n, has n + 1 distinct roots x0, x 1 , . . . , Xn and must be identically zero. [] The algorithm to evaluate a polynomial of degree n at an arbitrary point x, given its values at n + 1 distinct points, requires 2n + 2 inputs and O(n 2) arithmetic operations:
Lagrange Polynomial Evaluation l a g r a n g e ( x, x [ ] , y [ ] , n ): [0] Let y = 0 [1] For k=0 t o n, do [2] t o [2]
Let
lambda
[5]
= y[k]
[3] For j=0 t o n, do [4] [4] I f j != k, m u l t i p l y lambda *= ( x - x [ j ] ) / ( x [ k ] - x [ j ] ) [5] Accumulate y += lambda [6J R e t u r n y
Newton's form prepares the Lagrange polynomial for evaluation by a generalization of Horner's method. Instead of superposing the values of n + 1 elementary polynomials Ak(x), k = 0 , . . . , n, each of degree n and determined by { x 0 , . . . , xn}, we precompute n + 1 coefficients co, Cl, c 2 , . . . , Cn such that A n ( x ) -- c 0 -~- (x - x0)[c1 -~- (x - Xl)[C 2 -~-""-~- (x - Xn_l)Cn]'"-].
(4.5)
Expanded, this form bears some resemblance to the Taylor series for An: An(x) = co -Jr Cl(X - xo) -~- c2(x - Xo)(x - Xl) -~-"""-~- Cn(X -- Xo)''" (X -- Xn-1). Instead of jth derivatives, the coefficients are given by cj = D J f ( x j ) , where D J f is the jth divided difference, defined recursively as follows:
DOf(xk)
de~
DJ f ( x k )
=
f(Xk),
~ -- 0, 1 , . . . ,
Tt;
DJ-l f(xk) - DJ-l f(xk_l) Xk -- X k - j
,
0 < j <_ k <_ n.
In the special case of equispaced sampling, with Xk = Xo + kh for fixed h > 0, the Newton form mimics the Taylor series even more closely:
n j-1 n AYf(xy) j-1 An(x) - E cj 1 - [ ( x - xi) - E j!hJ II(xj=0
i--0
j 0"=
i=0
xi),
(4.6)
4.1.
APPROXIMATION
AND SAMPLING
111
zxJ f (x¢ ) where the coefficients Cj = j!hJ are computed from ordinary undivided differences AJ f defined recursively as follows: AO f (xk )
deJ
f (xk ),
AJ f ( x k )
=
AJ-l f(xk) - AJ-l f(xk_l),
jth
k - O, 1 , . . . , n; 0 < j < k <_ n.
Newton's form allows easier updates of the interpolating polynomial in response to additional points. For example, if one new point (Xn+l, f ( X n + l ) ) is added to the interpolation set {(xk, f ( x k ) ) " k - 0, 1 , . . . ,n}, then to get the new Lagrange polynomial we simply add one more term to the old Newton form: n
An+l(X) --
A~(x) +
Cn+l
H ( X -k=0
Xk),
(4.7)
where C n + l - - An+lf(xn+l) (n+l)!hn+l in the equispaced case, or Cn+ 1 - - Dn+l f(Xn+l) in general. To compute co,... ,cn from the interpolation set {(xk, f ( x k ) ) " k -- 0 , . . . ,n} costs O(n 2) operations, using the following algorithm:
D i v i d e d Differences for N e w t o n ' s Form divdiff( c[], x[], y[], n ): [0] For k=O to n, let c[k] = y[k]
[1] For j = l to n, do [2] to [3] [2] For k=n down t o j , do [3] [3] Replace c[k] = ( c [ k ] - c [ k - 1 ] ) / ( x [ k ] - x [ k - j ] )
Given {Ck}, subsequent evaluations of An cost O(n) operations each:
N e w t o n ' s Evaluation of the Lagrange P o l y n o m i a l n e w t o n p o l y ( x , x [ ] , c [ ] , n ): [0] Let y = c[n] [1] For k-n-1 down t o 0, r e p l a c e y = c[k] + ( x - x [ k ] ) . y [2] Return y
C h e b y s h e v polynomials If we can choose the sampling points {xk }, then we can select a good representation of the Lagrange polynomial due to Chebyshev. First note that any function f = f ( x ) defined for x E [a, b] determines an equivalent function g(y) = f o p(y) defined on y E [-1, 1], where p(y) dej b~_~y + b+___~maps [-1, 1] to [a, b]. We also have have f (x) - g o q(x) , where q(x) d=e f b-a 2 x -- g2--a b+a maps [a, b] to [-1, 1]. Since both p and q are of the form A x + B with A ¢ 0, the functions f and g have equal smoothness and integrability. Also, f is a polynomial of degree n if and only if g is a polynomial
C H A P T E R 4. S A M P L I N G A N D E S T I M A T I O N
112
of degree n. Hence, we m a y assume w i t h o u t loss of generality t h a t our functions are defined on [-1, 1]. For integer n 2 0, define the n th Chebyshev polynomial, Tn, as follows:
T n(x) de__f COS(n a r c c o s x ) ,
x C [-1, 1].
(4.8)
T h a t these are actually polynomials in x requires proof: L e m m a 4.3 To(x) - 1, Tl(X) - x, and for all n > 1, Tn is a polynomial of degree n, with leading coefficient 2 n - l , satisfying the recursion relation
T n ( x ) - 2XTn_ 1 (X) - Tn_2(x ). Proof: First verify To(x) - cos0 - 1 and T1 (x) - cos(arccosx) - x. Next, write 0 - arccos x, so cos 0 - x, and note t h a t for n > 2, 2xTn_ 1 (x) - Yn_2(x ) - 2 c o s O c o s [ ( n - 1)0] - c o s [ ( n - 2 ) 0 ] . T h e n evaluate the second term, c o s [ ( n - 2 ) 0 ] - c o s [ ( n - 1 ) 0 - 0 ] - cos 0 c o s [ ( n - 1)0] + sin 0 s i n [ ( n - 1)0], so
2XTn_l (X) -- T n - 2 ( x )
--
cos0
cos[(n
=
co
0]
[
-
1)0] -
sin 0sin[(n
-
1)0]
--
This establishes the recursion relation. Since To and T1 are polynomials, the recursion relation implies t h a t T~ is also a polynomial for all n > 1. It remains to establish, by induction on n, t h a t the highest order t e r m of Tn(x) is 2 ~ - l x ~ (for all n > 0, in fact), but this is left as an exercise. [] Lemma
4.4 The roots of Tn are the n distinct numbers xk -- cos [~(k+½) ~ ], k --
0, 1 , . . . , n -
1, all of which lie in the interval [-1, 1].
Proof." T h e r e are at most n distinct roots of Tn, since it has degree n, and the numbers {Xk} are evidently distinct and lie in [-1, 1]. It remains to check: Tn(xk) -
r cosx )
-
+ 1)] _ 0
-
[]
L e m m a 4.5 Any polynomial p - p(x) of degree N or less can be written as a linear combination of the Chebyshev polynomials To, T 1 , . . . , TN.
Proof: This is obviously true for N - 0 and N - 1. Suppose t h a t the result is true for N - 1 _> 1, namely, suppose 1, x , . . . , x u - 1 are expressible as linear combinations from the set To, T 1 , . . . , TN-1. Since x N - 2-(N-1)TN(X) is a polynomial of degree
4.1. APPROXIMATION AND SAMPLING
113
at most N - 1, we see t h a t X N can be written as a linear combination of TN and To, TI,..., TN-1. By induction, the result holds for all integers N > 0. [] In particular, the Lagrange polynomial of degree at most N interpolating N + 1 points {(xk,Yk) " k -- 0 , . . . , N } with {xk} C [-1,1] can be written as a sum of Chebyshev polynomials:
N
AN(X) - ~
c(n)T~(x).
n=0
The expansion coefficients are easily computed from the sequence {Yk} if we use Chebyshev nodes, the N + 1 distinct roots of TN+I"
1 7r(k N ++I ~) '
xk-cos
k - 0, 1 ' ' ' "
N,
(4.9)
T h a t is because Chebyshev polynomials { T o , . . . , TN} have a discrete orthogonality property with respect to the roots of TN+I. Let P be the space of polynomials of degree N or less, with inner product
N
N
c°s(narcc°sxk)cos(marccosxk)
k--0 ( =
E
k=0
1 cos
N+I
) (
1 )?7_t) cos
N+I
'
which is zero for n ~: m because distinct rows of the D C T - I I matrix in Table 3.1 are orthogonal. Likewise, it is straightforward to show t h a t (To, To) ~ kN = 0 1 -- N + 1, and
N
1]
rr(k+~)n
-
k=0 Theorem
N+I
-
_ N+I ~ , 2
4.6 For k - O, 1,..., N, suppose that xk
-
n - 1, 2 , . . . , N. ~(k+½)
(4.10)
N+I is a Chebyshev node and yk is arbitrary. Then the Lagrange polynomial of degree N or less interpolating {(xk, Yk)" k - 0, 1 , . . . , N} is:
N
Z
m--0
--
COS
C H A P T E R 4. SAMPLING AND E S T I M A T I O N
114
where c(O) -
1 En--O N Yn , and /
2
\
~N
71"(n + ~)ml
c(m)-- N + l ' 2 " Y n C ° S
N+I
I
'
n
m-l,z,...,lv.
AT
n--0
Proof." Every polynomial of degree N has the stated form, including the Lagrange polynomial AN(X). By definition, N
<TIn,AN>
-
E
T'~(x~)AN(xn)
n--O 71"
=
E cos n=0
1 N + 1
N
[71.(n ~_ 1 ) m
n--0
This can also be evaluated using discrete orthogonality: N
<Tin, AN> -- E
c(n) <Tin, Tn> -- c(n)
n---O
Applying Equation 4.10 finishes the proof.
[]
Thus, given values {Yn} at the N + 1 Chebyshev nodes {xn}, we can precompute the Chebyshev expansion coefficients {c(m)} using the DCT-II transform: N
c(m) -- E CINI+I(m,
n)yn,
n=---O
which is an investment of O(N 2) operations. If N + 1 is a power of 2, this may be done in O(Nlog N) operations with the fast factored DCT-II. Thereafter, evaluations cost only O(N) operations each since the Chebyshev recursion relation permits efficient grouping: C h e b y s h e v ' s E v a l u a t i o n of t h e L a g r a n g e P o l y n o m i a l chebyshevpoly( x, c [ ] , n ): [0] Let y = c[0] [1] If n>0, then do [2] to [7] Replace y += x,c[1] [2] If n>l, then do [4] to [7] [3] [4] [5] [6] [7] [8]
Let
T[O]
= i,
let
T[I]
= x
For k=2 to n, do [6] to [7] Let T[k] = 2,x*T[k-l] - T[k-2] Replace y += c [k],T[k] Return y
Chebyshev polynomials also have a continuous orthogonality property. Consider the vector space Lip[-1, 1] of Lipschitz continuous functions on [-1, 1], with inner
4.1.
APPROXIMATION
AND SAMPLING
115
product de_f f l I u(x)v(x) dx. This contains all polynomials, including all the Chebyshev polynomials. By substituting x ~ cos0, so dO - - ( 1 - x2) -1/2 dx, we get
-
/_t
cos
(n arccos x) cos(m arccos x)
1
V/1
-
dx -
x2
f
cos(n0) cos(m0)dO. 71"
The substitution 0 ~-- 2 u t - = converts this to
1
~0
cos(27~nt) cos(27rmt) dt,
which is zero for n ~: m by Equation 3.64.
4.1.2
Piecewise interpolation
High-order polynomials are sums of many terms that can have wildly different magnitudes. It is often better to approximate a function in pieces using low-order polynomials on each piece. Pieces will be short runs of sample points, so we now suppose that xo < . . . < X N, where N is fixed in advanced. The values Y0,.-., YN to be interpolated are arbitrary, and we denote the set of i n t e r p o l a t i o n p o i n t s by S-
{(xk,yk)" k -
0, 1 , . . . , i }
C R 2.
(4.11)
The piecewise c o n s t a n t f u n c t i o n through S is defined by" f ( x ) - yk,
when x is closest to xk.
(4.12)
Such f is also called a step f u n c t i o n . The evaluation algorithm, which assumes that n > 0 and that x0 _< x < xn, takes O ( n ) operations:
pwconstant(
Piecewise
Constant
Evaluation
x, x[], y[], N )[0] For k=O to N-l, do [i] [I] If x < (x [k] +x [k+l] ) /2 , then return y[k] [2] Return y[N]
All of the work is in finding that k for which x is closest to xk. If the points {xk } are equispaced in some interval [a, b], so that x k - a + k h for h - ( b - a ) / N , then k - [1 + (x - a ) / h J and each evaluation costs a fixed number O(1) of operations, independent of N: Equispaced
epwconstant(
Piecewise
Constant
x, y[], a, b, N )" [0] Let k = floor( 0.5 + N,(x-a)/(b-a) [I] Return y [k]
Evaluation )
116
CHAPTER
4.
SAMPLING
AND ESTIMATION
The piecewise linear f u n c t i o n through S is defined by: f ( x ) - y k ( x - x k - 1 ) -Jr-Y k - l ( X k -- X),
when Xk_ 1 __<x _< xk.
(4.13)
Xk -- X k - 1
Notice that f ( x ) = AI(X) on the interval [x0,xl], where A1 is the degree-1 Lagrange polynomial given by Equation 4.4. On the general interval [Xk-l,Xk], f is given by that same formula f ( x ) = Al(x), derived from the interpolation set S k ~- { ( X k - l , Y k - 1 ) ,
(Xk, Yk)}.
The graph of f is obtained by connecting ( X k - l , Y k - 1 ) t o ( x k , Y k ) , for each k = 1 , 2 , . . . , N , with a line segment. This is a simple way to obtain a graph from a table of at least two function values. The evaluation algorithm takes O ( N ) operations, most of which are spent finding the right subinterval: Piecewise Linear Evaluation pwlinear( x, x[], y[], N ): [0] If x < x[O], then return y[O] [I] For k=l to N, do [2] [2] If x < x[k], then return (y[k],(x-x[k-l]) + y[k-l],(x[k]-x))
/ (x[k]-x[k-l])
[3] Return y[N]
This implementation is robust: it returns y0 if x < x0 and returns YN if x > XN. The version for equispaced {xn} is left as an exercise. To find a root of a function from its samples, we first locate two adjacent samples yl, y2 of opposite sign, then use the root x0 of the linear function interpolating {(Xl, Yl), (X2, Y2)}" (4 14) X0 z x2yl - xlY2 . yl - y2 To find a local maximum or minimum of a smooth function f from its samples Yk - f(xk), we first locate three consecutive samples Yl,Y2,Y3 such that y2 - Yl and Y3 - Y2 are of opposite sign. Then the Mean Value Theorem implies that i f ( x ) changes sign between Xl and x3, and the Intermediate Value Theorem implies that f ' ( x o ) - 0 for some xo c (Xl,X3). We approximate this extremum Xo with the vertex of the parabola y - A2 (x) interpolating {(Xl, yl), (x2, y2), (x3, Y3)}. That quadratic polynomial may be written in efficient-to-evaluate Newton form as follows: y3--y2
y - A2(x) - yl -}- (x - Xl) ( y2 - yl x2
-
-
_
Xl
,( x
-
x2~
~-x~
_
_
y2--yl '~ x~'xl
X3 -- X l
)
(4.15)
The extreme value is then approximated by y, def A2(x,), where x, is the unique critical point satisfying A~(x,) - O . Solving for x, gives l x 2 ( y 3 -- Y2) -}- x 2 ( y l
-- Y3) -]- x ~ ( y 2 -- Y l )
X, -- ~ Xl(Y3 -- Y2)-Jr- x2(Yl -- Y3) -~- x3(Y2 -- Yl)"
(4.16)
4.1. A P P R O X I M A T I O N A N D S A M P L I N G
117
We may also combine the interpolation and root formulas to get y. directly:
2 4 -'~y2Ax41 +y~Ax42] -- [y1Ax23 +y2Ax21 +y3Ax22] 2 2 [YlAX23 y. -4Ax12Ax23AX31 [ylAx23 -~-y2Ax31 -~-y3Ax12] .
(4.17)
Here Axij -= xi - xj for i, j C {1, 2, 3}. One way to check such complicated expressions is by symmetry. It cannot matter how we label the points, so the formulas x . ( ( x l , y l ) , ( x 2 , Y 2 ) , (x3, y3)) and y . ( ( x l , y l ) , ( x 2 , y2),(x3, Y3)) must be symmetric functions, left unchanged by all permutations of the indices (1, 2, 3). Another check is based on rescaling: for any s,t ~ 0, changing Xl,X2,X3 to SXl, sx2, sx3 must change x. to sx. leaving y. fixed, and changing Yl, y2, Y3 to tyl, ty2, ty3 must change y. to ty. leaving x. fixed. In other words, the units for x. and y. are the units of the x and y axes, respectively. Such scale invariance is expressed more precisely by the formulas ty) -
x . ( x , y);
y.
ty) - t x . (x, y).
It is a worthwhile exercise to confirm that Equations 4.16 and 4.17 are scale invariant symmetric functions.
4.1.3
Sampling
spaces
A function ¢ - ¢(x) of one real variable is said to satisfy an interpolation condition if the following holds at the integers: ¢ ( 0 ) - 1;
¢ ( n ) - 0,
if n - + 1 , + 2 , . . . .
(4.18)
Such a function generates a sampling space, which consists of all the linear combinations of integer translates of ¢, or u(x) - ~-~-nc ( n ) ¢ ( x - n ) , where c - {c(n) • n C Z} is a sequence of scalars. But then the interpolation condition allows easy evaluation of the scalars: for each integer m, we have u(m) - c(m) since all translates ¢ ( m - n ) other than ¢ ( m - m) contribute nothing to the sum at m. Thus, any function in a sampling space is completely determined by its samples, or values at the integers. Additional hypotheses may also be imposed on the values of ¢(x) at non-integer x C R, to obtain additional properties for the sampling space and its functions. For a given sequence of scalars {c(n) • n E Z}, the following partial sum belongs to span { ¢ ( x - n ) ' n C Z} for any integers M <_ N:
N UMN(X) def E C(n)~9(X- n) n=M
(4.19)
We need some notion of convergence to a limit in order to make sense of the infinite superpositions available in a sampling space"
118
C H A P T E R 4. S A M P L I N G A N D E S T I M A T I O N
D e f i n i t i o n 3 Let B dej {¢n " n C Z} be a set of functions of one real variable, and suppose that span B forms a vector space with norm I]" ]]- The closure of span B in the norm I]" II, denoted span B, consists of all expressions of the form O0
.(x)- E where the scalars {c(n) " n c Z} produce partial sums UMN with the property that for every ~ > O, there is some number T~ > 0 such that I l U M N I ] < £ whenever N >_ M > T~ or M <
E
(X)
(X)
c(n)¢n(x) + a E
n------c~
c'(n)¢ n
(X)
de__f
n=---c~
y ~ . [C(n) -Jr- ac'(n)]¢n(x). n----c~
(4.20)
A norm may be defined on the resulting vector space by taking limits of the norms of partial sums: ilul I def
lim
- M,N---.c~
lUMNII,
and we are sure that this limit exists because both {]IU0NII : N > 0} and {]]U-M01] : M > 0} are Cauchy sequences. Indeed, the construction of the normed vector space span B is analogous to the construction of real numbers from Cauchy sequences of rational numbers. There is even a version of completeness similar to that of Theorem 1.9: T h e o r e m 4.7 Given a set B - {¢n" n e Z} and a norm II" II, form span B. Then for any V - {~)n "n E Z} C span B, we have span V C span B. []
II. II,
Given an interpolating function ¢ and a norm we get a sampling space s p a n B from the set B = {¢n(X) = ¢ ( x - n ) : n C Z}. The choice of C a n d t h e choice of norm both influence the sampling space. For example, fix ¢(x) = l ( x ) , the characteristic function of [0, 1), and consider the sampling space generated by B = { l ( x - n) : n c Z} by the closure in three norms. 1 evidently satisfies the interpolation condition, 1 and the partial sum U M N will be a piecewise constant function:
UMN(X)--
{ O,
if x C [n,n + 1) for some n E { M , M + 1 , . . . , N i f x ~ [M, N + 1).
1, N};
We compute the tail errors in three norms: 1To get continuity at the integer s a m p l e points, use a b a l a n c e d s u p p o r t interval I = [ - ~1, i] 2 a n d put ¢ = l t.
4.1.
APPROXIMATION
AND SAMPLING
119
def
N
1. Let IlU[]l - f R lu(x)l dx. Then IlUMNII1 -- ~ n = M Ic(n)l, so the expression u(x) -- ~-~.n c ( n ) l ( x - n) belongs to span S if and only if ~-~'~nIc(n)] is a convergent series.
def
2. Let I l u l 1 2 -
(fRlU(x) 12dx) l/2 .
Then
IlUMNII2--( ~_,nN=MlC(n)I 2 )1/2
is the
g2 norm of the partial sequence {c(n) • M <_ n _< N}, so the expression u(x) - ~.,n c ( n ) l ( x - n) belongs to s p a n B if and only if c e g2(Z), if and only if ~ n Ic(n)l 2 is a convergent series. co. Let Ilull~ d J m a x { l u ( x ) l . x c R}. Then IlUMNII~ -- max{lc(n)l" M ~ n N}, so the expression u(x) - Y'~-n c ( n ) l ( x - n) belongs to span B if and only if c(n) ~ 0 as o~. Example 2 deserves special attention since the norm II" 112 is derived from the inner product in L2(R), and the translates B = { l ( x - n) : n C Z} form an orthonormal set in that inner product space. In general, when the L 2 norm is chosen, and ¢ generates an orthonormal set B, then by adapting the proof of Parseval's formula 2 we can show that u belongs to span B if and only if the sequence of samples {u(n) : n C Z} belongs to g2(Z). Furthermore, B will be an orthonormal Schauder basis for span B, and since ((/)n, (/)m) = 5(n - m) for n, rn C Z, we see that m
¢(x -
-
-
(:x:)
E
era) -
(4.21)
m
This shows how we can compute the expansion coefficients of u in the orthonormal basis B by sampling, a simpler alternative to inner product integrals. However, the inner product must be used to evaluate the initial approximation of an arbitrary function u E L2(R) in span B: P " L2(R) ~ span B;
P u ( x ) d~j E
(¢n, u> ¢~(x).
(4.22)
nCZ This P is actually an orthogonal projection, generalizing the one in Exercise 13 of Chapter 2. It is not true that (¢n,u} = u(n) for arbitrary u c L2(R), but only that (¢n, u} = (Pen, u) = (¢~, Pu) = P u ( n ) since P e n = ¢~ and P = P*. We now restrict our attention to the L 2 norm, I1" 112, and consider the sampling spaces generated by two other interpolating functions ¢. The first is a hat function ¢(x) = h(x) like one of those defined in Equation 2.22: h(x) dJ
~l--]X,
iflxl
[ 0,
if x _< - 1
(4.23) or x _> 1,
This bounded, continuous function has compact support in the interval [-1, 1], so it is square-integrable. The sampling space generated by h consists of all piecewise
2Solve exercise 14 of Chapter 2!
C H A P T E R 4. S A M P L I N G A N D E S T I M A T I O N
120
linear square-integrable functions with joints at the integers. Although the translates B = { h ( x - n ) : n c Z} are not orthogonal, it is still true t h a t ~--~,~c ( n ) h ( x - n ) belongs to the sampling space span B if and only if the infinite series ~--~-nIc(n)l 2 converges. This is left as an exercise.
Band-limited functions The second example is ¢(x) - sine (x) - sin(.x) as introduced in Equation 3.47 71"X and graphed in Figure 3.7. Recall t h a t the Fourier integral transform of this ¢ is 1 1 the indicator function of the balanced interval I - [-31 ~], so ~ ¢ - lx is piecewise constant and compactly supported on I. It satisfies the interpolation condition because the numerator of sine (x) is zero at every nonzero x C Z. Plancherel's theorem may be used to show t h a t the set of functions B = {¢n(X) d¢_f sine ( x - n ) ' n
-
C Z} is an orthonormal basis for span B"
-
_
_
½ using the identity ~-¢a(~) = e-2~ik~-¢(~), whose proof was left as an exercise. Thus the expansion coefficients of u c V are just the samples {u(n) : n C Z}. But the same identity shows t h a t every u E V has a Fourier integral transform supported in I as well:
which is evidently the restriction to I of the 1-periodic function given by the exponential Fourier series in parentheses. A function u = u(x) will be called band limited with bandwidth T if its Fourier integral transform is a square-integrable function s = s(~) satisfying the compact T This s is called the spectral density support condition s({) - 0 if { < - ~T or ~c > ~_. of u. The sampling space for sinc is thus a subset of the band-limited functions u with bandwidth 1. In fact, it is all of them, and we will show more generally t h a t the sampling space generated by ¢(x) = Tsinc ( T x ) c o n s i s t s of all band-limited functions of bandwidth T. We begin by showing t h a t band-limited functions must be very smooth: Theorem
4.8 If u = u(x) is band-limited, then
1. For every n > O,
dn
it(X) exists at each x e R . In particular, u (n) (0) exists.
2. The Taylor series for u about x = 0 converges to u everywhere: oo
n! n=O
X
.
4.1. APPROXIMATION AND SAMPLING
121
Proof: Let T be the bandwidth of u, and let s - ~-u be its spectral density. Fix x0 E R and write T
U(X0) -- .~--ls(x0) -- /:x~
--
s ( ~c
d~.
T 2
(x)
T T The domain of integration is I - I--if, 5-] because s - 0 outside that interval. The first result is obtained by differentiating under the integral sign:
dn dx
/~
T
U(Xo) 2
We may interpret this as an inner product in L2(I), and estimate it with the Cauchy-Schwarz inequality for the derived norm: dn
lTrTl~+½
dx---~ u( xo )
v/ n + ~ 1
Here we used the identities l i l - 1 and le2~ix°~l- 1 for all xo and ~. Also, I l s l l IIf~ll - I1~11 by Plancherel's theorem. For any n >_ 0, this gives I~(~)(xo)l ___al~TI ~, where a - ~ I1 1 _> 0 is constant independent of n or xo. In particular, the inequality holds for xo - 0. Thus for all x E R and all n _> 0,
•a•,
n!
where a is independent of n > 0 and x c R. Using this in the comparison test with the absolutely convergent Taylor series for ael~Txl gives the second result. [] Since the sequence of numbers {u(n)(0) • n - 0, 1 , 2 , . . . } determines all the values {u(x) • x E R}, it seems less miraculous that samples of a band-limited u, at regularly-spaced points sufficiently close together, also determine u(x) everywhere: Theorem
4.9 ( S h a n n o n )
If u - u(x) is band-limited with bandwidth T, then oo
n--- --(20
Proof." Let s be the spectral density of u that is supported on the interval J = T T [--if,-if]. Then s(~) - 1j(~)s(~) for all ~ c R, since s is already localized to J. We expand s in its T-periodic Fourier series: oo
s ( ~ ) - 1 j ( ~ ) s ( ~ ) - 1j(~)
oo
c(n)e2~in~/T:
2 nz--
(2~
nz--
(x)
CHAPTER 4. SAMPLING AND E S T I M A T I O N
122
Figure 4.1: Left" Part of the graph of e-X2sinc (x). Right" Part of the graph of the "hat" function. Both curves have maximum value 1, and two roots nearest 0 at x - - 1 and x - +1. The factor 1j(~) is needed for equality on all of R since the series defines a periodic function supported outside the interval J. We combined it with the exponential to get bn(~) de__f 1 j ( ~ ) e ~ n ~ / T = I~(~/T) ~ n ~ / T , where I - [--5'1 2]1 and ,~-1 l i(x) - s i n c (x). By Exercises 11 and 12 of Chapter 3 we may evaluate 9c-lbn(x) - Tsinc (Tx + n). We now reverse course and write u as the inverse Fourier integral transform of the series for s: oo U(X) -- .~--ls(x)
--
~
ftz-(:x3
04)
c(?rt).~'-lbn(x) --
~ c ( n ) T s i n c (Tx + n). n---(:x:)
(4.26)
On the other hand, the Fourier coefficients {c(n)} for Equation 4.25 can also be written as inverse Fourier integral transforms of s" 1/T c ( n ) - -~ ~ s(~)e - 2 ~ / T
1/? ~ 1(n) d~ - -~ ~ s(~C)e2~(-~) ~:d~c - ~ u - ~
.
(4.27)
Substituting Equation 4.27 into Equation 4.26 and replacing n +-- - n yields the result. [] There are benefits to choosing an interpolating function ¢ with fast decay away from its peak at 0. We may wish to ignore entirely the values of ¢ outside I = [-1, 1], and then faster decay implies a smaller error I1¢- li(~l 2. This quantity is relatively large for sine, about 10%. It can be reduced to about 0.1% by using __X2 t h e aaussian sine function ¢ ( z ) - e sine (x), which is depicted in Figure 4.1 together with the hat function of Equation 4.23, to emphasize their similarity. The Gaussian sine function does not generate an orthonormal basis for its sampling space, however.
4.2. M E A S U R E M E N T AND ESTIMATION
4.2
123
M e a s u r e m e n t and E s t i m a t i o n
Consider what it means to make a measurement. For example, what is the length of a pencil? We must suppose that the pencil actually has a length that various observers can agree on. Upon close examination, even this simple problem is surprisingly complex. It is known that a pencil expands and contracts with temperature and humidity changes. Also, the end of a pencil looks rough under a microscope, so the measurement points must be specified among the peaks and valleys at the ends. Indeed, any mechanical device that touches the rough end of a pencil will press down some of these peaks, influencing the measurement and causing different observations to disagree. In general, it is common to suppose that an observable quantity has an ideal value, which is a constant real number. In practice, there will be various errors and uncertainties in any physical measurement. Taking a measurement at best gives some information about the likelihood of different ideal values. One way to model this is to introduce a random variable whose probability density function is determined by a measurement, and then estimate the ideal value by some expected value 3 or other functional of the density. This estimated ideal value should depend on the measurement, of course, or else the instrument is useless. We make this precise, and derive formulas, using the notion of joint and conditional probabilities.
4.2.1
Quantization,
precision,
and
accuracy
In practice, measurements are always quantized, taking one of finitely many discrete representable values that the instrument can produce. For example, a twelve-inch ruler marked in sixteenths of an inch can yield one of only 16 x 12 = 192 different nonzero measurements x c { ~ " n - 1 , . . . , 192}. Some measured lengths would fall between marks, of course, and these would be read to the nearest sixteenth of an inch. The quantization error of any quantized measurement is half the distance between adjacent values. For this ruler, that is 1 inch. In some cases, however, it is safe to assume an ideal instrument, with zero quantization error, because the quantization error is negligible compared to other errors. A length measurement x with the example ruler implies only that the ideal value y lies in the interval Ix def [X- ~2' X -~- ~2]" Told that the ruler read x, we may only conclude that y E Ix and that every value in that interval is equally likely. Hence, we may introduce a random variable Y = Yx to represent our knowledge, and give it a uniform probability density function supported on that interval. In general, a measurement x yields only partial information about the ideal value, which may therefore be represented by the probability density function of a random variable Y = Yx. The variance of Y indicates the uncertainty of this information, so we define the imprecision of the measurement to be the square root of this variance. In terms of expectations E, this is the root-mean-square error v/E(I Y - E(Y)I2). Note that even an ideal instrument can have nonzero 3Some random variables have densities with no expected value!
CHAPTER 4. SAMPLING AND ESTIMATION
124
imprecision. Conversely, a non-ideal instrument can have zero imprecision. An instrument that counts pennies can make only nonnegative integer measurements, and has quantization error 7, 1 but can have zero imprecision if it never miscounts since the ideal value is also a nonnegative integer. Given a measurement x of an ideal value y, we may hope that x is close to y. Since our knowledge of y is limited, we may at best label, or calibrate, the measuring instrument so that x = E(Yx), the mean value of the random variable Yx determined by the measurement x. But even if the instrument is not calibrated, we may define the inaccuracy of the measurement as the root-mean-square error v / E ( I Y - y12). It can be shown, using the Cauchy-Schwarz inequality of Lemma 2.4, that this is minimized when y = E(Y), and thus inaccuracy is never smaller than imprecision. Measurement
density functions
Inaccuracy and imprecision may be computed from the measurement density function, which is a nonnegative function f = f(x,y) giving the likelihood of any combinations of ideal value y and measured value x:
Pr(X C [ax , bxl,Y E [ay , by]) def -
~abx /a bY f (x, y) dxdy. X
(4.28)
Y
Since P r ( X E R, Y C R ) = 1, we must have that ffR2 f(x, y)dxdy = 1. Such an f is called a joint probability density function for the random variables X and Y, giving likelihoods that they fall within particular ranges. W i t h another normalization, it can be used to compute the likelihood that, given a measurement x, the random variable Y = Yx representing the ideal value falls in a particular range [ay, by]: Pr(Y ¢
[ay , bYl lx )
def
-
~a bY f ( y l x )
(4.29)
dy,
g
where
f (y l x )
de f
l f .x,( y);
cx -
Cx
f (x, y) dy.
(4.30)
oo
The normalizing constant Cx must be finite and positive at each representable x; it guarantees that P r ( Y E R Ix) = 1. Such a normalized f ( y l x ) is called a conditional probability density function. If in addition the instrument has finite imprecision, then the variance of Y given x will be finite for each representable x. This variance is comparable to f-~c~ Y2f(YlX) dy, which in turn is just a multiple of f _ ~ y2f(x, y) dy. If this last integral is finite, we will say that the instrument is focused. An instrument with measurement density f is calibrated if, for each measurement X~
E(yx ) _ E(y
I z ) def
Y I ( Y l X) oo
dy
-
x.
4.2. M E A S U R E M E N T AND E S T I M A T I O N
125
The measurement density may be uncalibrated by an amount that depends on x. For the example ruler, the domain of the measurement is { 10g;~1, . . . , 192} 16 , and the measurement density function is:
f(x,y)-
1,
ifx-0and0<_y<
~'
ifxE{l'""l-~}
1,
ifx-12and
0,
otherwise.
1;
andx-l
12-~
<-y<x+
l;
<_y<_12;
Then nonzero length measurements are calibrated, but for x = 0 we have E ( Y o ) = 1 ¢ 0, and for x - 12 we have E(Y12) - 1 2 - ~ =fi 12. 6~ The measurement density may also be uncalibrated by an unknown amount that is not computable from x. For example, let Y be the number of photons of all colors impinging on a detector in one second, and x the number that the detector counts. If 90% of red photons but only 50% of blue photons are detected, then the measurement density will be uncalibrated by an amount that depends on the color spectrum. For blue light, we will have E(Yx) = x/0.50, while for red light it will be E(Zx) = x/0.90. The imprecision of an instrument at a measurement x is the square root of the variance of Yx. This is finite for focused densities. For a calibrated measurement density f, variance is given by the following formula: Var(Y~) - V a r ( g I x)
de__f
lY --
xl2f(Yl x) dy.
(4.31)
OO
Then the imprecision is AYx = v/Var(Y I x). An alternative measure of imprecision is the width of the smallest interval centered at E ( Y ) that has at least 50% probability of holding the value of Y. For a calibrated measurement, this is given by the following formula:
W(Ylx)
de f
min
{ r
f ( y l x ) dy > 1/2
(~ > 0"
Jx-5/2
}
.
(4.32)
The imprecision by this definition is AYx = W ( Y ] x ) . The measurement density function is usually impossible to determine. However, if the measurement error is a sum of many small independent errors, the Central Limit Theorem 4 justifies approximating it by a normal density: 1
f (x, y) - ~
crlb _ al
exp((x-y)2)
-
2a 2
,
x E [a,b]
yE R
(4.33)
where the parameter cr > 0 is chosen to fit the imprecision of the instrument, and the range of possible values x is limited to allow normalization. The normalizing constants will be Cx = 1 for all x. This model implies that each measurement is calibrated and has the same imprecision: it is exactly a by the variance criterion, and approximately 0.954a by the 50%-interval criterion. 4See Ross, A First Course in Probability, third edition, page 340.
CHAPTER 4. SAMPLING AND ESTIMATION
126
Signal to noise ratio Inaccuracy in measurement is often called noise, especially in sequences of measurements such as digitally recorded sounds or images. The ideal values in this case are called the signal. Let u = { u ( n ) : n E N} be a sequence of measurements, and suppose t h a t each value u(n) can be written as v ( n ) + q(n), where v(n) is the ideal value and q(n) is a measurement error. The quality at sample n is just the squared ratio Iv(n)i2/iq(n)I 2, which is called the signal to noise ratio. But it can be misleading to focus on a single sample, and the measurements actually produce two sequences v and q. A useful concept is local power, or villa,b], defined by
iivil~a,b] dezf
b
1
l+b-a
E
Iv(n)I2
(4.34)
n--a
which is the average energy, or square norm, per sample in the sampling interval [a, b]. The signal to noise ratio of a sequence u defined on [a, b] expressed using local power is therefore ~NR(u)
Ilvl a,bl . Illa,bJ
(4.35)
de_f 101Ogl0 Iiq 2
Local power can be used to compute the signal to noise ratio of functions f =
f(t) of a real variable in the interval I - [0, 1]. For each N C Z +, the samples VN(n) -- f ( n / N ) , 1 < < n < N, when used in Equation 4.34, give a Riemann sum approximation to fo f(t)I 2 dt - flI 2, the square norm of f in L2(I). If f is continuous on I, then limN--~ IIvNII~I,N] --IlfiI 2 exists. We may therefore define the signal to noise ratio for such functions as
SNR(f)
de__f 10log10
IIf, II ]]fql[2'
(4.36)
where f - f8 + fq is written as a sum of ideal signal f8 and noise fq, with both parts required to be in L2(I). Of course, these notions are useful only when the signal and noise sequences are known. That is the case when the noise is caused by some transformation of an exactly-known initial sequence; then q is the difference between the initial and final sequences. When q is unknown, is can sometimes be estimated or modeled as a sequence of random variables with finite means and variances. So-called white Gaussian noise is a sequence of independent random variables 5 which each have the Gaussian, or normal, probability density function f(x) _ v/2-~crlexp
--)--~
with
mean 0 and variance cr2. 5When the r a n d o m variables take just the two values T and F, with P r ( T ) = p and P r ( F ) = 1 - p for all of t h e m given by some fixed 0 < p < 1, the result is called a sequence of Bernoulli trials.
4.2. MEASUREMENT AND ESTIMATION 4.2.2
127
Estimation
In our model, it is not possible to determine the ideal value y from a single measurement x since all we get is a r a n d o m variable Yx. We imagine t h a t many ideal values might yield the same measurement, each with some likelihood, and this many-to-one relationship is not invertible. But x and y play similar roles in the m e a s u r e m e n t density function f = f(x, y), and we may also imagine t h a t an ideal value y might result in various measurements Xu, each with its own likelihood. For an ideal instrument, the likelihoods are
b P r ( X C [a,
b] l y ) dJ ~ f (x l Y) dx,
(4.37)
where the integrand is a normalized version of the m e a s u r e m e n t density function called the conditional measurement density:
f (x
ly)
__
__
1
f (x, y);
Cy
d___f
Cy
f:x)
f (x, y) dx.
(4.38)
J _ oc
For each y, the normalizing constant Cy guarantees P r ( X C R ly ) = 1. T h e normal density of E q u a t i o n 4.33 is a common model for estimating unknown measurement density functions, t h o u g h its definition must be slightly modified:
f(x,y)-
1
~alb_aleXp
(-
2a 2
,
xcR,
y E [a,b].
(4.39)
From the estimation perspective, the range of ideal values y is constrained to a b o u n d e d interval, but we imagine t h a t a m e a s u r e m e n t Xy can produce any real number. By r e p e a t e d measurement, the likelihoods of various m e a s u r e m e n t s X can be approximated, and then the one-to-many relationship y H Xy can be inverted to get a good approximation for y. Such an a p p r o x i m a t e inverse is called an estimator, and it is implemented as a decision function, y ~ d ( x l , . . . , XN), giving an approximation for the ideal value y from a sequence of N independent measurements X l , . . . , XN. For example, d~(xl,x2) de__f 1(2; -[-X2) is one possible estimator: it uses the average of two independent measurements as an estimate for the ideal value. More generally, we may take the average of N measurements, d a N ( X l , . . . ' x N ) dej Xl -~-""-[-ZN
X
'
(4.40)
which under certain circumstances converges to the ideal value as N ~ oo. We will always assume t h a t the N measurements x 1 , . . . , X N are independent, so t h a t likelihood calculations factor into N pieces: Pr(X1 E [al, b l ] , . . . , XN
E [aN, bN] IY) =
f(xl,...,xNly) lib11 fabN N
. . . .
dxl...dXN
(/bl
128 --
)
CHAPTER
f (xl l y) d x l
4.
SAMPLING
""
f (XN l y) dXN
1
)
AND ESTIMATION ,
N
since f ( x l , . . . , X y l Y) d y f ( X l l Y ) ' ' ' f ( x N l y ) -- Cy N f ( x l , y ) ' ' ' f(xN,y). The expected value of any decision function d - d ( x l , . . . ,XN) for y is then a multiple integral involving N copies of the normalized measurement density function: E(d ly ) -
d ( x l , . . . , x N ) f (xl l Y ) ' ' " I ( X N l Y) d x l . . . d x N .
... O0
O0
Here we consider all possible sequences of measurements x 1 , . . . , x N, weighted by their likelihoods. We can sometimes design a decision function d so that its expected value is the ideal value: E ( d l y ) - y. Such a d is called an unbiased estimator. The averaging estimator d~v is one example. A biased estimator may also be useful, especially if we know its bias. For example, consider measuring the ideal breaking strength y of a rope by hanging various weights x 1 , . . . , x g on it. Our instrument will record the strength measurement xk if and only if xk < y. Choosing units so that all values lie in the interval I - [0, 1], we get a measurement density function on the unit square 0 < x, y < 1 defined by the formula
2, i f 0 _ < x < y _ < f (x, y) --
O,
1;
otherwise.
(4.41)
The factor 2 insures that f f I × I f ( x , y) d x d y - 1. Given N measurements x ~ , . . . , XN with this instrument, we let d ( X l , . . . ,XN) de_f m a x { x 1 , . . . , X N } be the estimator for the ideal value y. We are sure that d ( X l , . . . ,XN) < y since xk < y for all k, so the estimator is biased on the low side of y. But this bias can be removed by using d - N~____A1m a x { x 1 , . . . , XN} since for any y > 0,
E(d(X1,...,XN) Iy) -= ~I'"~Id(Xl'""xN)f(xlly)"'f(xNly)dxl"'dxN :
= 2 N(2y) -NN! = y-NN!
f0 y
dXl
dx2"'"
x N-1 1)! d x l
Xl ( N -
=
Xl dxN Ny N + 1 < y"
The factor N! appears on the last line since there are N! orderings of (Xl,... ,XN), and each one contributes the same amount to the total as the single one 0 _< X N < " " < X l < y that we actually integrate. Iterating the N - 1 inner integrals successively produces:
X~V_2 XN-1,
2!
""'
XlN-1 1)!'
(N-
(4.42)
4.2. M E A S U R E M E N T A N D E S T I M A T I O N
129
and the remaining steps are straightforward. It is left as an exercise to show that the normalizing constant that determines f (x l Y) from f (x, y) is Cy = 2y. The inaccuracy R(d, y) of an estimate d for an ideal value y, which is called risk, is similar to the inaccuracy of a measurement: it is given by the formula
R2(d,y)
-
E ( l d - y[2)
(4.43)
Id(xl, . . . , XN) -- yl2 f (Xl l Y ) ' ' " f ( x N l y) dxl . . . dxN. (:X)
For an unbiased estimator, the risk is the square root of the variance Var(d I y), which is like the imprecision of an instrument rather than the possibly larger inaccuracy. For example, if d(x) = x and f is the calibrated normal density of Equation 4.39 with imprecision a, then Var(d(X)) = a 2 and the risk R(d, y) = a of the estimate is exactly the same as the imprecision of the measurement. It is also independent of y, just like the imprecision. For the same measurement density, averaging N independent measurements with the averaging estimator d~v of Equation 4.40 decreases the risk: Var(d~v ) - ~a 2
=~ R(d~N, y ) -
- ~1 R(d, y) •
(4.44)
This is another consequence of the Central Limit Theorem. T h e C r a m ~ r - R a o lower b o u n d
Can the risk be reduced faster by a more clever choice of decision function? Any estimate d ( x l , . . . ,XN) gets some information about the density f from the measurements x 1 , . . . , X N, but there are many ways to combine these measurements to compute y. Also, the risk decreases with more samples N, if the approximate density determined from the histogram of X l , . . . , XN converges to f ( x l y ) as N --+ c~. Still, the computation of y from this density is possible if and only if f ( x [y) changes with y. For instruments whose measurements depend smoothly on the ideal value 0 y, that holds if and only if -O-yyf(Z l Y) is nonzero. Thus N and o-~f(x l Y) may be expected to take part in any risk estimate. But in fact, these two are the only relevant factors. Regardless of the choice of decision function dN for N independent measurements, there is a lower bound on Var(dNly)) that decreases with N and depends only on how the measurement density f ( x l Y) changes with y: 1
Var(dN l Y) ->
N E (f£
f(x
2)'
(4.45)
where we take o@ log f (x l Y) - 0 if f (x l Y) - O, by convention. Inequality 4.45, which is proved as Theorem 1 on page 18 of Hoel, Port and Stone's Introduction to Statistical Theory, is known as the Cramdr-Rao lower bound. It implies that the
130
CHAPTER
4. S A M P L I N G
AND ESTIMATION
risk of an unbiased estimate can be reduced by at most a factor 1 / x / ~ by taking N independent measurements. This lower bound is attained in many usual cases. Using the averaging estimator of Equation 4.40 with the normal measurement density of Equation 4.39 gives Var(d~v, y) - a 2 / N by the Central Limit Theorem. The Cram6r-Rao lower bound is the same" i
o.4
o.4
o.2
However, if the estimator is biased or if the measurement density function is discontinuous or nondifferentiable in y, the Cram~r-Rao inequality does not apply. It is left as an exercise to show that R ( d N , y) = O ( 1 / N ) for the breaking-strength estimation of Equation 4.41. Thus, a biased estimate from a nonsmooth instrument may gain more accuracy from repeated measurements than any unbiased average using any instrument with a smooth dependence on the ideal values.
4.3
Exercises
1. Find the Lagrange polynomial through the points (0, 0), (1, 2), (2, 4). 2. Fix x and find a formula for the value y = f ( x ) of the Lagrange polynomial f through the points ( - 1 , p), (0, q), and (1, r), in terms of x, p, q, and r. Then find dy/dq. 3. a. Find the Lagrange polynomial Ak = Ak(x) of degree k that interpolates {(j, 2J) : j = 0, 1 , . . . ,k}. (Hint: use Newton's form.) b. Using Ak from part a, prove that for every n >_ k,
(o)+
+
j=0
c. Using part b, prove that ~-}~=0 (~) - O(nk), as n ~ oc. 4. Find the expansion in Chebyshev polynomials T0(x), T1 (x), T2(x) of the function f ( x ) - 1 - x 2 defined for x E [-1, 1]. 5. Suppose that f ( x ) - m x + b for some constants m, b. Show that for any sampling of f, the piecewise linear approximation exactly equals f. 6. Implement e p w l i n e a r (x, y [], a , b , N), equispaced piecewise linear interpolation through the set {(xk, yk) " k - 0, 1 , . . . , N} C R 2, where xk - a + k(b a)/N. 7. For x0 = x 2 ~yl] l - --y2 Xl~2 as in Equation 4.14, prove that if Xl ~ X2 and YlY2 < 0, then Xl < x0 < x2.
4.3. E X E R C I S E S
131
__ 1 X2l(y3-y2) +X~ (yl --y3)+x~(y2 --Yl )
8. For x . -
~ Xl(y3-y2)+x2(yl-y3)+x3(y2-yl) a.s in Equation 4.16, prove that if Xl < x2 < x3 and Y2 is not between yl and y3, then Xl < X. < X3.
9. Let B dej {On " n C Z} C L2(R) be an orthonormal set of functions of one real variable, and write I1" II for the L 2 norm. For each u E L2(R), define
P?_t(x)
de__f E
(¢n,
nCZ
U} (~n (X).
Prove that P " L2(R) ~ span B. 10. Suppose that ¢(x) is the hat function: ¢(x) dej ~ 1 - Ixl, I, O,
if Ixl < 1; if x < - 1 or x > 1,
Let c -
{c(n) • n e Z} be a sequence of complex numbers, and put f = f ( t ) - ~-~n~Z c ( n ) ¢ ( t - n). Show that f C L2(R) if and only if c C t!2. (Hint" compute Ilfll 2 in terms of {Ic(n)12}.) 11. a. Find an example of measurement and instrument that has zero imprecision but nonzero inaccuracy. b. Find an example of measurement and instrument that has zero imprecision and zero inaccuracy, but nonzero quantization. 12. Suppose that f ( t ) - t for 0 <_ t _< 1. Fix N C Z + and let f N be the piecewise constant approximation to f given by N-1
f N ( t ) dej E
k f(-A )l(Nt-
k),
k=0
where 1 is the indicator function of the interval [0, 1). a. Prove that IIf - f N II -- 1 / 3 N 2. b. Treating f as the signal and f noise ratio of this approximation.
f N as the noise, compute the signal to
13. Let f - f ( x , y) be the joint probability density defined on the unit square Q - {(x, y)" 0 < x, y _< 1} by the formula
f (x, y) --
2, O,
ifO<x
Suppose an instrument has this f as its measurement density function. Given N measurements x 1 , . . . , Z N with this instrument, let
d(xl,...,XN)
de__f m a x { x l , . . . , X N }
CHAPTER 4. SAMPLING AND ESTIMATION
132
be the estimator for the ideal value y. a. Prove that f fQ f (x, y)dxdy - 1. b. Compute the normalizing constant cy and determine f(x[y). c. Find the formula for P r ( X C [a, b]]y) for 0 _< a < b _< 1 d. Compute the risk R(d, y) for y > 0.
4.4
Further Reading
• Paul G. Hoel, Sidney C. Port and Charles J. Stone. Introduction to Statistical Theory. Houghton Mifflin Company, Boston, 1971. ISBN 0-395-04637-8. • Robert J. Marks, II. Introduction to Shannon Sampling and Interpolation Theory. Springer-Verlag, New York, 1991. ISBN 0-387-97391-5. • John H. Mathews and Kurtis D. Fink. Numerical Methods Using MATLAB. Prentice-Hall, Upper Saddle River, New Jersey, third edition, 1999. ISBN 0-13-270042-5. • Alan V. Oppenheim and Ronald W. Sharer. Digital Signal Processing. Prentice Hall, Englewood Cliffs, New Jersey, 1974. ISBN 0-13-214635-5. • Sheldon Ross. A First Course in Probability. Macmillan Publishing Company, New York, third edition, 1988. ISBN 0-02-403850-4.
Chapter 5
Scale and R e s o l u t i o n 5.1
Wavelet Analysis
Suppose t h a t w = w(t) is a function of one real variable. For a > 0 and any real b, the new function WaD defined by
Wab(t)
clef
1 w(tv/-d a
b)
(5.1) '
is a shifted and s t r e t c h e d copy of w. For example, if w = 1 is the indicator function of the interval [0, 1], t h e n W~b is the indicator function of the interval [b, b + a], divided by v/-d. Now imagine t h a t some fixed w is a waveform t h a t is present in a signal, centered at an unknown location t = b and scaled to an unknown width a. T h e collection {WaD : a > 0, b C R } consists of all shifted and s t r e t c h e d versions of w, and can be m a t c h e d with the signal to d e t e r m i n e the best values for a and b. In this context, w is called a mother function for the collection. A wavelet w = w(t) is a special kind of m o t h e r function, with three properties t h a t m a k e it a building block for a r b i t r a r y signals:
Duration: Iw(t)I is either zero or negligibly small at any t outside some b o u n d e d interval;
Cancellation: w(t) oscillates so t h a t its integral fR w(t)dt is zero; Completeness: Any signal can be a p p r o x i m a t e d by a linear combination from {Wab : a > O, b E R}. If w belongs to the inner p r o d u c t space L 2 ( R ) , where t h e n the first two conditions can be combined into one:
Localization:
(g, f} = f ~ ( t ) f ( t ) d t ,
f ~(at)w(t - b) dt --~ 0 as a --~ + c o , or as a -~ 0+, ¢ 2
or as b ~ + c o . 133
CHAPTER 5. SCALE AND RESOLUTION
134
We therefore say that a wavelet is nearly orthogonal to sufficiently distant versions of itself, since the integral that must decrease is just the inner product (W~b, w}, as can be seen by changing variables t ~ t + b and inverting the parameters a ~ 1/a and b ~ - b . Also, IIw~b[I- [IwlI for all a, b because of the normalization by v/-a. 5.1.1
Haar
functions
The simplest example is the Haar wavelet" 1, -1, 0,
w(t)-
if0_< t < 1/2; if 1 / 2 _ < t < 1 ; otherwise.
(5.2)
Its duration is the interval [0, 1] of its support, which approximates its position. The localization integral can be evaluated explicitly. If one of the following holds, then v/-a f ~(at)w(t - b) d t - 0: 1. i f b b - l o r b > _ a , 2. if a 5
~1 o r a 2 2 ,
3. if a >-- ~ o r a <
1 for
fixed a,
forb-0,
1 -- 2(b-t-1)'
for fixed b > 0,
4. if a > 0, for fixed b _< - 1 , 1 5. ira_> b--~1, for fixed b C ( - 1 , - 7 ]
2 for fixed b E ( - 31 , 0) . 6. ifa_> 2-g¥7, The only remaining case, fixed b c ( - 1 , 0) and a ~ 0+, gives
x/~
f ~(at)w(t -
b)dt
_
-(b+l)v/-a, {bxfd '
1
if-l
(5.3)
whenever 0 < a < 2 ( b1+ l ) ' which means that the integral is O(v/-d) as a ~ 0+ Cases 1 through 5 are depicted in Figure 5.1. Case 6 and Equation 5.3 are left as exercises. To show that the Haar wavelet has the completeness property, it is enough to show that all piecewise constant functions are superpositions of Haar functions W~b. But 1, the indicator function of [0, 1), is such a superposition, though it takes infinitely many terms. The proof starts by considering the partial sums, namely
J J w(t/2 j) dpJ(t) def E 2-J/2w2-~,o(t) -- E 2J = j=l
j=l
0, 1 - 2- J , --2 - J ,
ift <0; if 0 < t < 1; if 1 < t < 2J;
0,
if
(5.4)
t > 2 J.
The first four summands ½w(½t),..., ~w(1Agt ) are shown together in Figure 5.2, and Figure 5.3 shows the first four partial sums ¢ 1 , . . . , q54 plotted together.
5.1. WAVELET ANALYSIS
1/a
(4)
I
135
(2)
(1) 1/a
/
7i
1/a
I"
I"
-1
~ 1/a
(5)
1/a
I 1¢
(3)
/ [
.
1/a
,,+.,
-
I
Figure 5.1" Graphs of Haar wavelets configurations.
1/4 1/8 1/16
w(at)
and
w ( t - b)
Ir
in most of the listed
;~;i~<;LLil;.;;i.;;L<.;7<
16
0
'
i
in ....................................................... ,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 5.2" Four dilated Haar wavelets.
1/4 1/8 1/16
2 I. . . . . . .
4 I
8 .I...................................................................................................................................................................
Figure 5.3" Partial sum of four dilated Haar wavelets.
16
C H A P T E R 5. SCALE AND R E S O L U T I O N
136
It is clear from the formula that at every point t E R, CJ(t) + l(t) as J -~ ~ . What is more important is that inner products with CJ converge to averages as J+~: L e m m a 5.1 If f ~ lu(t)l 2 dt exists and is finite, then lira (¢J u} - (1 u}.
Proof: Equation 5.4 implies that
1
lim (¢J u) - fJo u(t)dt J-+ c~
~
lim
[2 - J jf02Ju(t) dt 1
J-+ c~
The second term vanishes in the limit by the following estimate: for each J, note that l ( 2 - J t ) is the indicator function of [0, 2J), and write
2J 2-J Jo
O0
~ (x) u(t) dt - 2 -J Jo
<
(~00
=
2J/2
l(2-Jt)u(t)dr.
)1/2(jiO0lu(t) 12
Then apply the Cauchy-Schwarz inequality to the integral: l ( 2 - J t ) u(t) dt
]l(2-Jt)l 2 dt
Ju(t)j2dt
dt
)1/2
.
This becomes 2 -J/2 ( f ~ Ju(t)J 2 dr)1/2 when multiplied by 2 - J . But the integral of D Jul2 is finite by assumption, and 2 -J/2 ~ 0 as J --~ + ~ , finishing the proof. 5.1.2
The
affine group
The mapping x ~ ax + b of a point x E R, determined by parameters a > 0 and b E R, is called an affine transformation. The set of ordered parameter pairs {(a,b) : a > O,b e R} with the rules (a', b')(a, b) = (a'a, a'b + b');
(a,
b) - 1
=
(a -1, - a - l b ) ,
(5.5)
is called the affine group or the Ax+B group, and is denoted by Aft. The atone group's identity element is (1, 0), denoted by e. The multiplication rule comes from composition:
x H a'(ax + b) + b' = a'ax + a'b + b'.
(5.6)
Note that the left factor (a', b') is applied second, much as matrix A' is applied to vector x second in the composition A'Ax. A matrix representation of Aft is a function p from group elements (a, b) to invertible matrices p(a, b), which converts group multiplication into matrix multiplication. One such representation is
(a b ) ~ p(a b ) - ( a '
'
\ 0
b~ 1 /
"
(5.7)
5.1. W A V E L E T A N A L Y S I S
137
Matrix p(a,b) sends vector ( x1)
to vector ( a x ? b )
. It is left as an exercise to
check t h a t p((a', b')(a, b)) - p(a', b')p(a, b). There are many other matrix representations, including the obvious generalization
(a,b)~-.
(a 0) 0 0
1 0
0 1
.
(5.8)
The constant function p(a, b) - 1 is also a matrix representation of Aft, since it preserves the multiplication, but it is not faithful, or one-to-one, because it sends many different group elements to the same 1 x 1 identity matrix.
Unitary representations We can also interpret (a, b) c A f t as the substitution t ~ ( t - b)/a that sends a function f to fab. This gives a more general representation of A f t as linear transformations, which are generalizations of matrices. For each (a, b) E Aft, define
a(a, b) f (t) - lab(t) de__j _~fl
(t-b)a
"
(5.9)
This a(a, b) is a linear transformation, because addition in any function space occurs pointwise. Namely, for any functions f, g and any scalar c,
a(a, b)[f +cg](t)
=
1
xf d [f +cg]
1 (t-b)
(t-b) a
= -~ f
a
1 (t-b)
+ -~cg
a
a(a, b) f (t) + ca(a, b)g(t). In fact, a(a, b) is an invertible linear transformation, with inverse a(a, b)-lf(t) v/-af(at + b), and the inverse a(a, b) -1 represents (a, b) -1 = (a -1, - b a - 1 ) . Composing such substitutions shows how the group multiplication is converted into composition of linear transformations:
1 (t-b') ai
a(a', b')a(a, b) f (t) - a(a', b')g(t) - -~a~g where g ( s ) -
a(a, b ) f ( s ) -
a(a',b')a(a,b)f(t)
=
1
~f
(a_~). But then, putting s -
1 ~I f CJv
7- - b I I --d t-b~
,
t-b~
- 7 - gives
= ~ 1 f ( t - (a~ba + b~)
a
a(a'a, a'b + b') f (t). Observe that a is faithful, if the space has enough functions: a(a, b) - a(a', b') means that a(a, b)f(t) - a(a', b')f(t) for every function f and every t. There must simply be enough nonconstant functions so that this can only hold for all t if a - a ~ and b - b~.
CHAPTER 5. SCALE AND RESOLUTION
138
For definiteness, suppose now that f = f(t) belongs to L2(R), the inner product space of complex-valued, square-integrable functions of one real variable, with inner product {u, v} - f _ ~ e(t)v(t) dt. Then cr(a,b) " L2(R) --+ L2(R), and the factor 1/x/-d insures that II (a,b)fll = II/11. This space contains the Haar wavelet, and is a natural place to look for other wavelets. It is big enough to make cr faithful, because it contains 1: if a(a, b) = a(a', b'), then
l(t)_a(a,b)_lcr(at
,
b t ) l ( t ) _ l ( a t + b - b att )
-
1
( a- ~ t + b - b ' ) at
This can only hold for all t if a t = a and bt = b. Recall that a linear transformation U : X -~ X on an inner product space X is called unitary if and only if, for all f, g C X, we have:
(Ug, U f} = (g, f} .
(5.10)
Unitary transformations generalize rotations of geometric objects about the origin. They are rigid motions that preserve lengths as well as angles:
IIUfll - v/(U f , U f} = v/(f, f} = Ilfll.
(5.11)
But for each (a, b) C Aft, the linear transformation or(a, b) is unitary:
?~_~gl
{a(a,b)g,a(a,b)f} -
?
oo
(t-b)a
O(t)f(t) dt
lfx/-d (t-b)a - (g, f},
dt (5.12)
after the substitution t ~-- at + b. Some other examples of unitary transformations on L2(R) are given in Table 5.1. To show these are unitary, perform the appropriate changes of variable in the integrals behind Equation 5.10. The transformation f H lab is a combination of dilation followed by translation: lab = %Saf. Thus a(a, b) = Tb5a. This gives another proof that or(a, b) is unitary, since the product UV of unitary transformations U and V is unitary:
( u v g , u v f) = (vg, v f) = (g, f) ,
for all f, g.
Recall that the Fourier integral transform is defined by the following formula:
.)~U(~) def__
f
e-2rrit~t(t)
dt.
(5.13)
oo
)c is itself a unitary transformation because of Plancherel's theorem, Theorem 3.11. But it has a special relationship with these other unitary transformations. The
5.1.
WAVELET
ANALYSIS
139
l
Name
Action on f -- f ( t )
Inverse
v f (t) d~f f (--t)
reflection
dilation translation
1
~y
5~f(t) d~f - ~1f ( a )
t
5a I -- 5(1/a )
Tbf(t) d~j f ( t
b)
T b I -- 7"(_b)
(t)
Pc 1 -- P(-c)
p c f (t)
modulation
y
de__f e2~ict f
Table 5.1" Various unitary linear transformations of functions. Fourier integral transform of Wab can be expressed in terms of the Fourier integral transform of w:
jcWab(~)
_
e_2~it ~ 1
t -- b) dt
oo
=
-
e-27ri(at'+b)~x/a
a
w(t') dt'
oo
v/-d e-2~ib~Jzw(a~).
(5.14)
Another way of saying this is that oPWab -- YCTbSaW -- p-bS(1/a)YCW, or that after Fourier transformation, translation becomes inverse modulation, and dilation becomes inverse dilation: J f T-bJ2*
-
-
~bl;
J f S a J2*
-
-
5 a 1"
Likewise, after Fourier transformation, reflection becomes inverse reflection, which is again reflection:
-
F
e - 2 ~ i t ~ w ( - t ) dt -
O0
-
F
e-2~i(-t)~w(t) dt
O0
e-2"it(-~)w(t) dt
-
~w(-~).
(5.15)
O0
Thus 9cu9r* = / , / - 1
__//.
A unitary representation of the affine group is a faithful representation of group elements as unitary linear transformations. Equation 5.12 shows that (a, b) H a(a, b) is a unitary representation. The faithful matrix representation (a, b) H p(a, b) of Equation 5.7, however, is not unitary. Integration on the group Suppose t h a t f - f ( a , b) is a function defined on two real variables, a > 0 and b. Then f may be regarded as a function on Aft. It is possible to define an area
C H A P T E R 5. S C A L E A N D R E S O L U T I O N
140
element da for a = (a, b) E A f t so that, for any fixed a' c A f t ,
/Aff f (a) da -- /Aff f (ata) da.
(5.16)
In other words, the integral should not be changed by applying a ~ and thus r e n a m i n g the group elements. Such left invariance requires t h a t Id(a'a)/dal = 1, namely, the Jacobian of the change of variable a ~- at a is the constant 1. An area element da with these properties is called a left invariant measure. Now A f t is p a r a m e t e r i z e d by (a, b), so da = h ( a ) d a d b = h(a, b)dadb, where h is an u n k n o w n function to be determined. T h e invariance condition implies 1
-
I d(ata) I da
-
h(ata) h(a)
h(ata)
at 0
0 at
h(a)
O(att' bit) O(a, b)
-
h(a'a) h(a)
la'l
h(ata) h(a)
datt/da dbtt/da
datt/db dbtt/db (5.17)
Here a ' a (a',b')(a,b) - (a",b") defines the coordinate functions a" - a'a, b" = a'b + b' from E q u a t i o n 5.5. Thus h ( a ' a ) _ ~ 1 h(a), so p u t t i n g a - (1, 0) to force a ta - a t yields 1 h(a, b) - h(1, O) a2.
(5.18)
Thus, the left invariant integral of f over A f t is uniquely d e t e r m i n e d up to the arbit r a r y constant h(1, 0). Choosing the normalization h(1, 0) - 1 gives normalized left invariant measure, or Haar measure, on Aft, and uniquely defines the normalized left invariant integral:
L
f ( a ) da de__f
ff
/bec /a =-co
f(a, b) dadb a2 .
=0
(5.19)
W h a t functions f are integrable on Aft?. First, because the d o m a i n of integration is unbounded, it is necessary t h a t f(a, b) ~ 0 sufficiently fast as b ~ -t-00 and as a ~ +00. But also, because there is a factor 1/a 2 in the invariant measure, it is necessary t h a t f(a, b)/a 2 be integrable in a as a ~ 0+, which means f(a, b) -~ 0 s o m e w h a t faster t h a n a as a -~ 0. An example of such a function is f(a, b) = a2e -a-lbl, for which
L
f ( a ) da
tf
5.1.3
-
?/o
~ a2 e -a-lbl dadb = / : ~ j £ o o e -a-lbl dadb a2
oo
a.a)
oo
Wavelet transforms
Fix a wavelet w and define the associated wavelet transform W u of any function u - u(t) in L 2 ( R ) by the formula Wu"
tt:~
--> C ;
Wu(a,
b) de f
(Wab ' U} --
. / ~oo - -1~ ~(t -a b)u(t) dr.
(5.20)
5.1. W A V E L E T A N A L Y S I S
141
For w in L2(R), this formula makes sense for any u in L2(R). The numbers {Wu(a, b): (a, b) c Aft} are the amplitudes of the function u decomposed into rbtranslated and aa-dilated versions of the mother function w. It is roughly analogous to the Fourier integral transform amplitudes, {Yu(~c) : c C R}, of the signal u decomposed into > i - m o d u l a t e d versions e 2rri~t of the constant function 1. The set R, which is a group under addition, plays the role of A f t for Y. However, since >41 (x) - e 2~ix~ does not belong to L 2 (R) for any {, there is no analogous expression 2ru(~) = (p~ 1, u). A wavelet transform of a function is indexed by the parameters (a, b) of the affine group, just as the Fourier transform is indexed by the frequency parameter. Unlike the Fourier transform, there is no single wavelet transform; it varies with the choice of mother function w. The wavelet transform of a function is as well-behaved as the wavelet w. For example, since [(Wab, u)] < [[wab[[[[u[[ -- I]w[[ [[u[[, this implies that [Wu(a,b)] < Ilwll Ilull for all (a, b) e Aft. Thus the wavelet transform of a square-integrable function, using a square-integrable mother function w, is a bounded function on Aft. Likewise, if w is smooth and has compact support, then W u is a smooth function of a and b. This is proved by differentiating with respect to a or b under the integral sign in Equation 5.20. For what w can u be recovered from Wu? Clearly w = 0 won't work, so that trivial case is excluded by the normalization assumption Ilwl[ = 1. For certain special w, there is a formula that recovers averages of a function from its wavelet transform. For example, suppose w is the Haar mother function defined in Equation 5.2. Since 2-J/2Wu(2 j, 0) is the inner product of u with ~ w ( ~ t ) , the sum of certain samples of W u is the inner product of u with the corresponding sum of dilated w's: J
Z
2-J/2Wu(2J' O) - (¢J, u) --+ (1, u},
as J --+ oc,
(5.21)
j=l
~ j J 1 ~l W ( 1 ~Tt) as in L e m m a 5.1. To get the value of u at a point t, just take averages of u over the interval [t, t + 2 -M] by starting the sum at j - - M and let M -+ oo. For example, if u is continuous at t - 0, then where
CJ(~:) --
(x)
(Do
d°J j=-oo
lira
M--+cxD
j=-
M
'
"
(5.22)
A necessary condition for invertibility is that u ~ W u is one-to-one. Namely, if u -¢ v, then W u ¢ Wv. W i t h nice wavelets for which W u is a continuous function of (a, b), this is equivalent to the property that Wu(a, b) =/= Wv(a, b) for some (a, b) c Aft, if u =/= v. But since W u - W v - (Wab, u} - - (Wab, V} - - ( W a b , U - - V } - W [ u - v], this is equivalent to the condition that if u ¢ 0, then (Wab, u} ¢ 0 for some (a, b) E Aft. Another way that W is one-to-one is that ]IW IIA -- 0 if and only if ]l ll- 0. The Hermitean inner product on Aft, and thus the norm I " IAfr, is defined using
C H A P T E R 5. S C A L E A N D R E S O L U T I O N
142
the left invariant integral on the group: (u, v)Aff de__f --
~2(a)v(a) da ff
=-oo
Ja
ft(a, b)v(a, b) dadb
(5.23)
a2
=0
This kind of one-to-one condition follows from the analog of the Plancherel theorem, for the wavelet transform rather than the Fourier transform: 5.2 Suppose that the wavelet w is square-integrable and there is a finite, nonzero constant Cw with
Theorem
c~ -
~ oo ifw(~)l = =0
d~ -
£oo ifw(_~)l~.
~
T h e n f o r all square-integrable u -
u(t)
d~.
=0 and v -
v(t),
we have ( W u , W V i A ff =
Proof: Evaluate the inner product (Wu, WV}A if"
----(X~
=
]a If° ---0
~ab(t)u(t) dt
--CX3
=0
----CX~
l
~-;ab(8)V(8) ds dadb a2
w t - b)db] da 1 _ s - b ) 1__ v/-d ( a --~ dsdt.
~t(t)v(s) ,t=-~
l[i
= _ ~ x/~ w(
a
The innermost integral, the one with respect to the parameter b, is (w s, wt), where w t __ w t ( b ) de__f ~ W ( 1 ta___bb) a n d w s - - w s ( b ) def_ ~ 1 W(Sa-----~b) are considered functions of b. By Plancherel's theorem, (w ~, w t} - (Uw s, Uwt), and a direct computation yields
Uw t (13) - v/-de 2~uz gcw(-a/3);
Uw~(~)-
vfde2~i~ZUw(_a~).
Thus, <w s, w t} - a
e 2Èi(t-s)z Ifw(-a/~)l 2 d~ - a --- -- OO
e 2Èi(~-t)~ IUw(a/3) [2 d/3, ~ --OO
and so, after substitution and interchanging the a and/3 integration,
(Wu, W v ) A ~ - f o o
~(t)v(s) f oo e 2"~(~-t)z ( f a ~ I$-w(al3) ,2 -da- I d~dsdt.
d s,t=--cx~
----(xD
---0
a
Now observe that for 13 > 0,
i c¢ f (al3) ada - fro ~ f (a') da a' l '
(5.24)
5.1. W A V E L E T A N A L Y S I S
143
if both integrals converge, which is the case if, for example, f ( x ) --. 0 sufficiently rapidly as x ~ 0+ and as x ~ c~. Equality is proved by substituting a ~-- a'/~. For/3 < 0, the substitution a ~- - a " / ~ yields
_ ~o ~ f ( - a " ) ~'a" fro~ f (a~) --da da" a
(5.25)
Therefore, if c~ is finite and nonzero,
e2~i(s-t)Z~t(t)v(s) dsdtd~,
(Wu, Wv) Aft --- -- (X)
--00
-- -- (X)
and the result follows from Corollary 3.12. Any square-integrable function w for which cw is finite and nonzero is called admissible, and the resulting cw is called its normalization constant. Such functions give invertible wavelet transforms: c~ (u, v} - (Wu, WV)A ~ -- (u, W * W v } for all u, v E L2(R), so 1--W*Wv - v and 1--W*W - Id. Thus the inverse wavelet transform is W -1 = 1CwW * where W* is a linear transformation defined for functions on Aft by Czv
Cw
W*z(t) - (ff~ab(t), z(a,
1
b)}Af r
=-~
=o ~ w
(ta
b) z(a, b) dadba2 .
(5.26)
The adjoint wavelet transform W* is derived by changing the order of integration: for any u - u(t),
(Wu(a,b),z(a,b)}A~ -
Wu(a,b)z(a,b) -----oo
-
=
j[b~
~~
[ ~ -~
=o Jt--~
a2
--0
-
= f~
dadb
~1
-oov
~t(t) [ ~ ~
=-~
dadb z(a, b) a 2
(t-b) a
] i ~ ---Fw ( t1a- b ) v =0
z(a, b) dadb] dt -
a
a2 J
(u, W* z).
Since this holds for all u E L2(R), the nondegeneracy of the inner product allows us to identify W*z with the formula inside the last set of square brackets, which is evidently (@ab(t), z(a, b))Aff. T h e o r e m 5.3 ( W a v e l e t I n v e r s i o n ) Suppose that w - w(t) is admissible with
normalization constant Cw ~ O. Then its associated wavelet transform satisfies W " L2(R)---+ L2(Aff), its adjoint satisfies W* • L2(Aff) ~ L2(R), and we have
1.
[ I _ w , W ] u - u, for any function u - u(t) e L 2(R)"
2.
[1--WW*]z - z for any function z - z(a b) E L2(Aff)
Cw
Cw
~
'
"
CHAPTER 5. SCALE AND R E S O L U T I O N
144
Proof." Theorem 5.2 with u = v E L2(R) implies that W u c L2(Aff), with IlWulla < cwllullr. The norms 11-Ila and I1" lit are derived from the inner products in L2(Aff) and L2(R), respectively Thus, fixing z C L2(Aff) and taking any unit vector u C L2(R) gives Il= I<Wu, Z>Afrl ~ IlWulla IlZlla = Cw IlZlla, by the Cauchy-Schwarz inequality in L2(Aff). Taking the supremum over all such unit vectors gives the estimate IIW*zll ___ llzlla, so W * z C L2(R). The inversion results now follow from the discussion preceding Equation 5.26. [] Because the admissibility condition applies to 9rw, wavelets are often defined as inverse Fourier integral transforms of bump functions with simple formulas. For example, we may define w = w(t) by 9 r w ( ~ ) = ¢(1~1), where
¢(~)-
{ e -(l°g~)2, 0,
if ~ > O; if~<0.
(5.27)
Then 9rw is a pair of bumps peaking at frequencies ~ = +1. It is an exercise to show that w = w(t) is a smooth, rapidly decaying function concentrated near t = 0, so that w is localized in both time and frequency. Since w is Hermitean symmetric in frequency, it is real-valued. But also, w is an admissible mother function. The integrands are positive so the admissibility integrals are positive: 0 < ~ o ~ "y'w(~)'2
j[o ~
d~ < oc.
Finiteness follows from the rapid decay of ¢(~) as ~ --+ oc and as ~ ~ 0+. Showing this rapid decay is left as an exercise. The Fourier integral transform of the dilation, )Cw~0, has peaks at ~ = +l/a. The location of these frequency peaks is the same for W~b(t), which is concentrated near t = b. Hence, by Plancherel's theorem, Wu(a, b) = (W~b, u) = (~Wab,~U) is an average of u's frequency components near ~ = + l / a and t = b. Any admissible wavelet must have a power spectrum with energy at both positive and negative frequencies. If we are not interested in an invertible transform, but only wish to identify time-frequency components of a signal, then we can use just one of the two halves of the admissible function above. For example, putting w + d~f ) c - 1 ¢ gives a complex-valued wavelet transform, and if IW+f(a, b)l - I(Wab, + f } l is large, then we may conclude that near time b the signal f has a strong component with frequencies near 1/a.
5.2
Discrete Wavelet Transforms
Whenever ~ is an admissible mother function, the wavelet inversion theorem implies that a function u can be recovered from {Wu(a, b ) : a > O, b C R}, its wavelet transform. But samples of W u at discrete values of (a, b) also determine u, and
5.2. D I S C R E T E W A V E L E T T R A N S F O R M S
145
good approximations to u may be recovered from finite lists of these samples. Furthermore, only certain averages of u are needed to compute the samples of Wu. The relation between discrete averages of u and samples of Wu is called the discrete wavelet transform, or DWT. To get a discrete approximate for u c L2(R), we first fix a scaling function ¢ C L 2 such that B = {¢n(t) = ¢ ( t - n ) : n E Z}, is an orthonormal set. Then
V clef span B, which is called a scale space, has B as an orthonormal Schauder basis, and the following transformation is an orthogonal projection onto V: P " L 2(R) + V;
Pu(t) de__f ~ ((~n, U} (~n(t). nEZ
(5.28)
This is the same formula as Equation 4.22, only V is not necessarily a sampling space since ¢ is not necessarily an interpolating function. The sequence of expansion coefficients, {(¢~, Z}, is the discrete approximation to u. For example, we may approximate u by a discrete sequence of local average values. Let 1 = l ( t ) be the indicator function of the interval [0, 1). P u t ¢~ =
u}:n ~
¢n(t) def l ( t -
n); then ¢~ is the indicator function of the interval [n, n + 1), and it is easy to see that {¢n : n E Z} is an orthonormal set. For any u, the function Pu defined by Equation 4.22 with these ¢'s will be piecewise constant on intervals of the form [n, n + 1), where n is an integer. The constant value on [k, k + 1) is just an average:
J'~+l
Pu(t)-
k
u(t) dt,
if t C [k, k + 1).
The Haar wavelet transform of such a piecewise constant u is given by
Wu(a b) _ / ~ '
l_~¢(t - b)u(t) dt _ l jfb b+~ ~ xffd a -~ u(t) dt
P u t t i n g b - k, an integer, and a -
w (2J, k)
=
1
2J/2
1
~
fb+au(t) dr.
Jb+~
(5.29)
2j for integer j > 0, this evaluates to
[ u ( k ) + . . . + u(k + 2j-1 -- 1)]
1
2J/2 [u(k -~- 2 j - l ) + . . . - [ - u(]¢ -J7 2j - 1)] In particular, x/~Wu(21, O) -- u ( O ) - u(1), v/2 Wu(21, 1) -- u ( 1 ) - u(2), and so on.
5.2.1
Multiresolution analysis (MRA)
If 1 - l ( t ) is the indicator function of [0, 1), then 1(2t) is the indicator function of 1 1). Thus [0, 1) and l ( 2 t - 1) is the indicator function of [3, l ( t ) -- l ( 2 t ) + 1 ( 2 t - 1).
(5.30)
C H A P T E R 5. S C A L E A N D R E S O L U T I O N
146
This is one example of a two-scale relation, because it relates a function to shifts of itself dilated to another scale. Likewise, ¢(t) = 1 ( 2 t ) - 1 ( 2 t - 1),
(5.31)
where ¢ is the Haar mother function defined in Equation 5.2. Replacing t +-- 2 i t - k in Equations 5.30 and 5.31 gives l(2Jt-k) ~(2Jt)
=
l(2J+lt-2k)+l(2J+lt-2k-1),
=
l ( 2 J + l t - 2 k ) - l ( 2 J + l t - 2 k - 1).
Any nonzero 1 function ¢ satisfying an equation of the form ¢(t)-
Eh(k)v/2¢(2t-k)de__f
He(t),
(5.32)
k
for a possibly infinite sequence h = {h(k) : k c Z} of filter coefficients, is said to satisfy a two-scale relation. The sequence 2 h is called a quadrature filter, or simply filter. The factor v ~ is used so that we have unit vectors on both sides: IIv~¢(2t- k)ll = I1¢11-- 1, if ¢ C L2(R) is a unit vector, for all shifts k. It will be assumed that h(k) = 0 for all but finitely many values of k, as in the Haar case where h(0) - ~ , h(1) - ~ , and h(k) - 0 for all k ¢ 0, 1. Such an h is called a finite impulse response, FIR, or simply finite, filter. The finiteness guarantees that H makes sense on any vector space. Substituting t ~ t - n into Equation 5.32, then renumbering k ~ k ' - 2 n , shows that ¢(t - n) -- Z
h(k)v/2 ¢ ( 2 t - 2n - k) - E k
h(k' - 2n)x/~ ¢ ( 2 t - k').
(5.3a)
k'
This means that ¢ ( t - n) is a finite linear combination of functions in { ¢ ( 2 t - k ) : k E Z}. Recall that in Equation 2.19, we called the set of all such finite linear combinations a linear span. We may thus define a sequence of scale subspaces, beginning with the set of finite linear combinations of elements of { ¢ ( t - k ) : k C Z}:
V0 de_.f span { ¢ ( t - k)" k E Z},
(5.34)
This is the subspace of L2(R) of all superpositions }-~-kcZ s ( k ) ¢ ( t - k ) where s(k) - 0 for all but finitely many values of k. Continuing, we define Vj dej span { ¢ ( 2 - J t - k)" k E Z},
(5.35)
the linear span of translates by 2J k of the dilate of ¢ by 2 - j . Functions in V0 are superpositions of unit scale building blocks ¢ ( t - k ) ; functions in Vj are superpositions of building blocks of scale 2J. Note that u(t) belongs to Vj if and only if u(2Jt) belongs to V0; this is a special case of the following lemma: 1The uninteresting example q5 -- 0 obviously satisfies such a relation; t h a t is why it is excluded. 2The linear transformation H determined by the sequence is also called a filter.
5.2. D I S C R E T E W A V E L E T T R A N S F O R M S
147
L e m m a 5.4 For any function u = u(t), u(t) belongs to Vq if and only if u(2Pt) belongs to Vq_p.
Proof:
Writing u(t) = E k s(k)¢( 2-qt - k ) ,
Ek
substitute t ~- 2Pt to get u(2Pt) =
k).
[]
The special case is obtained when p = q = j. Lemma 5.4 and Equation 5.33 imply that the spaces Vj are nested, or ordered by inclusion: L e m m a 5.5 For each j, Vj C Vj-1. That is, if u C Vj, then u c Vj-1.
Proof: First show that Vo C V_ 1. For u(t) = ~ s ( n ) ¢ ( t - n) C Vo, Equation 5.33 implies u(t) - E s ( n ) ¢ ( t - n) - E E s(n)h(k - 2 n ) ¢ ( 2 t - k). n
n
k
Thus u(t) = E k d ( k ) ¢ ( 2 t - k) C V-I, where d(k) = E n s(n)h(k - 2n). Now take any u C Vj. By Lemma 5.4 with p = q = j, u(2Jt) c V0, so u(2Jt) c V-1 by the previous paragraph. Reapplying Lemma 5.4, this time with p = j and q = j - 1, shows that u(t) E Vj_I. [] Iterating Lemma 5.5 gives the inclusion ordering: • "" C V2 C V 1 C
Vo c V - 1 C
V_2 C - - -
L e m m a 5.6 If ( ¢ ( t - k): k e Z} is a basis for Vo, then { ¢ ( 2 J t - k): k e Z} is a basis for Vj. Furthermore, if the first is an orthogonal basis, then so is the second.
Proof: Since Vj - span (¢(2-J t - k): k C Z }, it is only necessary to check for linear independence. But if 0 - u(t) de___fEk 8(k)(/)(2 - j r - k) e Yj, then v(t) de_f u(2Jt) e V0 is also 0, and 0 = v(t) - ~ k s ( k ) ¢ ( t - k) implies that s(k) - 0 for all k e Z, since, by hypothesis, { ¢ ( t - k): k e Z} is a linearly independent set. For orthogonality, we have ( ¢ ( 2 - J t - k), ¢ ( 2 - J t - k')} - 2J ( ¢ ( t - k), ¢ ( t - k')} by the change of variable t ~-- 23t. One inner product is zero if and only if the other is zero, since 2J never vanishes. Thus, if ¢ ( t - k ) is orthogonal to ¢ ( t - k ' ) whenever k' =/: k, the same holds for ¢ ( 2 - J t - k) and ¢ ( 2 - J t - k'). [] Abstracting this construction and adding some properties defines a multiresolution analysis of L2(R), or MRA. This is a chain of subspaces {Vj: j e Z} of L2(R) satisfying the following: MRA Conditions Containment:
Decrease:
Vj c Vj-1 C L 2 for all j E Z;
lim Vj - 0 ; that is, f i Vj - {0} for all N; j---+oc
Increase:
j >N
lim Vj - L 2, that is, U Vj is dense in L 2 for all N;
j~-oc
D i l a t i o n : v(2t) • Vj-1 ~
j
v ( t ) e Vj;
CHAPTER 5. SCALE AND RESOLUTION
148
S c a l i n g F u n c t i o n : There is a function ¢ C V0, integrable and square integrable, having compact support and nonzero integral, whose integer translates { ¢ ( t - k ) : k C Z} form a Schauder basis for V0. Notice that { 2 - J / 2 ¢ ( 2 - J t - k ) : k E Z} will be a Schauder basis for Vj. The scaling function is sometimes called a father function, to emphasize its relation to the mother function of a wavelet basis. If the scaling function generates an orthonormal basis for V0, then we have an orthogonal MRA. In that case, { 2 - J / 2 ¢ ( 2 - J t - k)" k c Z} will be an orthonormal basis for Vj. The factor 2 -j/2 gives the basis functions unit norm. Taking Vj --+ L 2 as j --~ - o c is the "Daubechies" indexing convention for an MRA. In it, the scale or width of the building blocks increases with j. It corresponds directly to the indices computed by the programs in this text. The alternative or "Mallat" indexing convention reverses the sense of scale: Vj ~ L 9 as j ~ +oc. In that convention, the resolution, or narrowness, of a building block in Vj increases with j. The two conventions are equivalent and produce equal sets of coefficients; they differ only in how the coefficients are tagged for subsequent processing. 5.2.2
From
MRAs
to filters
Now suppose that we have an orthogonal MRA with a scaling function ¢, which we will insist has compact support, giving an orthonormal Schauder basis B0 = { ¢ ( t k) : k c Z} for V0 = span B0. The containment condition V0 C V-1 implies that ¢ may be expanded in the orthonormal Schauder basis B - 1 = { v / 2 ¢ ( 2 t - k ) : k E Z} of V-1 -- spanB_l. Writing the expansion coefficients h(k) - (v/-2¢(2t- k), ¢(t)}, we see that ¢ must satisfy a two-scale relation: ¢(t) - y ~ h ( k ) v ~ ¢ ( 2 t - k) - He(t).
(5.36)
k
This defines a filter sequence h and transformation H. The compact support of ¢ implies that h(k) = 0 for all sufficiently large Ikl, so h will be an FIR filter. Coming from an orthogonal MRA, this filter satisfies some special properties. First, orthonormality of the set B0 C L2(R) implies that, for n ¢ 0,
l
=
k
~ Z h(l)h(k)5(2~ + k - l ) - ~ h(2~ + k)h(k), l
k
k
and
1
-
(¢(t), ¢(t)) l
=
k
~ Z h(1)h(k)5(k - l ) - ~ Ih(k)l~ l
k
k
5.2. D I S C R E T E W A V E L E T T R A N S F O R M S
149
Here 5 is the Kronecker symbol of Equation 2.31" 5(n)
de__f
~ 1, ( 0,
if n -- 0; otherwise.
Thus, the filter h determined by an MRA satisfies the self-orthonormality condition E Ih(k)12 - 1; E h(k)h(k + 2n) - O, if n 7~ O. (5.37) k
k
If h is real valued, the complex conjugation is unnecessary. Second, since ¢ is integrable, Equation 5.36 can be integrated as follows:
¢(t) dt - v ~ ~ h(k) ¢(2t - k)dt - ~ ~ h(k) ¢(t) dr, k
(5.3s)
k
where the substitutions t ~-- (t+ k)/2 have been performed o n t h e middle. Dividing by the nonzero f ¢(t)dt shows that
(5.39)
E h(k) - x/2. k
More is true: since 2 - I E k h(k)[ 2 - E k E n h(k)h(n), we can substitute n ~ k + n and then divide into even n and odd n to have
n
k
n
k
The first sum is 1 by Equation 5.37, leaving -
EEh(k)h(kq-2n+l) n
=
-
Eh---~Eh(k+2n+l)
k
k
(k~h(2k))(
n~h(2n+
1))+
n
(k~h(2k+
1))(n~h(2n)),
after splitting the k-sum into even and odd k, and substituting k ~ 2k, n ~ n - k in the even-k part, and k ~ 2k + 1, n ~-- n - k - 1 in the odd-k part. Writing E - E k h(2k) and O - Y~'-kh(2k), this means 1 - E O + E O . But since E + O - x/~ by Equation 5.39, IE - OI 2 - ] E
+ OI 2 - 2 ( / ~ O + E 0 )
- 2 - 2 - 0,
so E - O - 1/x/~. This is the low-pass filter condition:
1 (~ ~
E h(2k)- Z h(2k + 1 ) - v~ k
k
k
h(k)- v~
)
(5.40)
CHAPTER 5. SCALE AND RESOLUTION
150
Third, we observe that another filter with similar orthogonality properties can be defined from h:
g(k) - ( - 1 ) k h ( 1 - k),
for all k C Z.
(5.41)
Clearly, g will be finite whenever h is finite, and given g we may determine h by the similar formula h(k) = (--1)l-kg(1 -- k). This and Equation 5.40 implies the high-pass filter condition for g:
Ekg ( 2 k ) - - Ekg ( 2 k + l) - V~ 1
( ~ E g ( k ) - 0) .
(5.42)
k
Fourth, there is a self-orthonormality condition for g:
E g(k)g(k + 2n)
-
k
k)(-1)k+2~h(1- k - 2n)
E(--1)kh(1k
=
Eh(1-k)h(X-k-2n) k
=
Eh(k)h(k-2n)
-
5(n).
(5.43)
k
Fifth, for any integer n, the following independence condition holds between the two filters h and g:
E g ( k ) h ( k + 2n)
-
E(-1)kh(1-
k
k)h(k + 2n)
(5.44)
k
=
E
h(1 - k)h(k + 2 n ) -
even k
=
E
h(1 - k)h(k + 2n)
odd k
E h(2p+l)h(2n-2p) - E h ( 2 n - 2 q ) h ( 2 q + l ) p
- O.
q
Here k ~- -2/) in the first sum and k ~ 2q + 1 - 2n in the second. Finally, the filter pair h, g satisfies the completeness condition:
E h ( n - 2k)h(m - 2k) + g(n - 2k)g(m - 2k) - 5 ( n - m).
(5.45)
k
This can be shown case-by-case. We first write g in terms of h, making the sum
E h(2k + n)h(2k + m) + ( - 1 ) ~+m E h(2k + 1 - n)h(2k + 1 - m). k
k
Then we put p = m - n the cases:
to have n + m = 2n + p and ( - 1 ) n + m = ( _ 1)p, and consider
• If n = 2n t is even, then substituting k ~- k - n t in the first sum and k +-- k + n ~ in the second reduces them to
E h(2k)h(2k + p) + ( - 1 ) p E h(2k + 1)h(2k + 1 - p). k
k
5.2. DISCRETE WAVELET TRANSFORMS -
If p -
151
2p ~ is even, t h e n s u b s t i t u t i n g k ~-- k + p~ in the second s u m gives
E h(2k)h(2k+p) + E h(2k+l+p)h(2k + 1) k
-
E
k
h(k)h(k+p)
k
= Z h(k)h(k + 2p')
-
~(p') -
~(~-.~).
k
-
If p = 2p ~ + 1 is odd, t h e n s u b s t i t u t i n g k ~-- k + p~ in the second s u m gives
h(2k)h(2k + p) - ~ k
h(2k + p)h(2k) - 0. k
This agrees with the value of 5 ( n - m), which is 0 in this case since p = m - n being odd m e a n s n ¢ m . • If n = 2n ~ + 1 is odd, t h e n s u b s t i t u t i n g k ~ k +-- k + n ~ in the second reduces t h e m to
E h(2k + 1)h(2k
h(2k)h(2k - p).
+ 1 + p) + ( - 1 ) p E
k
-
k - n ~ in the first sum and
k
If p = 2p ~ is even, t h e n s u b s t i t u t i n g k ~-- k ÷ p~ in the second s u m gives
h(2k+~)h(2k+l+p) + Z h(2k + p)h(2k) k
-
~
k
h(k)h(k + p) k
= ~
h(k)h(k + 2;')
-
~(;') -
~(~-.~).
k
- If p = 2p ~ - 1 is odd, t h e n s u b s t i t u t i n g k +-- k + p~ in the second s u m gives
E h(2k + 1)h(2k + 1 + p) - E h(2k + p + 1)h(2k k
+ 1) - 0.
k
This agrees with the value of 5 ( n p = m - n being odd m e a n s n ¢ rn.
m),
which is 0 in this case since
T h e sequences h and g derived from the M R A are called orthogonal conjugate orthogonal CQFs. We m a y a b s t r a c t the properties just deduced from the M R A conditions:
quadrature filters, or
Orthogonal
CQF
Conditions
(Basic)
Sequence h - { h ( k ) : k E Z} consists of zeroes for all but finitely m a n y values of k.
Finiteness:
Normalization
o f h: }--~kh(2k) = E k
h(2k +
1) = l/v/-2, and thus
E k h(k) - v@ Self-Orthonormality every n, m c Z.
o f h: }-~-kh(k
+ 2n)h(k + 2m)
=
5 ( n - m),
for
CHAPTER 5. SCALE AND RESOLUTION
152
From these stand-alone assumptions, the other properties of h and g can be deduced:
Orthogonal CQF Conditions (Derived) C o n j u g a c y : There is a fixed integer M, and g(k) = ( - 1 ) k h ( 2 M + l - k ) , for k C Z, defines another (finitely-supported) sequence g = {g(k) :
kez}. Normalization of g: ~-~-kg(2k) - -~-~k g(2k + 1) -- 1/x/~, and thus
Ek g(k)=0. Self-Orthonormality of g: ~-~kg(k + 2n)g(k + 2m) = 5(n - m). Independence: ~ k g(k + 2n)h(k + 2m) = 0 for any n, m e Z. Completeness: ~-~kh(2k + n)h(2k + m ) + ~-'~kg(2k + n)g(2k + m) =
5(n- m). The so-called lazy filters, h(k) - v / 2 5 ( k - 1) and g(k) - x/~5(k) satisfy the finiteness, conjugacy, self-orthonormality, independence and completeness conditions, but only part of the normalization conditions. This partial example is a useful test case for some constructions. To be definite, suppose that for some fixed L > 0, h(k) - 0 if k < 0 or k _> L; this may be called conventional indexing. Then the length of the finite support of h is no more than L. If it is exactly L, namely if h(0) ~ 0 and h ( L - 1) ~ 0, then h is said to have filter length L. The normalization condition implies that filter length L>2. L e m m a 5.7 An orthogonal conjugate quadrature filter's length must be even.
Proof: It is enough to prove this for the low-pass filter h, since the high-pass conjugate filter g will have the same length L as h. If L - 21 + 1 for 1 > 0, then L - 1 - 21 is the largest index k for which h(k) ~ 0, so
0 -- E h(k)h(k + 2 l ) - h(O)h(21)- h(O)h(L- 1). k
Thus either h(O) - 0 or h ( L length L.
1) - O, contradicting the assumption that h has [2
Constructing orthogonal filter pairs How can we construct a finite sequence h -- {h(k) : k C Z} satisfying the orthogonal CQF conditions? One solution can be found right away, the Haar filter, which is the unique orthogonal CQF of length two:
~1 h(k)-
~22' i f k - 0 o r k - 1 , O, i f k ¢ { O , 1};
g(k)-
if k-0, v~'
O,
if k - l , i f k ~ { O , 1}.
(5.46)
5.2. DISCRETE WAVELET TRANSFORMS
153
Filters of length four are not unique. Let h be an orthogonal CQF with nonzero coefficients h(0), h(1), h(2), and h(3). Then h must satisfy the norm condition h2(0) + h2(1)+ h2(2)+ h2(3) = 1, plus the following constraints: h(0) + h(2)
1 x/2;
-
1 h(1) + h(3) - x/2;
h(0)h(2) + h(1)h(3) - 0.
(5.47)
By the first two conditions, picking h(0) and h(1) determines h(2) - ~22- h(0) and h(1). The third condition holds if and only if there is some constant h(3)- 1 c for which h(2) = ch(1) and h(3) = -ch(O). The result is a system of two linear equations for h(0) and h(1), containing a free parameter c:
h(O) + ch(1) -ch(O)+h(1)
=
v/5 1 v~
=:~
()() 1 -c
c 1
h(0) h(1)
()
1
1 1
~
"
The matrix is nonsingular for every real c since its determinant, 1 + c 2, is at least one, and the one-parameter set of solutions is obtainable by inverting: (h(0)}_ h(1)
1 (1 v/~(1 + c 2) c
h(0)
-c)(1) 1 1
--
:a
1-c
V/2(1-}-c2) 1+c
h(1)--
(5.48)
v/~(x_t_c2 )
The remaining coefficients are then h(2) _ v~Ti%c -2)c(c+1) and h ( 3 ) - v~(l+c2)'c(c-1) The Daubechies ~ filters are obtained this way using c = 2 - x/3: 3+x/~
l+x/~ 4v/2 '
3-~/3
4~/~ '
4V~ '
h(3)-
1-x/~ 4v/2
.
(5.49)
The normalization condition for 5.47 seems to impose an additional constraint on c. However, that condition is satisfied for all real c:
h2(O)+h2(1)+h2(2)+h2(3)
=
(1 + c2)(h2(0) + hS(1))
= (1+c2)( 1-2c+c2 1 +2c+c2) 2 ( 1 + c 2 i -~ + 2 ( 1 + c 2 ) 2
-- 1.
If all four coefficients are nonzero, then c ~ {0, i l , icx~}. Otherwise, the degenerate cases are c---1
=~
h-{~,0,0,~};
c-0
=a
h-{~,~,0,0};
c-1
=a
h-{0,~,~,0};
c-+oo
=~
h-{0,0,~,~}.
These are all just variations on the Haar filters. M o t h e r f u n c t i o n s and details
The conjugate filter g derived from h defines the mother function for the MRA by way of a linear transformation G:
~(t) - E g(k)x/2 ¢(2t - k) dS G¢(t). k
(5.50)
CHAPTER 5. SCALE AND RESOLUTION
154
Thus ~b(t-k) E V - 1 for every integer k. In fact, {~b(t-k) • k c Z} is an orthonormal subset of V_I"
( ¢ ( t - ~), ¢ ( t - .~)) l
= ~
k
~ 9(1)9(k)~(2~ + l 1
2~ - k)
k
= Z9(2(.~-
~ ) + k)g(k)
~ ( ~ - .~).
-
k
This mother function defines another collection of subspaces in the MRA. Put Wo = span {~b(t- k) : k E Z}, and observe that Wo c V-1. In general, for any integer j, put
Wj
de f span { ~ b ( 2 - J t - k)" k E Z}.
(5.51)
Then Wj c Vj-1. Note that {2-J/2~p(2-Jt- k) : k c Z} is an orthonormal basis for Wj. By the independence condition, every basis vector of Wo is orthogonal to every basis vector of Vo:
( ¢ ( t - ~). ¢ ( t - .~)) = 1
= ~
k
~ l
= ~
g(l)h(k)~(2~ + l -
2.~ - k)
k
g ( 2 ( ~ - .~) + k)h(k)
-
0.
k
Also, since (~p(t- n), ¢ ( t - m)} - 29 (~(2Jt- n), ¢ ( 2 J t - m)} for every j c Z, every basis vector of Wj is orthogonal to every basis vector of Vj. In other words,
w~ ± v~. Multiresolution analysis works because f c V-1 is the sum of an average part that lies in V0 and a complementary detail part that lies in Wo:
L e m m a 5.8 W0 + V0 - V_ 1.
"Proof: We first show that each basis function of V_ 1 is a sum of a function in Vo and a function in W0, namely, that x / 2 ¢ ( 2 t - n) - Z
h ( n - 2k)¢(t - k) + 9 ( n - 2k)¢(t - k).
(5.52)
k
Using the two-scale relations for the scaling and mother functions, we may expand the ¢ and ~b terms. Then we use Equation 5.45, the completeness condition, to
5.2. DISCRETE WAVELET TRANSFORMS
155
evaluate the sum over index k as follows:
E h(n - 2k)¢(t - k) + g(n - 2k)¢(t - k) k
k
m
+ g ( n - 2k)9(m)x/2¢(2t- 2k - m) - ~
(E
h(n-2k)h(m-2k) +g(n-2k)g(m-2k))v/2¢(2t-m) k
= E 5(n - m)x/~¢(2t - m)
-- x / ~ ¢ ( 2 t - n).
m
u(t) - ~ k c ( k ) v ~ ¢ ( 2 t - k) E V-l, there is a function Pou(t) def ~ k s ( k ) ¢ ( t - k) E Vo, where s(k) - ( ¢ ( t - k), u(t)), and a function Thus, for any u -
Qo~(t) d~_f E k d(k)+(t - k) ~ Wo, wh~r~ d(k) - ( + ( t - k), ~(t)>, ~nd si~c~ ~(~) Ek h(n - 2k)s(k) + E k g(n - 2k)d(k), it follows that u = Pou + Qou. [] This decomposition generalizes to arbitrary scales in the MRA. For fixed j E Z, define the functions Cjk(t)
de=_f 2-J/2¢(2-Jt- k),
k e Z, t e R
(5.53)
¢jk(t)
d~=f 2 - J / 2 ¢ ( 2 - J t - k),
k e Z, t e R
(5.54)
These are orthonormal basis vectors for Vj and Wj, respectively.
Coronary 5.9 Po~ ~ W
~ t ~ g ~ j, W~ + V~ - V~_~.
Proof: We substitute t +- 2-Jt and multiply by 2-J/2 everywhere in Equation 5.52 in the proof of Lemma 5.8, then apply the definitions of Cjk and ¢jk to get Cj-l,~(t) -- ~
h(n - 2k) ¢jk(t) + g(n - 2k)~j~(t).
(5.55)
k
We have thus written an arbitrary basis function of Vj-1 as a linear combination of basis functions of Vj and % . [] The subspaces Wj are the differences between the adjacent Vj and Vj-1. Knowing the expansion coefficients of u's approximation in Vj, it is only necessary to get the expansion coefficients of its projection on Wj (and to do some arithmetic) in order to get a better approximation of u in Vj-1. We may call Wj a detail space, since it contains the details from u's approximation in Vj-1 which are missing in Vj. Repeated application of this splitting yields the discrete wavelet decomposition: C o r o l l a r y 5.10 V0 = W1 + W2 + - . - +
Wj + Vj, for any integer J > O.
[]
If the scale and detail spaces form an orthogonal MRA, then the subspaces in the sum are pairwise orthogonal.
CHAPTER 5. SCALE AND R E S O L U T I O N
156 P , ,
•
go
P2 1
,~~
V1
P p~. -
w1
V2
,
,
,
V j_ 1
j , ~~
w2
Vj
,
,
,
wj
Figure 5.4: Pyramid of projections onto subspaces in the MRA.
5.2.3
F r o m filters to d i s c r e t e w a v e l e t t r a n s f o r m s
Once an orthogonal MRA has been fixed, a function u may be approximated to any desired degree in one of the scale spaces, {Vj : j E Z}, using the scaling function ¢. We define a linear transformation Pj that produces the approximation by the following formula: Pju(t) - E (¢jk, u) Cjk(t), (5.56) k
where Cjk(t) - 2 - J / 2 ¢ ( 2 - J t - k), as defined in Equation 5.53. If u - u(t) has compact support, then the coefficient sj(k) dJ (¢jk, u} is nonzero for only finitely many values of k, so Pju c Vj. Furthermore, Pj(Pju) = Pju, and u - Pju is orthogonal to Pju, so Pj is the orthogonal projection onto Vj. The finitely-supported sequence of coefficients {s0 (k) : k E Z}, in particular, contains enough information to recover the approximation Pou E Vo of u. For integer J > 0, the sequence {sj(k) : k E Z} contains the smaller amount of information needed to recover the cruder approximation Pju c Vj. Likewise, the orthogonal projection Qj onto Wj is defined by
Qju(t) - E
(¢jk, u)Cjk(t),
(5.57)
k
where ¢ is the mother function of the orthogonal MRA, and ¢jk(t) is defined in Equation 5.54. Again, coefficient dj(k) def (¢jk, u) will be nonzero for only finitely many values of k, whenever u has compact support. The finitely-supported sequences {dx(k): k C Z}, {d2(k) : k E Z } , . . . , { d j ( k ) : k E Z}, contain the information from which we may recover the details in spaces W1, W2,..., Wj. This decomposition, Vo
=
w~ + w 2 + . . . + w j + v j ;
I Pou
=
Qlu + Q2u + . . . + Q j u + Pju,
is depicted in Figure 5.4. The orthogonal CQF properties imply that
k
k
5.2.
DISCRETE
WAVELET
po u ~
So
H
d1
157
TRANSFORMS
~..
s1
H
~~
$2
" " "
H
Sj-1
d2
~
sj
dj
Figure 5.5: The pyramid algorithm for the discrete wavelet transform (DWT).
SO
S1
d1
Figure 5.6: (iDWT).
--
S2
o . .
S j_ 1
d2
Sj
dj
The pyramid algorithm for the inverse discrete wavelet transform
dj+ 1 (n)
-
E
g(k)sj(2n
-[- k )
-
k 8j-1 (n)
-
E
g(k -
2n)sj (k);
(5.59)
k +
(5.60)
k Equations 5.58 and 5.59 provide a recursive algorithm, the Mallat p y r a m i d algorithm depicted in Figure 5.5, for computing expansions in any of the subspaces of the MRA. The finitely-supported sequence so = {s0(k) : k E Z}, defined by so(k) = ( ¢ ( t - k), u(t)}, completely determines the approximation Pou C Vo. The wavelet expansion of Pou to level J > 0 consists of the sequences (dl , d2, . . . , d j; s j). Sequence 8 j determines the crude approximation P j u E Vj, while d j, d j - l , and so on contain extra information needed to refine it successively into the better approximation Pou E 17o. Reconstruction from the wavelet expansion is done by a similar pyramid algorithm, depicted in Figure 5.6. The arrows are reversed using adjoints, and the results are summed according to Equation 5.60. In both pyramid algorithms, sequences s l, s 2 , . . . , 8J-1 are computed along the way, even though they are not part of the discrete wavelet expansion or the reconstructed signal. Enough temporary storage to hold another copy of the signal may therefore be needed, depending upon how the arrow operations are implemented.
Filter transforms A finitely-supported sequence f = { f ( k ) : k e Z} defines a filter transform, acting on arbitrary sequences u = {u(k) : k c Z} by either of the two equivalent formulas,
158
C H A P T E R 5. S C A L E A N D R E S O L U T I O N
related by the substitution k ~-- k z + 2n: ru(n) - ~
f(k-
2n)u(k) - ~
k
f ( k ' ) u ( k ' + 2n),
n C Z.
(5.61)
k'
This F is a linear t r a n s f o r m a t i o n on every vector space of complex-valued sequences, including the inner product space g2 of square-summable sequences with inner p r o d u c t (u, v} - }--~ku ( k ) v ( k ) . In t h a t space, F has an adjoint F* t h a t satisfies {Fu, v) - (u, F ' v } for all u and v. But then,
n
def E k
~t(k)F*v(k,),
which defines two equivalent formulas for the adjoint filter transform:
(5.62)
F*v(k) n
~ __
k
f(2~,)v(~ - ~,),
if k E Z is even,
n !
f(2~"+~)~( k - 1 _ 2
nII),
ifkcZisodd.
These are related by the substitutions n ~-- 5k _ n' if k is even, and n 4-- -k ---2 1 if k is odd. Composing F and its adjoint gives
F*Fu(j) - E f(2n - j)Fu(n) - E / ( 2 n n
-
j ) f ( 2 n - k)u(k).
~I b t t
(5.63)
n,k
Similarly, FF*u(m) - E
f (2m - k)F*u(k) - E f (2m - k) f (2n - k)u(n).
k
(5.64)
k,n
Because of the dilation by 2, F typically shrinks the support of sequences, while F * enlarges it" L e m m a 5.11 Suppose that the sequence f is supported on the index interval [a, b]" f - { . . . , 0 , f ( a ) , f ( a + 1 ) , . . . , f ( b - 1 ) , f ( b ) , 0 , . . . } , since f ( n ) - 0 if n < a or n > b. For any sequence u supported on [x, y],
• F * u is supported on [2x + a, 2y + b].
5.2. DISCRETE WAVELET TRANSFORMS
159
Proof." Taking into account the support, the second version of the filter transform formula reduces to b
Fu(n) - ~
f(k')u(k' + 2n).
(5.65)
k~=a
Notice that the s u m m a n d will be zero if b + 2n < x or a + 2n > y. Only output values at indices n e [x',y'] need to be computed, where x' - I ( x - b)/e~ and y' -
L(y -
a)/2J.
On the other hand, the first version of the adjoint filter transform formula reduces to Y
F*v(k) - y ~ f(k - 2n)v(n).
(5.66)
T~-- X
The summand will be zero unless a < k - 2n _< b and x < n < y. Hence, output values need only be computed at indices k E [x",y"], where x" - 2x + a and y" - 2y + b. [] Lemma 5.11 illuminates two kinds of spreading in support that occur with filter transforms. Firstly, if F is one filter from an orthogonal CQF pair, then F*F is an orthogonal projection on g2, but the support of F*Fu may be greater than that of u. If u is finitely-supported on the index interval [x, y], and f is supported on [a, b], then F*Fu will be finitely supported in the index interval [2 [~-~1 + a, 2 [~-~-2~J + b]. This contains Ix - ( b - a - 1), y + (b - a - 1)], which in turn contains [x, y] and is strictly larger if and only if b - a > 1. The only orthogonal CQF with b - a _< 1 is the Haar pair, with a - 0, b - 1 in the conventional indexing giving b - a - 1. Secondly, a CQF pair H, G of filter transforms can produce more total output values than there are input values. Suppose the supports are [a, b] for H and [c, d] for G. For a finitely supported sequence u - { u ( x ) , . . . , u(y)} of length N - 1 + y - x, the high-pass and low-pass parts of the signal will be supported on the intervals [[~_~], [~_9_J] and [ [ ~ A ] , ~ _ ~ J ] , respectively, with total length
(1+ lY-2aJ-Ix2bl)+(l+lY2CJ-Ix-2d]).
(5.67)
The total support length will be greater than 1 + y - x if and only if b - a > 1 or d - c > 1. The Haar CQF pair has b - a - 1 and d - c 1, and is the only filter pair that does not cause spreading of the support. Successive applications of H and G give the (nonperiodic) discrete orthogonal wavelet transform on finitely-supported infinite sequences. There are only finitely many finitely-supported sequences dl, d2,..., d j, and sj to compute, and each output coefficient costs only a finite number of operations since h, g are both finite sequences, say of length L. Since L must be even by Lemma 5.7, we can write L - 2 M for an integer M. If h is conventionally indexed, so that h(k) is nonzero only for 0 _< k < L, then we may choose 3 to define g(k) - ( - 1 ) k h ( 2 M - k - 1) to insure that g(k) is also nonzero only for 0 _< k < L. 3Work Exercise 12 to see why!
CHAPTER 5. SCALE AND RESOLUTION
160
W i t h these indexing conventions, if sj(k) is supported in x _< k _< y, then dj+l(n) and Sj+l(n) may be nonzero for [(1 + x - L)/2] _< n < [y/2J. Hence, the output sequences are of varying lengths: Mallat's Discrete Wavelet Transform dwt( u [ ] , x, y, J, h [ ] , g [ ] , L )" If J=O then for n = x to y, [0] [1] Else do [2] to [9] [2] Let xl = ceiling((l+x-L)/2), For n=xl to yl, do [4] to [3] [4] Let s[n] = O, let din] For k=O to L-I, do [6] [5] Accumulate s [n] += [6] [7] Accumulate d [n] += [8] Print d In] [9] Compute dwt( s[], xl, yl,
print
u[n]
let yl = floor(y/2) [8] = 0 to [7] h [k] ,u [k+2,n] g [k] ,u [k+2,n] J-l,
hi],
g[],
L )
Of course, values d In] do not have to be printed as soon as they are computed, they may be stored in an array. For fixed L and J, this array will require O(N) total elements, and will cost O(N) operations to fill. P e r i o d i c filter t r a n s f o r m s
f2q is a 2q-periodic sequence with even period, then it can be used to define a periodic filter transform F2q from 2q-periodic to q-periodic sequences, and a periodic adjoint F~q from q-periodic to 2q-periodic sequences. These are, respectively, the If
transformations 2q--1
r2qu(n) - E
2q--1
f2q(k- 2 n ) u ( k ) - E
k=0
f2q(kZ)u(k' + 2n),
0_~i
(5.68)
kI=0
and
-
q--1 E )~q (k--2/t)V(n) n-0 q-i _ k
(5.69)
if k C [0, 2q-2] is even,
. 10
-
(5.70) k-1
-n"),
if k C [1, 2 q - l ] is odd.
ntt---O
We have performed the same substitutions as in Equations 5.61 and 5.62. Except for the index ranges, the formulas are the same. Periodization commutes with filter transforms: we get the same periodic sequence whether we first filter an infinite sequence and then periodizes the result,
5.2. DISCRETE WAVELET TRANSFORMS
161
or first periodize both the sequence and the filter and then perform a periodic filter transform. To be precise: (FU)q -- F2qU2q and (F'v)2 q - F~*qVq.
L e m m a 5.12
Proof." Note that oo
(Fu)q (n) -
oo
E
Fu(n+qj) -
j=--c~
=
Z
f(k-2n-2qj) j=-c~
2q-1
f(k-2[n+qjl)u(k)
)
u(k)-
E
f2q(k-2n)u(k)
k=-c~
c<)
E
E
kl--0
f2q(kl nt- 2 q k 2
- 2n)U(kl
+ 2qk2)
k2 =--(:x:)
2q--1
-
E
j=-ook=-~
k=-c~ --
oo
E
~
c<)
f~(kl - 2n) ~
kl--0
~(kl + 2qk~)
k2-----c~
2q--1
=
~
f~(kl - 2~)~(kl).
kl--O
Also, (:x:)
(F*v)2~ (k) --
(:x:)
E j=--c~
=
-
F_,
E
E
f([k + 2qj] - 2n)v(n)
j=--c<)n=-c<)
f(k+2qj-2~)
n----c<) q--1
(x)
F*v(k + 2qj) -- E
j----cx~
)
~(~)-
}~ f~(k-2~)~(n) n=--c<)
oo
E
f2q(k -- 2nl -- 2qn2)v(nl Jr-qn2)
h i - - - 0 n 2 ----- (x)
q--1
E hi--0
c<)
f2q(k-2nl)
E
v(nl--t-qn2)
n2----o()
q--1
E
f 2 q ( k - 2nl)Vq(nl).
nl----O
Thus, any redundancy introduced by periodizing an even-length input signal can be removed by ignoring all but one period of the output. A 2q-periodized pair of orthogonal CQFs h, g retain their orthogonal CQF properties. A 2q-periodic input sequence u may be completely described by 2q coefficients, and H2q and G2q each produce q-periodic outputs that are completely
CHAPTER 5. SCALE AND RESOLUTION
162
described by q coefficients each. It is efficient to combine the two periodic filter transforms as follows: C o m b i n e d P e r i o d i c F i l t e r T r a n s f o r m on 2q S a m p l e s p c q f i l t e r ( out [], i n [ ] , q, h [ ] , g [ ] , L ) : [0] For n=0 t o q - l , do [1] t o [4] [1] Let oUr[hi = 0, l e t out[n+q] = 0 [2] For k=0 t o L - l , do [3] t o [4] [3] Accumulate out [n] += h [k] *in [ (k+2*n) %(2*q) ] [4] Accumulate out[n+q] += g [ k ] * i n [ ( k + 2 * n ) % ( 2 * q ) ] Both the input array in [] and the output array out [] must have 2q elements. The H output sequence s ( 0 ) , . . . , s ( q - 1) gets written into the first q elements of out [], namely o u t [ 0 ] , . . . ,out [ q - l ] , and the G output sequence d ( 0 ) , . . . , d ( q - 1) gets written into out [q] ,... ,out [ 2 * q - l ] . The index expression (k+2*n) %(2*q) gives a remainder in the range 0 , . . . , 2 q - 1 for all values of k + 2n, as all its arguments are nonnegative. Since applying a pair of CQFs together yields enough information to recover the original samples, the combined filter transform is invertible. With the arrangement of the s, d sequences produced by p c q f i l t e r (), we may recover the original samples as follows: I n v e r s e of t h e C o m b i n e d P e r i o d i c F i l t e r T r a n s f o r m o n 2q S a m p l e s i p c q f i l t e r ( out [], i n [ ] , [0] For k2=0 t o q - l , do [1] Let o u t [ 2 , k 2 ] = 0, For n2=0 t o L / 2 - 1 , [2] Sum out[2*k2] [3] Sum out[2*k2] [3+] Sum out[2*k2+l] [4] Sum out[2*k2+l] [4+]
q, h i ] , g [ ] , L ) : [1] to [4+] l e t out[2*k2+l] = 0 do [3] t o [4+] += h [ 2 , n 2 ] * i n [ ( k 2 - n 2 ) mod q] += g [ 2 , n 2 ] , i n [ ( ( k 2 - n 2 ) mod q) + q] += h [ 2 , n 2 + l ] * i n [ ( k 2 - n 2 ) mod q] += g [ 2 , n 2 + l ] , i n [ ( ( k 2 - n 2 ) mod q) + q]
Since the arguments can be negative, the index expressions (k2-n2) mod q and (l+k2-n2) mod q must be implemented carefully to insure that they take values in the range [0, q - 1]. The Standard C remainder operator can be used, if qL is added to each left-hand side to guarantee nonnegativity: (k2-n2) mod q
+--
(q,L+k2-n2)Zq
(l+k2-n2) mod q
+--
(q,L+l+k2-n2)Zq
Combined periodic filter transforms are size preserving, in that they produce as many output coefficients as input coefficients. Applying them recursively yields another kind of discrete wavelet transform. For N = 2 J K with integer K and J > 0, output sequences sj and dj will both be periodic of period N/2J - 2J-JK, which is an integer if j <_ J. The total number of output wavelet expansion coefficients in the sequences (dl,d2,... ,d j; s j) will equal the number of input coefficients, since
5.2. DISCRETE WAVELET TRANSFORMS
163
Mallat's Periodic Wavelet Transform
pdwt( u[], N, J, h[], g[], L ): [0] If J>O, then do [l] to [4] [i] Allocate temp [0] =0,... ,temp [N-I] =0 [2] Compute pcqfilter( temp[], u[], N/2, h[], g[], L) [3] For i=O to N-I, copy u[i] = temp[i] [4] Compute pdwt( u[], N/2, J-l, h[], g[], L ) Each output value dj(n) costs LN/2 j-1 multiply-adds to compute, plus there are another LN/2 j-1 multiply-adds needed to compute sj(n). The total cost is 2LN, or O(N) as N --~ co, and is gotten by summing over j = 1, 2 , . . . , J. An important special case is the periodic discrete orthogonal wavelet transform on N = 2 J points, with complete expansion to the maximum depth J. The number of output coefficients equals the number of input coefficients, so the output can overwrite the input: C o m p l e t e P e r i o d i c W a v e l e t T r a n s f o r m o n 2J S a m p l e s
pdwtO( [0] If [i-] [i] [2] [3] [4]
u[], J, h[], g[], L ): J>O, then do [i-] to [4] Let N = l<<J Allocate temp [0] =0 .... ,temp [N-I] =0 Compute pcqfilter( temp[], u[], N/2, h[], g[], L ) For i=O to N-I, copy u[i] = temp[i] Compute pdwtO( u[], J-l, h[], g[], L )
Sequences 8 j and dj are each 1-periodic and representable by a single coefficient, which is in u[0] and u[1] of the output, respectively. The remaining sequences d j - i , . . . , d2, dl are of lengths 2 1 , . . . , 2 J-2, 2 J - l , respectively, and are found at consecutive indices starting with u[2]. It is straightforward to check that the original 2 a locations in u I] exactly suffice to hold everything. Along the way, an additional 2 J temporary memory locations are used. Given wavelet expansion coefficients produced by pdwt0(), we can reconstruct the original signal samples as follows: R e c o n s t r u c t i o n f r o m P e r i o d i c W a v e l e t E x p a n s i o n o n 2J S a m p l e s
ipdwtO( u [ ] , J, h [ ] , g [ ] , L ): [0] I f J>0, t h e n do [1-] t o [4] [1-] Let N = l<<J [1] Compute ipdwt0( u [ ] , J - l , h [ ] , g [ ] , L ) [2] A l l o c a t e temp [0] = 0 , . . . , temp [N-i] =0 [3] Compute i p c q f i l t e r ( t e m p [ ] , u [ ] , N/2, h [ ] , [4] For i=0 to N-I, l e t u [ i ] = temp[i]
g[],
L )
C H A P T E R 5. SCALE A N D R E S O L U T I O N
164
Output is written over the input array u [], as the inverse transform is size preserving. We now use induction on J to prove that pdwt0(u[] , J , h [ ] ,g[] ,L) is inverted by ipd~rt0 (u [] , J , h [ ] ,g[] ,L), for any orthogonal CQFs h,g. For J - 0, both p d u t 0 ( u [ ] , 0 , h [ ] ,g[] ,a) and i p d u t 0 ( u [ ] , 0 , h [ ] ,g[] ,a) are the identity on one-point signals u, and are thus trivially inverses. For J > 0, suppose that i p d u t 0 ( . , J - l , . . . ) inverts pdut0 ( . , J - l , . . . ) on all signals of length 2 J-1. Given a signal {u(k) • 0 _ k < 2 J} of length 2 J, consider p d u t 0 ( u [ ] , J , h [ ] ,g[] ,L). This consists of p c q f i l t e r ( ) applied to u, followed by p d u t 0 ( u [ ] , J - l , h [ ] ,g[] ,L)) which acts just on the first-half elements {u(k) • 0 <_ k < 2J-1}. By the inductive hypothesis, that is inverted by i p d u t 0 ( u [ ] , J - l , h [ ] ,g[] ,L), which recovers the first-half elements, followed by i p c q f i l t e r ( ) which combines those with {u(k) • 2 J-1 _~ k < 2 J} to recover the rest of u. After implementation, it is a good idea to perform some tests with random sequences to see whether i p d u t 0 ( ) and p d u t 0 ( ) are inverses. The reconstructed samples will contain roundoff errors from the finite-precision arithmetic, but with orthogonal length-L CQFs the relative error should be about 2cf J v/L. B u i l d i n g m u l t i r e s o l u t i o n s f r o m filters Does choosing any h satisfying the stand-alone, or basic, orthogonal filter conditions on page 151 determine a multiresolution analysis? The scaling function ¢ is found by solving the two-scale equation. In turn, ¢ determines the entire MRA {Vj : j C Z}. Thus, we must show that the two-scale equation, for a given orthogonal CQF, always has a unique solution ¢ with all the scaling function properties. One way to solve the two-scale equation is by iteration. Define a linear transformation from the sequence h:
H f(t) - ~
h(k)v/-2f(2t - k).
(5.71)
k
The idea is to start with fo - 1 and apply H repeatedly: fn+l d~f = H f ~ so fn de__f H n l ,
for n - 0, 1, 2, ....
(5.72)
T h e o r e m 5.13 If, for every t, fn (t) converges uniformly to a limit function ¢(t) as n -~ c~, then
1.
¢ has compact support;
2.
¢ satisfies the two-scale equation: H e -
3.
¢ is nonzero, integrable, and satisfies f ¢ ( t ) d t -
~{. { ¢ ( t - k)" k e Z} is an orthonormal set.
¢; 1;
5.2. D I S C R E T E W A V E L E T T R A N S F O R M S
165
Proof: Properties 1-4 will be shown in turn. 1. We show by induction t h a t ~b inherits compact support from 1. Suppose h(k) - 0 for k > b or k < a, and f(t) - 0 for t ~ [c,d]. T h e n H f(t) ~J-~k=ah ( k ) f ( 2 t - k) - 0 unless c < 2 t - k _< d for some k - a,a + 1 , . . . , b . But this means t h a t H f ( t ) - 0 unless (a + c)/2 <_ t <_ (b + d)/2. Iterating, H2 f(t) - 0 unless [a + (a + c)/2]/2 <_ t <_ [b + (b + d)/2]/2, and H~ f(t) - 0 unless a a c b - ~ + . • • + ~-~ + 2--~ _< t _< -+ . - . + 2
(1- 2-~)a+2-~c
b d ~-~ + ~-£ - ( 1 - 2 - ~ ) b + 2-~d.
Note t h a t if t < - l a l - Icl or t > Ibl + Idl, then H n f ( t ) - 0 for every n - 0, 1, 2, .... This means t h a t u and all iterations H ~ f are supported in a single compact interval [ - l a [ - fcl, Ib[ + Idl], of length la[ + ]b[ + Ic[ + Idl. Starting with 1, with c - 0 and d - 1, the limit ¢ obtained as n ~ oc is s u p p o r t e d in [a, b]. 2. Let c > 0 be given. We show t h a t I ¢ ( t ) - H¢(t)f < c for every t, so since ~ is a r b i t r a r y we must have ~ - H e . But for any 5 > 0, by uniform convergence we can choose N large enough so t h a t n >_ N ~ If~(t)- ¢(t)l < 5. Then, using the relation f n + l ( t ) - H f n ( t ) and the triangle inequality, we estimate
I ~ ( t ) - HaS(t)[ < a s ( t ) - fn+l(t)[-Jr I H f ~ ( t ) - HcS(t)l < 5 + B6, where B - v/2 }-~k Ih(k)l is the largest a m o u n t by which H can increase the maxim u m absolute value of a function. Now we go back and pick 5 - e/(1 + B). 3. First note t h a t if u is integrable then so is H f, since finite sums of integrable functions are integrable. T h e n observe t h a t f H f ( t ) d t - f f ( t ) d t by Equation 5.38. Thus, for n - 0, 1, 2 , . . . , fn is integrable and f f~ (t) dt - 1. Now f~ (t) --. qS(t) uniformly at all t, so given e > 0 there is an N large enough so t h a t n _> N I~(t)- f~(t)l < e for all t. Since all functions are supported in a single interval of length L - l a l + Ibl + I c t + Idl, it follows 4 t h a t ~b is integrable, and
I
da(t) dt
-
1
/ ~(t) dt - / f~ (t) dt _< / [ q S ( t ) -
A ( t ) ] dt < eL.
Since ]f ~ b ( t ) d t - 11 < eL for every e > 0, it follows t h a t f ¢ ( t ) d t - 1. Finally, ~b must be nonzero because its integral is nonzero. 4. Suppose (f (t - p), f (t - q)) - 5(p - q) for a c o m p a c t l y - s u p p o r t e d function u. T h e n H f inherits the same property:
(H f (t-p), H f (t-q) )
-
2/ E
h(k - 2 p ) h ( k ' - 2q)f(2t - k ) f ( 2 t - k')dt
k,k'
=
Eh(k
- 2 p ) h ( ( k ' - 2q)(~(k - k') -
(~(p- q).
k,k'
Thus, since 1 is orthogonal to its integer translates, so is fn for every n - 0, 1, .... 4Here we use the Lebesgue dominated convergence theorem, which is beyond the scope of this text. For a full proof, see Apostol, page 270, in the further readings from Chapter 3.
CHAPTER 5. SCALE AND RESOLUTION
166
For n so large that I¢(t) - A (t)l < ~ at all t, the value M - f [¢(t)l dt gives an upper bound f Ifn(t)l dt < M + eL. Thus ¢(t
p)¢(t - q ) dt -
5(p - q )
=
/ ¢ ( t - p ) C ( t - q ) d t - / fn ( t - p)fn ( t - q) dt _ /
I¢(t - p) - fn(t - p) l I¢(t - q) l dt + /[f~(t
- P)I [¢(t - q) - f~(t - q)l dt
< cM + (M + ~L)c. Since this holds for all c > 0, it follows that I ( ¢ ( t - p), ¢ ( t - q ) ) - 5 ( p - q ) [ - 0. This implies that ( ¢ ( t - p ) , ¢ ( t - q ) ) - 5 ( p - q), so the inner product is zero if p ~- q. Finally, setting p - q - 0 shows that I1¢]1- 1. [] For the Haar filters of Equation 5.46, we have H 1 - 1 as in Equation 5.31. Thus
fN -- 1 for all N - 0, 1, 2 , . . . , so convergence is not only uniform but immediate: ¢ - 1. However, a study of more general filters H, G that have uniform convergence of {fn} is beyond the scope of this book. 5 To get lots of samples for a graph of a wavelet or scaling function, however, is easy. Since the wavelet transform of Cjk has the expansion sequence sj - ek, we simply apply the j-level inverse wavelet transform to the sequences sj - ek; dj - dj-1 . . . . . dl - 0. Likewise, to get the samples for a graph of ¢jk, we simply apply the j-level inverse wavelet transform to the sequences sj - 0; dj = ek; dj-1 . . . . . dl - 0. We need to use the indexing formula for the particular wavelet transform to find the locations of sj(k) and dj(k). 5.2.4
Lifting
A clever method of implementing filter transforms is called lifting. The two output sequences (Hu, Gu) produced by a pair H, G of CQFs are computed together, efficiently and in a manner that reduces the amount of auxiliary storage. We illustrate with the example of Haar filters applied to a finitely-supported signal u(0),...,u(N1) of length N = 2q > 0:
Lifting Implementation of the Haar Filter Transform on 2q Samples haarlift( u[], [I] For n=O to [2] For n=O to [3] For n=O to [4] For n=O to
q, dq ): q-l, replace q-l, replace q-l, replace q-l, replace
u[(2,n+l),dq] -= u[(2,n)*dq] u[(2*n)*dq] += 0.5*u[(2*n+l)*dq] u[(2,n+l),dq] /= sqrt(2.0) u[(2,n),dq] ,= sqrt(2.0)
5Cavaretta, Dahmen and Micchelli's Stationary Subdivision, in the further readings, has a highly detailed exposition of the relevant technicalities.
5.2. DISCRETE WAVELET TRANSFORMS
167
Ignore the increment dq for the moment, pretending that it is 1. Step 1 replaces all the odd-indexed elements of u with their differences u(2n + 1) - u(2n). Step 2 then adds half these differences into the even-indexed elements, leaving them containing the averages [u(2n + 1) + u(2n)]/2. Steps 3 and 4 then normalize these differences and averages into the familiar Haar filter outputs Gu(n) = [u(2n + 1 ) - u(2n)]/v/-2 and Hu(n) = [u(2n + 1) + u(2n)]/v/-2. Permitting increments dq > 1 makes it easier to use h a a r l i f t () in a recursive discrete wavelet transform. Note that Hu(n) is found at index (2n)dq of the output, and Gu(n) is at index (2n+l)dq. This is different from the p c q f i l t e r ( ) convention, in which Hu(n) is at index n, while Gu(n) is at index n + q. Thus, a different recursion is needed to obtain the D W T by lifting: C o m p l e t e D i s c r e t e H a a r T r a n s f o r m b y L i f t i n g o n 2J S a m p l e s ldht0( [0] I f [1] [2]
u [ ] , J, dq ): J>0, t h e n do [1] t o [2] Compute h a a r l i f t ( u [ ] , ( 1 < < J ) / 2 , Compute l d h t 0 ( u [ ] , J - l , 2 , d q )
dq )
Notice that no temporary storage array is required. Because of the way the outputs are interleaved, the locations of wavelet expansion coefficients d l , . . . , d j; 8j have more complicated index formulas than those of pdwt0(). In particular, sj(O) is found at u[0], dj(O) is found at u [ ( l < < J ) / 2 ] . For 1 < j _< J - 1, there are N/2J - 2 J - j coefficients in the sequence dj, spaced 2dq - 2J indices apart at the odd multiples of dq - 2j-1. Thus the index of dj(k) is 2J-1(2k -~- 1) - 2j-1 -~- k2J, or
dj(k) - u [ ( l < < j ) / 2 + ( l < < j ) , k ] .
(5.73)
To invert h a a r l i f t (), we reverse the order and use the inverses of the steps: I n v e r t t h e H a a r F i l t e r T r a n s f o r m t o 2q s a m p l e s ihaarlift( u[], [1] For n=0 to [2] For n=0 t o [3] For n=0 to [4] For n=0 to
q, dq )" q-l, replace q-l, replace q-l, replace q-l, replace
u [ ( 2 , n ) , d q ] /= s q r t ( 2 . 0 ) u [ ( 2 , n + l ) , d q ] ,= s q r t ( 2 . 0 ) u [ ( 2 , n ) , d q ] -= 0 . 5 * u [ ( 2 * n + l ) * d q ] u [ ( 2 , n + l ) , d q ] += u[(2*n)*dq]
Similarly, we can compute the inverse D W T by reversing the order of lifting and recursion: I n v e r s e D i s c r e t e H a a r T r a n s f o r m b y L i f t i n g on 2 J S a m p l e s ildht0( [0] I f [1] [2]
u [ ] , J, dq ): J>0, t h e n do [1] t o [2] Compute ± l d h t 0 ( u [ ] , J - l , 2 , d q ) Compute i h a a r l i f t ( u [ ] , ( l < < J ) / 2 ,
dq )
It is an exercise to show that i l d h t 0 ( ) inverts l d h t 0 ( ) .
The proof does not use
C H A P T E R 5. S C A L E A N D R E S O L U T I O N
168
the orthogonal C Q F conditions, as these are not needed to prove t h a t i h a a r l i f t () inverts h a a r l i f t (). Lifting may thus be used to get invertible discrete wavelet transforms from nonorthogonal filter transforms.
Symmetric extension before periodization Suppose u - {u(k) • 0 _< k < N} is a finite sequence of N samples of a smooth function. Then ] u ( n ) - u(m)l will be small when I n - m I is small. However, the periodic extension of u given by u(k + N ) def -- u(k) will not have t h a t same smoothness property in general, unless l u ( 0 ) - u ( N - 1)1 is also small. Analysis methods which require t h a t u is a smooth N-periodic function might therefore show artifacts from this failure of the hypothesis. In Chapter 3, we saw t h a t smooth local periodization could be used to modify a smooth signal made nonsmooth by restriction to a segment, but t h a t technique is not available if all we have are the N samples and nothing outside. Another way to preserve some smoothness after periodizing is to extend u by reflection before periodizing. This creates two-fold redundancy, but if we then use a filter transform with the same reflection s y m m e t r y the redundancy can be removed. Restriction to half the output coefficients determines the other half by symmetry, so there is neither redundancy nor loss of information. There are two ways to extend u symmetrically past k - N - 1 and k - 0. One is half-sample symmetric periodization:
HSPu(k) -
u(k), u(2N-
l - k),
ifk-0,...,N-1 ifk-N,...,2N-1
(mod2N); (mod2N).
This extension has period 2N and satisfies u(k) - u ( - 1 - k) - u ( 2 N - 1 - k) for all 1 To compute integers k, making it symmetric about the half-integers - 3 1 and N - 3" H S P u ( k ) at any k C Z requires an index calculation:
Half-Sample Symmetric Periodic Extension Asp( u I ] , k, N )" [0] I f k
WSPu(k) _ f
if k - 0,. .. , N - 1 (rood 2 N - 2); if k - N , . . . , 2 N 3 (mod 2 N - 2).
5.2. D I S C R E T E W A V E L E T T R A N S F O R M S
169
coefficient[value I[ c°efficient I value I h(0) h(+l) h(+2)
3/4 1/2 1/8
g(1) g( 1 + 1) g( 1 + 2)
5//4 -5/32 -3/8
-3/32 Table 5.2: Nonzero coefficients of the 4,2-biorthogonal filters.
This extension has period 2 N - 2 and satisfies u(k) = u ( - k ) = u ( 2 N - 2 - k) for all integers k, making it symmetric about the integers 0 and N - 1. To compute W S P u ( k ) at any k C Z requires another index calculation:
Whole-Sample Symmetric Periodic Extension wsp( [0] [I] [2] [3]
u[], k, N ): If k
The 9,7- and 4,2-biorthogonal filter transforms, described below and in the exercises, both have whole-sample symmetry. If we apply one of them to the ( 2 N - 2)-periodic signal W S P u and restrict to one period, the first N outputs will determine the second N - 2. Once again, N can be an arbitrary odd or even length for u. The discrete wavelet transform thus obtained is free from the power-of-2 length condition.
Symmetric filters A filter sequence f can have four types of symmetry:
Types of Symmetric Filters WS
Whole-sample symmetry about C: f ( 2 C - k) for all integers k;
WA
Whole-sample antisymmetry about C: For some integer C, f (k) = - f ( 2 C - k) for all integers k. This also implies that f ( C ) = 0;
H S Half-sample symmetry about C + -~ 1. f (2C + 1 - k) for all integers k;
For some integer C, f ( k ) =
For some integer C f(k) -
H A Half-sample antisymmetry about C + 1. f (k) = - f (2C + 1 - k) for all integers k.
For some integer C,
1 For Haar filters, h is HS about ~1 and g is HA about ~. The g,2-biorthogonal filters are WS about 0 and - 1 , respectively, as is evident from Table 5.2. All their other coefficients are zeroes.
170
CHAPTER
coefficient
5. S C A L E A N D R E S O L U T I O N
value
value II coefficient
h(0) h(+l) h(+2) h(±3) h(+4)
0.8526986790
g(-1)
0.377402855a 0.1106244044 0.0238494650 0.0378284555
g( 1 + 1) g( 1 + 2) g ( - 1 + 3)
0.7884856164 0.4180922732 0.0406894176 0.0645388826
Table 5.3: Nonzero coefficients of the 9,7-biorthogonal filters.
Likewise, the 9, 7-biorthogonal filters h, g given approximately in Table 5.3 are WS about 0 and - 1 . All their other coefficients are zero. Exact formulas for the coefficients may be found in Daubechies on page 279, Table 8.3. Note that neither pair h, g of WS filters are orthogonal CQFs, as they are not related by conjugacy. They nevertheless allow perfect reconstruction, as their combined action is invertible. The filter transform that inverts the h, g combined filter transform is given by their actual conjugates h, ~, defined by ~(k) de___f ( _ l ) k + l h ( _ l - k).
~t(k) de f ( _ l ) k g ( _ l _ k ) ;
(5.74)
The conjugate of a symmetric filter is also symmetric: L e m m a 5.14 Suppose h - {h(k)} is a filter sequence, and g - {g(k)} is its conjugate defined by g(k) - ( - 1 ) k h ( 2 M 1 - k), then 1. h is W S about C if and only if g is W S about 2 M -
C-
1;
2. h is WA about C if and only if g is WA about 2 M - C -
1;
3. h is H S about C if and only if g is HA about 2 M - C - 2 + ~1 ; 1 ~. h is HA about C if and only if g is H S about 2 M - C - 2 Jr 2"
Proof:
In the first case, compute g(k)
-
(-1)kh(2M-
l - k) -
(-1)kh(2C-
2 M + l + k)
=
(-1)kh(2M-
1 -[4M-
--
(-1)4M-2C-2-kh(2M-
2 C - 2 - k]) 1 - [ 4 M - 2 C - 2 - k])
=
g(4M-2C-2-k).
Modified slightly, the same argument proves the second case: g(k) - ( - 1 ) k h ( 2 M -
1 - k) - - ( - 1 ) k h ( 2 C - 2 M + 1 + k) - - g ( 4 M -
2 C - 2 - k).
In the third case, g(k)
-
(-1)kh(2M-
l - k) -
2 C - 3 - k]) - - ( - - 1 ) 4 M - 2 C - 3 - k h ( 2 M - 1 - - [ 4 M - 2 C - 3 - k]) (-1)kh(2M-
=
-g(4M-
2C-
1 -[4M-
( - 1 ) k h ( 2 C + l - 2 M + l + k)
3 - k).
5.2. D I S C R E T E W A V E L E T T R A N S F O R M S
171
In the fourth case,
g(k)
-
( - 1 ) k h ( 2 M - 1 - k) -
- ( - 1 ) a h ( 2 C + 1 - 2 M + 1 + k)
= =
- ( - 1 ) k h ( 2 M - 1 - [ 4 M - 2 C - 3 - k]) ( - 1 ) 4 M - 2 C - 3 - k h ( 2 M - 1 - [ 4 M - 2 C - 3 - k])
=
g(nM-2C-3-k).
This also follows from the third case by exchanging h and g and then substituting 1 [] C~-2M-C-2+~. With symmetric filters and symmetric extension and periodization, a discrete wavelet transform may be performed on signals of arbitrary length. We begin by separating the three kinds of lifting steps. The step that computes new values at odd multiples of the increment dq is called prediction:
Whole-Sample Symmetric Lifting: Prediction Step wslpredict( u[], N, dq, coeff ): [0] Let i = dq [i] While i
Step 4 handles the odd N / d q case. Step 5 handles even N / d q by whole-sample symmetric extension. The step that computes new values at even multiples of dq is called updating: W h o l e - S a m p l e S y m m e t r i c Lifting: U p d a t i n g S t e p wslupdate( u[], N, dq, coeff ): [0] Sum u[O] += 2*coeff*u[dq] [I] Let i = 2,dq [2] While i
Steps 0 and 7 perform whole-sample symmetric extension. Step 7 is supplanted by step 6 if N / d q is even. Note that the inverse of w s l p r e d i c t ( u , N , d q , c o e f f ) is wslpredict(u,N,dq,-coeff), wslupdat e (u, N, dq, -coeff).
and the inverse of wslupdate(u,N,dq,coeff)
is
CHAPTER 5. SCALE AND RESOLUTION
172
T h e t h i r d t y p e of lifting step, n o r m a l i z a t i o n , does not require s y m m e t r y . It is always 6 p e r f o r m e d jointly on b o t h t h e even-indexed a n d o d d - i n d e x e d elements: Lifting: Normalization
Step
Inormalize( u[], N, dq, coeff ): [0] Let i = 0 [I] While i
Inormal ize (u, N, dq, i/coeff).
T h e 4,2- a n d 9 , 7 - b i o r t h o g o n a l
filters of JPEG
2000
T h e so-called 4,2-biorthogonal discrete wavelet t r a n s f o r m used in t h e lossless 3 P E G 2000 image compression a l g o r i t h m is a whole-sample s y m m e t r i c - e x t e n s i o n algor i t h m i m p l e m e n t e d by lifting. T h e filter t r a n s f o r m requires two predictions, one u p d a t i n g , a n d one normalization: WS Lifting: 4,2-Biorthogonal
ws142filter( [0] Compute [I] Compute [2] Compute [3] Compute
Filter Transform
u[], N, dq ): wslpredict( u[], N, dq, alpha42 ) wslupdate( u[], N, dq, beta42 ) wslpredict( u[], N, dq, gamma42 ) Inormalize( u[], N, dq, zeta42 )
1 1 T h e inverse T h e lifting coefficients 7 are c~a2 - ~,/342 - 1, "/49._ - 7 53, a n d ¢42 -- 3" filter t r a n s f o r m requires one n o r m a l i z a t i o n , one u p d a t i n g , a n d two predictions, with inverted coefficients: WS Lifting: Inverse 4,2-Biorthogonal
Filter Transform
ws142ifilter( u[], N, dq ): [0] Compute Inormalize( u[], N, dq, I/zeta42 ) [i] Compute wslpredict( u[], N, dq, -gamma42 ) [2] Compute wslupdate( u[] , N, dq, -beta42 ) [3] Compute wslpredict( u[], N, dq, -alpha42 ) 6The HS/HA biorthogonal Haar transform on any number of points can be made orthogonal if the last output in the odd N/dq case is left unnormalized. See Exercise 20. 7Determining the lifting coefficients from the filter coefficients is beyond the scope of this text. See Daubechies and Swelden's article in the further readings for a complete derivation.
5.3. EXERCISES
173
Following l d h t 0 ( ) , we can now implement the 4,2-biorthogonal wavelet transform recursively: W S Lifting: 4 , 2 - B i o r t h o g o n a l D i s c r e t e W a v e l e t T r a n s f o r m ws142dwt( u [ ] , N, dq, J ): [0] If J>O, then do [I] to [2] [i] Compute ws142filter( u[], N, dq ) [2] Compute ws142dwt( u[], N, 2*dq, J-i ) Reconstruction from the output coefficients is accomplished by the inverse: W S Lifting: 4,2-Biorthogonal I n v e r s e D i s c r e t e W a v e l e t T r a n s f o r m
ws142idwt( u[], N, dq, J ): [0] If J>O, then do [i] to [2] [I] Compute ws142idwt( u[], N, 2*dq, J-I ) [2] Compute ws142ifilter( u[], N, dq ) The 9,7-biorthogonal filter transform used in J P E G 2000 is implemented by whole-sample symmetric lifting as well:
WS Lifting: 9,7-Biorthogonal Filter Transform ws197filter( [0] Compute [i] Compute [2] Compute [3] Compute [4] Compute
u[], N, dq ): wslpredict( u[] , N, dq, alpha97 ) wslupdate( u[], N, dq, beta97 ) wslpredict( u[], N, dq, gamma97 ) wslupdate( u[], N, dq, delta97 ) Inormalize( u[], N, dq, zeta97 )
..
The lifting coefficients, at better than IEEE 64-bit precision, are 0/97
--
- 1.5861343420599235584283154513374... -0.0529801185729614146241295675035...
/~97 797
--
+0.882911075530933295919790099003...
(~97
--
+0. 4435068520439711521156042151689...
~97
(5.75)
+ 1.149604398860241159795075642191...
The rest of the implementation is left as an exercise.
5.3
Exercises
1. Draw graphs like those in Figure 5.1 on page 135, depicting the configuration of w(at) and w(t-b) in Case 6 and Equation 5.3 on page 134. Use the graphs to compute the inner product integrals v / ~ / ~ ( a t ) w ( t cases.
, J
b)dt for those two
CHAPTER 5. SCALE AND RESOLUTION
174 2. Show t h a t the function
p(a, b) def ( ao lb) is a faithful representation of the group Aft. 3. Suppose t h a t f = f(a,b) is a function on Aft. Along with left-invariant integrals, it is possible to define an area element db, for b = (a, b) c A f t , so that for any fixed b t c A f t ,
/Aff f (b) db - /Aff f (bb') db. In other words, the integral should not be changed by renaming the group elements through applying b' on the right. An area element db with these properties is called a right invariant measure. Find a normalized right invariant measure on Aft. 4. Suppose t h a t w = w(t) is the Haar mother function and u = u(t) is an absolutely integrable function which is piecewise constant on intervals of the form [k, k + 1), where k is an integer. Prove t h a t (3<)
- Z
k).
j=l
5. Let d be a positive integer. Show t h a t the function e -(1°gl41)2, if~ # 0; ¢(¢)--
0,
if
-0,
has d continuous derivatives. 6. Let n and d be positive integers. Show t h a t the function ¢ = ¢(~) defined in Exercise 5 satisfies ¢(n)(~) = O(1/l~l d) as ~ ---+ +oo. 7. Let u = u(x) be any fixed function in L2(R). Let w = w(t) be the function defined by $-w(~) = ¢(~) as in Exercise 5. Prove t h a t the wavelet transform Wu - Wu(a, b) using mother function w has derivatives with respect to a and b which are continuous away from a = 0. 8. C o m p u t e I[w[I, where rem.)
w(x)
= sincx = ~sin .7rx
(Hint: use Plancherel's theo-
9. Show t h a t the function w(x) - 2sinc 2 x - sinc x - sin27rx--sinwx is an admis7rx sible function. C o m p u t e its normalization constant. 10. Suppose t h a t w = w(x) is the Haar mother function. C o m p u t e the Fourier integral transform of w.
5.3. EXERCISES
175
11. Prove that the set of functions {¢k " k C Z} defined by Ck(t) - sine ( t - k) is orthonormal. (Hint: use Plancherel's theorem and the fact that sine -
~E-I,~I .) 12. Show that if h - {h(k) • k E Z} is the low-pass filter from an MRA, and M is any fixed integer, then defining
g(k) - (-1)kh(2M-
for all k c Z,
1 - k),
(5.76)
gives another high-pass filter for that MRA. 13. Show that the Daubechies 4 low-pass filter of Equation 5.49 is derived from the general form in Equation 5.48 using the parameter value c - 2 - x/~. 14. Suppose that h, g is a CQF pair derived from an orthogonal MRA with scaling function ¢ and mother function ~. Suppose that u C L2(R) has compact support, and let sj(k) de__f(¢jk, u} and dj(k) de_f {¢jk, u} be the expansion coefficients of u in Vj and Wj in their respective orthonormal bases. Prove that 8j+1(n)
-
~
h(k)~(2~ + k)
=
k
d~+~(~)
-
~g(k)~(2~ ~
h ( k - 2n)~(k); k
+ k)
=
k 8j-l(n)
~
~g(k-
2~)~(k);
k
h(~ - 2k)~(k) + g(~ - 2k)~(k). k
(These are Equations 5.58, 5.59, and 5.60, respectively.) 15. Suppose that x, y, a, b, c, d are integers with x >_ y, b _> a, and d _> c. a. Show that 2 [~@1 + a _< x - ( b - a - 1), and 2 [~2aJ + b _> y + (b - a - 1)1. (Hence a sequence u supported in Ix, y] may have a projection F*Fu, as defined by Equation 5.63, with coefficients in the larger interval [ x - ( b - a -
1),y+(b-a-1)].) b. Show that
(l+lY-2aJ-
[x2bl) > -
1+y-x+
b-a-1 2
+
d-c-1 2
(This estimate of the quantity in Equation 5.67 shows that the nonperiodic discrete wavelet transform with CQFs longer than 2 may have more output coefficients than inputs.)
CHAPTER 5. SCALE AND RESOLUTION
176
16. Show that if h = {h(k) : k E Z} and g = {g(k) : k E Z} satisfy the orthogonal CQF conditions, and P = 2P' is any fixed even integer, then the P-periodizations hp, gp of h and g, respectively, also satisfy the orthogonal CQF conditions. Namely, show: p,
N o r m a l i z a t i o n of hp: Ek___-O1 hp(2k) thus ~ ek-=10
pt
Ek___-o1 hp(2k + 1) -
1/~/2,
and
S e l f - o r t h o n o r m a l i t y of hp: E k=O P-1 hp(k + 2n)hp(k + 2m) - 5 p , ( n - m) for all integers n, m. P'
P'-I
N o r m a l i z a t i o n of gp: ~k_~ 1 gp(2k) - - ~ k = 0 gp(2k + 1) - 1 / v ~ , and thus y-~,P-lk=0gp(k) - 0. S e l f - o r t h o n o r m a l i t y o f gp" }-~P-1 k=O gp(k + 2n)gp(k + 2m) - 5p,(n- m), for all integers n, m. P e r i o d i c i n d e p e n d e n c e of hp a n d gp: }-~p-1 k=0 gp(k + 2n)hp(k + 2m) - 0 for all integers n, m. P e r i o d i c c o m p l e t e n e s s of hp a n d gp: for all integers n, m, P'-I
E
[hp(2k + n)hg(2k + m) + gg(2k + n)gg(2k + m)] - 5 p ( n - m).
k=0
17. Implement the inverse to Mallat's periodic discrete wavelet transform, for signals of period N - 2JK with positive integer J and K, using arbitrary 4-tap filters. Use it to generate a graph of the Daubechies 4 wavelet and scaling function, using the filters -g(3)-
g(2)- h(1)-
-g(1)-
0.48296291314453416
h(0)-
h(2)-
g(0)- h(3)-
3 + v/-3
3-v/5 l-v/5
0.83651630373780794 0.22414386804201339 -0.12940952255126037
18. Suppose that {u(n) • n E Z, 0 _< n _< 2 q - 1} is a given sequence of 2q numbers. a. Determine the contents of u(2n) and u(2n + 1), for n - 0, 1 , . . . , q - 1, after the following sequence of substitutions:
1. u(2n + 1)+- u(2n + 1 ) - u(2n), all n 2.
+
1 u ( 2 n + 1), all n - 0 , . ,
0 , . . . , q - 1; . , q - 1;
5.4. FURTHER READING
177
3. u(2n + 1) +- u(2n + 1)/x/2, all n = 0 , . . . , q 4.
u ( 2 n ) + - x/2u(2n), all n = 0 , . . . , q -
1;
1.
(These are the steps performed by h a a r l i f t ().) b. Determine the contents of n(2n) and u(2n + 1), for n = 0, 1 , . . . , q after the following sequence of substitutions:
1,
1'. g(2n) ~- u(2n)/v/-2, all n = 0 , . . . , q - 1; 2'. u(2n + 1)~-- x/-2u(2n + 1), all n = 0 , . . . , q - 1; a'. 1 u(2n + 1) , all n - 0, . . . , q - 1 ; 4'. u(2n + 1)~-- u(2n + 1 ) + u(2n), all n = 0 , . . . , q - 1. (These are the steps performed by i h a a r l i f t
().)
c. Show that the procedure in part a is inverted by the procedure in part b, proving that i h a a r l i f t () is the inverse of h a a r l i £ t (). d. Show that i l d h t 0 ( )
is the inverse of i l d h t 0 ( ) .
19. Implement the 9,7-biorthogonal discrete wavelet transform and inverse, for signals of arbitrary length, using whole-sample symmetric lifting and the coefficients of Equation 5.75. Plot a graph of a 100-point signal reconstructed from a single nonzero wavelet coefficient at index 32 at level 3. Do the same for index 36 at level 4, and again for index 41 at level 5. 20. Implement the discrete Haar wavelet transform and its inverse, for signals u ( 0 ) , . . . , u ( N - 1) of arbitrary length N, using half-sample symmetric extension at - ~1 and N - 5" 1 Test your program by implementing the inverse to check that it recovers the signal. Modify the normalization step to omit normalizing u ( N - 1) when N is odd, and test that the resulting transform is orthogonal by computing the sum-of-squares of signal samples and transform coefficients to check that they are equal. 21. Let w = w(x) be the Haar mother function and let 1 = l(x) be the Haar father function, namely the indicator function of [0, 1]. For (x, y) C R 2, define co(x, y) = l ( x ) l ( y ) ,
e 1(x, y) = l(x)w(y)
e2(x, y) = w(x)l(y),
e3(x, y) = w(x)w(y).
Prove that the functions {en : n = 0, 1,2,3} are orthonormal in the inner product space of square-integrable functions on R 2.
5.4
Further
Reading
• Alfred S. Cavaretta, Wolfgang Dahmen, and Charles A. Micchelli. Stationary Subdivision, volume 93(453) of the Memoirs of the AMS. American Mathematical Society, Providence, Rhode Island, 1991. ISBN 0-8218-2507-0.
178
CHAPTER 5. SCALE AND RESOLUTION Ingrid Daubechies. Ten Lectures on Wavelets, volume 61 of the CBMS-NSF Regional Conference Series in Applied Mathematics. SIAM Press, Philadelphia, 1992. ISBN 0-89871-274-2. Ingrid Daubechies and Wim Sweldens. Factoring wavelet transforms into lifting steps. J. Fourier Anal. Appl., 4(3):245-267, 1998. Arne Jensen and Anders la Cour-Harbo. Ripples in Mathematics: The Discrete Wavelet Transform. Springer-Verlag, Berlin , 2001. ISBN 3-540-41662-5. • ISO/IEC. JPEG 2000 final committee draft 15444-1, March 2000. Available
from U R L http://www, jpeg. org/JPEC2000 .html.
• St@phane G. Mallat. A Wavelet Tour of Signal Processing. Academic Press, New York, second edition, 1999. ISBN 0-12-466606-X.
Chapter 6
Redundancy and Information Information is stored in computers as strings of bits. For example, each letter, number and punctuation mark of English text in my computer is encoded with a unique string of seven bits defined by the American Standard Code for Information Interchange, or ASCII, a 128-character alphabet listed in Table B.1 on page 274 in Appendix B. Today's most common computers use eight bits per character in a 256-element alphabet, because this simplifies and standardizes hardware designs. With ASCII data, the eighth bit can be used for some other purpose, such as parity-error detection, described in Section 6.2 further on. The eighth bit depends on the previous seven and is therefore redundant, adding to the cost of information storage and transmission. There are subtler forms of redundancy as well. For example, the letter 'e' is exceedingly common in English text. The string for 'e' can be abbreviated by one bit if the string for a rare letter such as 'q' is lengthened by one bit. The result is a slightly shorter encoding of English text. How far can this idea be pushed? Likewise, not every sequence of letters constitutes an English word. Given the side information that the communication is English text, the receiver can often deduce the entire word or phrase from just a portion of its letters. This is evident in expressions like '2 bdrm aptmnt avlbl'. With sufficient effort, all the possible interpretations can be searched and the likeliest one chosen. W h a t is the cost to benefit relationship for such methods? The theoretical lower bound on the amount of information needed to represent a string of bits is the algorithmic complezity, or Kolmogorov complezity, which is defined to be the number of bits needed to specify the shortest algorithm that produces the bit string and then terminates. Such a vague definition requires a notion of "universal computer," programmable by bit strings to produce any output bit sequence. Both receiver and transmitter must possess such a c o m p u t e r - - i t provides the context in which the algorithm is interpreted--but that is not an obstacle in practice. However, algorithmic complexity is an impractical information measure for two reasons. First, it assigns no weight to the effort required for 179
180
C H A P T E R 6. R E D U N D A N C Y
AND INFORMATION
encoding or decoding. It is possible that the shortest algorithm will produce the output after a million times as many steps as an algorithm only one bit longer. A less dramatic example is the compressed message '2bdrmaptmntavlbl' which is only three space-characters shorter than the original but is much harder to decode. Second, the effort needed to find the shortest algorithm grows exponentially with the length of the message to be encoded. That is because in the most general case it is necessary to examine all of the algorithms with bit lengths up to that of the message, and there are 2 N of these for a message originally encoded with N bits. There can be no guarantee that every message will require a significantly shorter algorithm, for if so then a small number of algorithms could be used to denumerate a much larger number of messages. Because of these flaws, the notion of algorithmic complexity is mainly useful for obtaining ultimate lower bounds for data compression methods.
6.1
Information
Source
Coding
There is a more practical notion of complexity which, for certain kinds of messages, gives a lower bound on the average number of bits per transmitted character. We begin with rigorous definitions of some of the intuitive notions just mentioned: D e f i n i t i o n 4 A n information source is a random variable S taking values in the alphabet A. The alphabet is a finite set A - { a l , . . . , a N } . We imagine evaluating S over and over, to get information in the form of a sequence of values. The probability space for S is the set A, and the N elements a l , . . . , a N o f A are called letters or characters. def
The probability function is completely determined by its values Pk - P r ( S = ak) on individual letters. These are also called the occurrence probabilities. We have 0 _< P k _~ 1 for all k - 1 , . . . , N, and P l + " ' " ~- P N - - 1. A message of length M from the source S is the random variable $1 ... SM built from M independent copies of S. Its probability space is M
A M d~j ~ A × . . . × A , the ordered M-tuples of letters in A. A message instance is a particular sequence S l ' ' ' S M E A M. It is written concatenated, without commas or parentheses. Independence implies that regardless of m - 1 , . . . , M, Pr(Sm - ak) - Pk,
for each k - 1 , . . . , N,
and thus for any message instance of M letters S l . . . SM C A M, P r ( S l . . . SM --
-- P r ( S l -
×...
× Pr(S
-
The assumption that adjacent letters in a real text are values of independent random variables is clearly false in particular cases. In English text, for example,
6.1.
181
INFORMATION SOURCE CODING
the likelihood that ~ r n + l - - U is strongly influenced by whether Sm = q. The independence assumption simply states that we will not take such influences into account when calculating the probability of a message instance. Our deliberate ignorance will produce cruder results, but they will apply to all languages. 6.1.1
Lossless
encoding
Each character a in a message instance may be transmitted as a codeword c(a), a finite string of 1 and 0 bits 1. The code a H c(a) is a function on the alphabet A - { a l , . . . ,aN}. We require that it be one-to-one, so that it can be inverted and the character recovered from its codeword. Since there are just 2 n possible n-bit codewords, it follows that if all the codewords have n or fewer bits, then N _< 2 n. If the codewords all have n bits and c is one-to-one, then every message instance 8 1 ' ' ' 8 M for every M can be recovered exactly from its concatenated codeword bit strings C(Sl).. "C(SM), with no lost or extra letters. For example, ASCII encodes a 128-letter alphabet using n - 7 bits per codeword, the minimum number. But we will allow codewords of varying bit lengths, as long as the encoding function remains invertible: D e f i n i t i o n 5 A code c for an alphabet A is called uniquely decipherable if the message encoding function that concatenates codewords, C(8182"''8M)
de___f C ( 8 1 ) C ( 8 2 ) ' ' ' C ( 8 M ) ,
is one-to-one on A M for every M .
One way to show that the message encoding function is one-to-one is to find an algorithm that recovers Sl ... SM from its encoding C ( S l ) . . . e ( s M ) . For example, e(a) = 0, e(b) = 0001 is a variable bit length code for A = {a, b}. The message instance baab yields the binary string 00010 0 0001. This code is uniquely decipherable, since the following algorithm recovers any message instance from its encoding:
Unique Deciphering Example d e c i p h e r e x ( b i t [ ] , L ): [0] Let n=0 [1] For k=l to L, do [2] to [5] [2] If bit[k]==O, then increment n += 1 [3] Else do [4] to [5] [4] Print n-3 'a's f o l l o w e d by a single [5] Let n = 0 [6] p r i n t n ca' s and terminate.
'b'
By contrast, c(a, b, c) - (0, 0, 1) is not a uniquely decipherable code for the alphabet A - {a, b, c}, since the codeword 0 corresponds to both a and b. The 1Only binary codes will be considered here. A more general treatment of codes in any base B can be found in Ash's Information Theory, pages 27-45.
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
182
problem is that its codewords are not long enough for it to be one-to-one. They must be long enough to distinguish different messages, giving the following necessary condition" L e m m a 6.1 If alphabet A has a uniquely decipherable code with codeword lengths {nx " x C A}, then E2-n~
<_ 1.
xCA
Proof: Since A is finite, there must be a longest codeword. Let r > 0 be its length in bits. Let wj be the number of codewords of length j, for j - 1, 2 , . . . , r. Then E
2_n~ _ ~
xCA
W j2 _ j de__f W.
j=l
Now consider W m for any fixed m > 1. This consists of terms Wjl"" .Wjm2-J where j -- jl + " " + jm for each j satisfying m <_ j < mr, so
w
=
-
":
WJl .
jl + ' " + j m : j
Wjm . .
)
.2 _ j
def
M2-
j:rn
Now Nj counts all the m-letter messages whose encodings total j bits. Since each encoding is uniquely decipherable, Nj cannot exceed the number of j-bit binary strings, which is 2J. Thus, mr
mr
mr
j--m
j--m
j--m
so W < rnl/mrl/m. Since this is true for any rn, and
lim m l / m r 1/m - 1, it follows m
that W < 1.
----~ o o
[]
Note that if A has N - 2 n letters, and each has a codeword of n bits as in ASCII where n 7, then ~ x c A 2 - ' ~ -- N 2 - n - 1 gives equality in L e m m a 6.1. But equality is also attained by some variable-length uniquely decipherable codes. For example, c(a, b, c, d) - (0, 10,110,111) has codeword bit lengths (na, nb, no, rid) -(1,2,3,3) , so ~ x e A 2-n~ ---~ +1~ + ~ +1 ~ - 1 1. 1 A code will also fail to be uniquely decipherable if two codewords can concatenate to give a third. For example, c(a,b,c) - (0, 01,001) is not a uniquely decipherable code for the alphabet A - {a, b, c}, since both ab and c are encoded as the string 001. We can avoid that problem by using a fixed bit length for all codewords, or else by imposing a structure on the code: D e f i n i t i o n 6 A prefix code is a uniquely decipherable code with the additional property that no codeword is the first part of a longer codeword.
6.1. I N F O R M A T I O N S O U R C E C O D I N G
183
For example, c(a, b, c) = (0, 11,101) is a prefix code, while c(a, b) = (0, 0001), c(a, b, c) = (0, 01,001) and c(a, b, c) = (0, 0, 1) are not. Note t h a t a prefix code is instantaneous, since each letter of the message can be d e t e r m i n e d as soon as its codeword is read. From our examples, we see t h a t not all uniquely decipherable codes are prefix codes or instantaneous codes. To describe the construction, encoding, and decoding of a prefix code, we first need some basic facts a b o u t a b s t r a c t graphs and trees: D e f i n i t i o n 7 A graph is a set V, called the vertices, together with a set E of (unordered) pairs of vertices called edges.
A graph is called finite if there are finitely many vertices, which implies there are finitely m a n y edges 2. A graph with n vertices can have at most n ( n - 1)/2 edges. Two vertices u, v C V are considered joined by an edge, or neighbors, if
{u, v} ~ E. Two vertices u, v C V are considered joined by a p a t h if there is a finite set of distinct vertices {u = x0; X l . . . , X~_l; Xn ~- V} such that {Xk_l, xk } E E for every k = 1, 2 , . . . , n. Such a path is said to pass through the i n t e r m e d i a t e vertices Xl, x2, . . . , X~-l. The length of this path is n, the total number of edges it contains. • A graph is called connected if each pair of vertices is joined by a path. • The distance between two distinct vertices is the length of the shortest path joining them. If they are not joined, then their distance is said to be +c~. If two vertices are joined by an edge, their distance is 1. A vertex is also considered at zero distance from itself. In all three of these extreme cases, the set of intermediate vertices is empty. G r a p h s are often visualized as sets of points, the vertices, connected by line segments, the edges. Figure 6.1 shows two examples. It is left as an exercise to label the vertices and list the edges. D e f i n i t i o n 8 A tree is a graph in which each pair of vertices is joined by a unique path.
• A tree contains no loops, or distinct paths between distinct vertices. • A leaf is any vertex in a tree which is joined by an edge to a single other vertex.
• We can also fix one vertex in a tree and call it the root. A n y vertex will do, but there can be no more than one. If a tree has a root, then 2Our definition allows at most one edge for each pair of distinct vertices. What happens if we allow a vertex to be joined to itself by an edge, or allow more than one edge between two vertices?
184
C H A P T E R 6. R E D U N D A N C Y
AND INFORMATION
Figure 6.1: E x a m p l e graphs: a generic graph with loops, and a tree.
-- The generation of a vertex in the tree is the distance between it and the root. The root is generation O. - Every non-root vertex is joined by an edge to a unique parent vertex one generation closer to the root. The root vertex has no parent. -
The children of any vertex are the vertices one generation f a r t h e r f r o m the root that are joined to it by an edge. A vertex with no children is a leaf.
- Ancestors of a vertex include the parent, the grandparent and so on; descendents include children, grandchildren, and so on. -
The depth of a tree with root is the m a x i m u m generation n u m b e r of any vertex.
T h e graph on the right-hand side of Figure 6.1 is a tree. It is left as an exercise to pick a root and find the resulting d e p t h and the generation numbers of each of its vertices. Trees with a root are used in the construction of uniquely decipherable codes, in fact prefix codes, because of their unique p a t h property. T h e generation of a vertex will be the bit length of a codeword. For proper labeling, we must add one extra piece of structure to a tree: D e f i n i t i o n 9 A binary tree is a tree with root such that each vertex has at m o s t two children, which are distinguishable and called the son and daughter. This extra structure affects the e n u m e r a t i o n of binary trees. For example, the graphs in Figure 6.2 are considered different as binary trees, even t h o u g h they are identical as graphs and trees. T h e number Bn of binary trees with n vertices is 3
n + 1
n!(n + 1)!"
Still, for every n there are only finitely many binary trees with n vertices. T h e r e are likewise at most finitely m a n y binary trees with D or fewer generations, since such a tree can have at most n = 1 + 2 + . - - + 2 D = 2 D+I - 1 vertices. However, for every N > 0 there are infinitely m a n y binary trees with N leaves.
3See Knuth, pages 388-389, from the further readings in Chapter 1.
6.1. INFORMATION SOURCE CODING
185
s
s
Figure 6.2: Two equivalent graphs which are considered distinct binary trees.
root b : ° l l ~' "/~ o
c:OOl ]
d:oool
@ I
prefix ]leaf
Figure 6.3: Binary tree for the prefix code (a = 1, b = 01, c = 001, d = 000).
A special kind of binary tree is the extended binary tree, which has the property that every non-leaf, or interior vertex, has both a son and a daughter vertex. Any binary tree with n vertices can be grown into an extended binary tree by adding a son or daughter leaf wherever one or both are missing. The extended tree will have n + 1 added leaves and 2n + 1 total vertices, with all of its original vertices becoming interior vertices. Thus an extended binary tree with N leaves has N - 1 interior vertices and 2 N - 1 total vertices. A quaternary tree or quadtree is a tree with root such that each vertex has at most four distinguishable children. In general, a d-ary tree has a root and at most d distinguishable children per vertex. The number of d-ary trees with n vertices is
Dn = [d-1]n + 1
n!([d-1]n + 1)!"
(6.2)
Extended d-ary trees can likewise be defined. Any binary prefix code is equivalent to a binary tree. Each letter corresponds to a leaf in the tree, with its codeword sequence of 0's and l's determined by the sequence of sons and daughters needed to get from the root to the leaf. For example, the code c(a, b, c, d) = (1, 01,001,000) corresponds to the tree in Figure 6.3. The generation number of a leaf in such a tree equals the number of bits in its codeword. For example, letters c and d in Figure 6.3 come from generation a and have a-bit codewords. The deciphering algorithm starts at the root and turns left or right depending upon the latest bit read, until it gets to a leaf. It then prints the letter determined by that leaf, returns to the root, and continues reading bits. Whenever a uniquely decipherable code exists, there is a prefix code with the same codeword bit lengths. The proof is constructive, building the prefix code's binary tree:
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
186
~ii'~Ii~~~iii::i.ii:I~;~II:I~II' i:.i::(.~ii:,(.~:!~II;IIIIII i Figure 6.4: Prefix code built from a complete binary tree of depth r - 4. Shaded vertices indicate codeword leaves {000, 0010, 0011,01, 1}; light vertices and edges have been pruned.
L e m m a 6.2 An alphabet A has a prefix code with codeword lengths {nx " x E A} if and only if E 2 - - n x <__ 1. xCA
Proof: Since a prefix code is uniquely decipherable, Lemma 6.1 implies that A has a prefix code only if ~ x c A 2-n~ --< 1. Conversely, suppose the inequality holds. Let r - max{nx • x c A} be the the longest bit length and consider the complete binary tree with depth r, namely, one that has 2 ~ leaves at generation r from the root. We proceed as follows" C o n s t r u c t a Prefix Code W i t h Specified C o d e w o r d L e n g t h s PC-1.
If there are no letters in alphabet A, then terminate. Otherwise, take x E A and let nx be its codeword bit length.
PC-2.
Find an unlabeled vertex at generation nx which does not lie on the path from the root to any previously labeled codeword leaf. Label that vertex with the letter x.
PC-3.
Prune the tree at the vertex labeled x by removing all of its descendents, making it a codeword leaf.
PC-4.
Replace A +-- A \ {x} and go to step PC-1.
It remains to show that the algorithm does not run out of vertices in step PC-2 before it exhausts the finite alphabet A. But making a leaf labeled x at generation nz removes exactly 2 ~-nx leaves from generation r. Since ~ x c A 2-nx <-- 1 implies that Y~xeA 2 ~-nx < 2 ~, the tree provides at least enough unlabeled vertices for the whole alphabet. [3 Figure 6.4 depicts the construction of a prefix code with lengths 3, 4, 4, 2, 1 for a five-letter alphabet. Note that there may be more than one prefix code for a given set of bit lengths. 6.1.2
Efficient
coding
All of the codes we consider are static, in the sense that each letter of the alphabet is assigned the same codeword regardless of its position in the message. That is
6.1. I N F O R M A T I O N SOURCE CODING
187
not a necessary assumption for uniquely decipherable codes, as one of the exercises will show, but it simplifies the analysis. In particular, it allows us to compute the following: D e f i n i t i o n 10 The bit rate of a code c for an information source S is the expected number of bits per character in any message from S. Let n ( x l . . "XM) be number of bits in the encoding C(Xl... XM) of the message instance X l ' ' ' X M E A M of length M, where each xm is a letter in the alphabet A used by the source S. Since the code is static, n ( x l . . . XM) = n(xl) + ' ' - + n(XM). Since the letters in a message from this source are independent, P r ( x l . . . XM) = P r ( x l ) . . . Pr(xM). The expected number of bits RM = RM(S, c) in a message of length M is therefore
/:~M -- E ?~(Xl""" XM)Pr(xl... XM)
AM
--
E
E
xl EAAM-1
[?~(Xl)-~-?~(X2"'" XM)]Pr(Xl) Pr(x2... XM)
-+-(x~A pr(xl)) (A~M ln(X2"''XM)Pr(x2"''XM)) " The sums without n are both 1, since Pr is a probability function, so we get a recursive formula RM =/~1 -t-/~M-1, where
/~1 -- E ?~(X)Pr(x) - E nxPx.
xCA
xcA
(6.3)
Here nx is the bit length of the codeword c(x), and Pz is the occurrence probability of letter x. But the recurrence is easy to solve by induction: /~M = M R1, so the expected number of bits per character in a c-coded message of any length is just R1. W i t h our independence assumptions, the one and only way to reduce the bit rate is to match the bit lengths {nx} to the occurrence probabilities {px}. We will save bits on frequently occurring letters and spend them on rare characters, thereby reducing the average cost. Lemma 6.5, proved below, shows that the following quantity is a sharp lower bound for this minimal average bit length per character:
H(p) def E
1 Px log2 - - ,
xEA
Px
(6.4)
where Px is the occurrence probability of letter x. We evaluate 0 log(l/0) de_f 0 if Px = O. H(p) is called the entropy of the message. It applies to all replacement
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
188
alphabets, so no m a t t e r how the original message is translated into codewords, the new version will still have the same occurrence probabilities p = {Px : x E A} and thus the same entropy H(p). Hence, entropy measures the m i n i m u m number of bits per character needed to distinguish among all messages with occurrence probabilities p, t h a t is, the information contained in one such message. Quantity 6.4 is also called the first order entropy, from the assumption t h a t individual characters in the message are independent. Second order entropy counts the occurrence probability of pairs of characters, third order entropy t h a t of triples, and so on. Higher-order entropies measure the information cost of messages wherein letters are partially predictable from their predecessors, namely for which the independence assumption fails.
Optimal coding efficiency The expected number of bits per character needed by a uniquely decipherable (binary) code for a message in alphabet A is the sum
Epxnx,
(6.5)
xEA
where Px is the occurrence probability of letter x in the message, and nx is the number of bits in the codeword for x. This is also called the bit rate of the code. The efficient coding problem for an alphabet A with probabilities p - {px " x E A} is the problem of finding a set of nonnegative integers {nx "x E A} minimizing bit rate under the constraint E 2-nx -< 1. (6.6) xEA
L e m m a 6.3 For any finite set of nonnegative probabilities {Px " x E A}, a solution exists to the efficient coding problem.
Proof:
Suppose that A' c
A indexes the strictly positive probabilities, with
min{px • z E A'} d~f p, > 0 being the smallest. satisfy
E xEA
nxPx - E
def
nxpx -
E
Any set { n , • z E A} must t
nxPx,
xEA I
so it suffices to show t h a t the latter sum over A t has a minimum t h a t satisfies the constraint in Equation 6.6. P u t d = ~ t 2_nx" Since A t is finite, there is a bounded set of positive integers {n~x • x E A t} for which d < 1. For example, it works to take n xt _ n t f o r a l l x E A t, where n t is the least integer greater than the base-2 logarithm of the number of to be the bit rate of this starting set of codeword elements of A. Define d t - ~ t nxPx t lengths. If nx > dt/p t for all x E A t , then ~-~t nxpx > d t will exceed the starting set bit rate. Thus the minimum of ~-~t nxPx lies in the finite collection of sets {nx : x E A t}
6.1.
INFORMATION
189
SOURCE CODING
for which 0 <_ nx <_ d~/p ~ at every x E A ~. It can be found by searching the list and checking the constraint. If there are no zero probabilities, the solution is the minimizing set that satisfies 2 -nx _< 1. If some of the probabilities are zero, the solution is the minimizer that satisfies ~ 2 -n~ < 1, taking large enough integers nx for all the irrelevant x~A'toget~2 -n~ < 1 . [] Once it is known that a solution exists, efficient algorithms may be used to find it. L e m m a 6.2 implies that if A has a uniquely decipherable code with given codeword lengths, it also has a prefix code with the same set of codeword lengths. Hence, a prefix code for A can always be found which is just as efficient as any uniquely decipherable code for A. The optimization problem for prefix codes is easier to solve because of their correspondence with binary trees. Before constructing a solution to the efficient coding problem, we show that the entropy H(p), defined in Equation 6.4, gives a sharp lower bound for the bit rate of Equation 6.5. We start with an inequality provable by elementary calculus: Lemma
6.4 Suppose p -
{px " x E A } and q - {qx " x E A } satisfy
O < px,qx < l
and
~
px - ~
xEA
qx - 1 .
xEA
Namely, p and q are two occurrence probabilities f o r an alphabet A. Then
Z xlo xEA
(1) Px
xEA
with equality if and only if Px - qx f o r all x E A. Proof." The graph of log t lies below its tangent line at t - 1, so log t _< t - 1, with equality if and only if t - 1. But then log(qx/Px) <_ (qz/Pz) - 1 with equality if and only if Px - qx. Multiplying by Px and summing over x E A yields
~-'~ Pz log qx _< ~ xEA
Px
(qx-Px)--O,
xEA
~ ~-~ Px log 1--- _< ~-'~ Pz log 1-xEA
Px
xEA
with equality if and only if Px = qx for all x E A.
qx
[]
Since log 2 x = (log x ) / ( l o g 2 ) for every x > 0, L e m m a 6.4 holds for log 2 as well: we just divide the inequality by the positive constant log 2. T h a t imposes a lower bound for the average number of bits per character of any prefix code: Lemma
6.5 For any prefix code with codeword lengths {nx : x E A } , pxnx > H(p). xEA
Equality holds if and only if Px - 2 -nx for each x E A.
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
190
Proof: P u t W ~-~xEA 2-n~ , a n d define qx - 2 - n ~ / w E x E A qx -- 1. By L e m m a 6.4,
H(p)- Epxlog2 xCA
--1 < Z p x l o g 2 Px
for each x C A. T h e n
1 qx
xCA
with equality if a n d only if qx - Px for all x E A. C o n t i n u i n g the calculation,
1 Px ltx,
qx
xCA
xEA
xEA
xCA
since W < 1 by L e m m a 6.2, so log 2 W < 0. E q u a l i t y holds here if a n d only if W - 1, so it holds t h r o u g h o u t if a n d only if Px - qx - 2 -n~ for all x E A. []
Existence of almost optimal codes A second i m p o r t a n t preliminary observation is t h a t a prefix code can get arbitrarily close to the lower b o u n d in L e m m a 6.5. W h a t makes this tricky is t h a t a b i n a r y prefix code must use at least one bit per letter, while H(p) can be less t h a n one. This obstacle results in the following weak u p p e r bound:
Lemma 6.6
There exists a prefix code with codeword lengths {nx " x c A } such
that Z
pxnx < H ( p ) + 1.
xEA
Proof: Let A t c A be t h e letters x with px > 0, a n d let A" c A be those with Px - 0. T h e n A - At t0 A". For each x E A t, let n~ be the unique integer satisfying log 2 (1/Px) < nz < 1 + log 2 (1/Px). Then,
E 2-~x< Z 2-1°g2(1/P~)-- E px -- Z P x - 1. xCA ~
xEA ~
xEA ~
xcA
For each x C A", we m a y take nx large e n o u g h so t h a t
E 2-n~-
xEA t
::a Z2-nx_
By L e m m a 6.2, there is a prefix code with codeword lengths {nx " z c A}. B u t
xEA
xCA'
xGA'
Px
so this prefix code has a bit rate below the claimed estimate.
[]
6.1. I N F O R M A T I O N S O U R C E C O D I N G
191
Figure 6.5: Propagating leaf weights back to the root of a binary tree.
Unfortunately, the upper bound of L e m m a 6.6 is sharp. The trivial example A - {a}, with Pa - 1, has H(p) - O , but we must have na _> 1 so t h a t p~na >_ 1 H(p) + 1. At least one bit must be t r a n s m i t t e d per letter to tell the receiver that something is there. One extra bit per character is a heavy price, but it can be reduced. The trick is to code multiple letters so t h a t the excess per character is made arbitrarily small. Consider an indefinitely long message in which successive characters are independent and identically distributed random variables taking values in the alphabet A with occurrence probabilities p - {p(x) • x c A}. Then the probability of a particular sequence XlX2 . . . x 8 of s characters appearing in the message is p ( x l x 2 . . . X s ) - p ( x l ) p ( x 2 ) . . . p ( X s ) . It is a straightforward exercise to prove t h a t ifp~ - { p ( x l x 2 . . . x ~ ) " ( X l , X 2 , . . . , x s ) c A~}, then H ( p ~) - sH(p), and that if a code uses N bits on average per block of s letters, then it uses N / s bits per letter on average. L e m m a 6.6 implies t h a t there is a prefix code for blocks of s characters satisfying N <_ H ( p ~) + 1 - sH(p) + 1, so N / s <_ H(p) + 1Is. Such an argument proves the following result" L e m m a 6.7 Let e > 0 be given, and let s > 1/c be an integer. Then there is a prefix code for blocks of s characters which uses fewer than H(p) + e bits per character. []
6.1.3
Huffman's algorithm
Bit rate may be abstracted into weighted depth ~-~xcA pxnx, defined for any tree with a root and with leaves x E A each having a generation number nx and a nonnegative weight Px. Weighted depth gives the bit rate of a code if the weights {Px " x E A} are normalized like occurrence probabilities, with ~ x e A P x -- 1. We will construct a minimal bit rate code by building a binary tree of minimal weighted depth, using D. A. Huffman's weight propagation algorithm. Leaf weights are propagated back to the root as each interior vertex gets the sum of its children's weights, starting with the deepest non-leaf vertices. Figure 6.5 shows one example. We prove by induction on the depth of the tree t h a t weight propagation gives each vertex the sum of the weights of its descendent leaves. Weight propagation is equivalent to filling each non-leaf vertex along the unique path from the root to a leaf with the leaf's weight, then superposing or adding
192
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
Figure 6.6: Binary trees weighted along root-to-leaf paths.
together all the weights. The resulting weight at each vertex is evidently the sum of its leaf descendent 's weights. For example, Figure 6.6 shows five partially filled copies of the same tree which may be superposed to give the propagated tree of Figure 6.5. In the superposed tree, a weight Px from a leaf x at generation nx appears 1 + nx times, so adding up the weights at all the vertices gives pxnx.
Epx(I+nx)-EPx+E xEA
xcA
xEA
But ExCA Px is the weight at the root after propagation, so we have:
L e m m a 6.8 The weighted depth of a binary tree equals the sum of the weights at all vertices except the root, after propagation. [] Requiring minimal weighted depth constrains the shape of a binary tree: L e m m a 6.9 Suppose that the leaf weights p l , . . . ,PN are nonnegative. Then a binary tree of minimal weighted depth with these weights at its N leaves must have both a son and a daughter at every non-leaf vertex.
Proof." Any non-leaf vertex with just one child may be removed and replaced by the child, shortening some paths and creating a new binary tree with smaller weighted depth. [] Lemma 6.9 implies that the minimal weighted depth tree must be an extended binary tree with N leaves. These are themselves binary trees with 2N + 1 vertices, (4N+2)! and there are fewer than (2N+1)!(2N÷2)! of them by Equation 6.1. Hence to find the most efficient prefix code is at worst a search for minimal weighted depth through this many trees. However, Huffman found a more efficient method based on the following observation: L e m m a 6.10 Given leaf weights 0 <_ pl <_ p2 < "'" < PN, there is a minimal weighted depth binary tree in which the lightest leaves, those weighted pl and p2, share a parent.
6.1.
INFORMATION
SOURCE CODING
193
Figure 6.7: A minimal weighted depth tree whose lightest leaves are siblings. Proof." Lemma 6.3 insures that at least one minimal weighted depth tree exists with the given leaf weights. We show that it or another minimal tree must contain the subtree depicted in Figure 6.7. Consider a non-leaf vertex with deepest generation number in a binary tree of minimal weighted depth. Its two children must be leaf vertices of maximal depth, so exchanging their weights with Pl and P2, which are lightest, does not increase the weighted depth, and gives a minimal weighted depth tree with the required subtree. [:] A Huffrnan code is a prefix code for N > 1 letters with occurrence probabilities p l , p 2 , . . . ,PN. Huffman's algorithm builds a binary Huffrnan tree from its N leaf vertices, each of which is assigned a weight Pk. To construct the tree, the parent of each vertex is specified recursively, beginning with the leaves:
Huffman's Algorithm, Recursive Version HR-1.
Sort and relabel the weights so that 0 < Pl <_ P2 < "'" < PN.
HR-2.
If N - 2, return a 3-vertex tree with root x0 weighted Pl + P2, a son leaf Xl weighted Pl, and a daughter leaf x2 weighted p2.
HR-3.
Otherwise, construct a Huffman tree with the N - 1 leaf weights (pl + P2), P3, . . . , PN. Then make the leaf weighted (pl + p2) into a parent interior vertex by appending a son leaf weighted pl and a daughter leaf weighted P2. Return the appended tree.
Recursion step HR-3 is encountered at most N - 2 times. Equivalently, the Huffman tree may be constructed with a loop. Until its parent is determined, call a vertex an orphan. We start by creating N orphan vertices with weights P l , . . . , P N . Then we proceed through the following:
Huffman's Algorithm, Loop Version HL-1.
Find the orphan vertex x with the smallest weight Px. Use some convention to break ties.
HL-2.
Find the orphan vertex y with the next smallest weight py, again breaking ties by some convention. It is possible that px - p y , but of course x ~: y.
HL-3.
Create a new orphan vertex z, give it weight Pz - Px + Py, and make z the common parent of vertices x and y which are no longer orphans.
HL-4.
If there is only one orphan vertex left, then call it the root and terminate. Otherwise, return to step HL-1.
C H A P T E R 6. R E D U N D A N C Y AND I N F O R M A T I O N
194
x EA
p(x)
a b c d
1/2 1/4 1/8 1/8 -
C(x) ]
0.5 - 0.100 (base 2) 0.25 - 0.010 (base 2) 0.125 - 0.001 (base 2) 0.125 - 0.001 (base 2)
1 01 001 000
Table 6.1: Example Huffman code C for a four-letter alphabet.
~
]p(a)=0.5 ]p(b)=0:25 ] p(c)=O.1251 "]p(d)=O.1251
~
@ ~
[p(a)=0.5 _ ~ . ~ p(b)=0.25 ] p(c)=O.125 I p(d)=O.1251
p(a)=0"5 I p(b)=0.25 I p(c)=O.125] p(d)=O.1251
Figure 6.8: Three steps in building a Huffman tree. For example, let A = {a, b, c,d} be a four-letter alphabet. Table 6.1 shows one Huffman code chosen for a particular message written in this alphabet with occurrence probabilities p(a, b, c, d) = (0.5, 0.25, 0.125, 0.125). Figure 6.8 shows the three passes through the loop that built the Huffman tree. Notice that the code of Table 6.1 achieves the the entropy of the occurrence probabilities p, the minimum expected number of bits per letter for the message:
H(p)-
~)lP(x)log 2
1
- 1.1+
1
.2+
1
.3+
1
.3-175
That is because the codeword bit lengths match the occurrence probabilities. It is not always possible to achieve the minimum, though, since codewords must have a positive integer number of bits whereas the probabilities need not be integer powers of 2. Note too that Huffman codes are not uniquely determined. For the example code, exchanging the codewords for c and d gives another code. Indeed, exchanging 1 and 0 in each codeword of any binary code gives another code with the same bit rate.
Analysis of Huffman's algorithm With each pass through the loop, or each recursion, the number of orphans and weights decreases by one, so either algorithm must terminate after N - 1 steps. The sole remaining orphan will be the root and will have weight 1, since it accumulates the sum of all the probabilities pl + . . . q-PN = 1. Each reduction requires finding the two smallest weights among the remaining orphans. If there are k orphans, that costs O(2k) comparison operations, for k = N, N - 1 , . . . , 2. Adding up shows that Huffman's algorithm with N weights requires no more than O ( N 2) operations. It remains to show:
6.1.
INFORMATION
Theorem
SOURCE CODING
195
6.11 A H u f f m a n tree has m i n i m a l weighted depth.
Proof: Suppose that A has N _> 2 letters with occurrence probabilities pl <__p2 _< • " <_ PN. The proof is by induction on N, using the recursive version of Huffman's algorithm. If N - 2, step HR-2 returns the 3-vertex Huffman tree with a root and two leaves. It evidently has the minimal weighted depth 1 - 1 . p l + 1-p2. Now fix N > 2 and suppose that Huffman's algorithm returns a minimal weighted depth tree for any list of N - 1 weights. Step HR-3 of Huffman's algorithm constructs such an (N - 1)-leaf tree with leaf weights (Pl + P2), P3, . . . , PN, Denote its minimal weighted depth by e. Step HR-3 then appends two leaves, weighted Pl and P2, respectively, as son and daughter to the leaf weighted (pl -~-p2), and returns the resulting N-leaf tree. By Lemma 6.8, the weighted depth E of the Huffman tree returned from HR-3 is E - e + pl -t-p2. Now suppose that E t is the minimum weighted depth for the weights p l , . . . , PN. By Lemma 6.10, there is a tree with this weighted depth in which the lightest leaves, weighted pl and p2 because of HR-1, are siblings. Pruning these from their joint parent yields a tree for the N - 1 weights (Pl + P2), P3, . . . , PN with weighted depth e t - E ~ - Pl - p 2 , again computed by Lemma 6.8. Since E ~ _< E and e < e ~, it follows that E - E ~. Hence the returned Huffman tree for the N weights has minimal weighted depth. []
Describing
a Huffman
tree
To transliterate a message instance from alphabet A into its Huffman code, simply replace each letter with its binary codeword. This can be done with a table such as Table 6.1. No commas or other spacers are needed between codewords. However, to recover the message instance from the binary string of concatenated codewords, it is necessary to have the Huffman tree. The encoder that built the tree must transmit it to the receiver for use in decoding, and it should do so economically lest the advantage of Huffman coding be squandered in the cost of describing the tree. One way to transmit the tree is to send the occurrence probabilities tagged with the letters they refer to, then have the receiver build the tree using exactly the same algorithm as the transmitter. For an N-letter alphabet, this side information costs ( B + [log 2 N ] ) x N bits, if we record the probabilities in a B-bit format. Probabilities are typically floating-point numbers, so B might be the rather costly 32 or 64. Also, to get exactly the same Huffman tree in all cases we must use exactly the same arithmetic to compare and add the weights. But arithmetic is not guaranteed to be the same on different computers. It is therefore better to describe a Huffman tree without mentioning the weights that built it. We are aided by Lemma 6.9. A Huffman tree must be an extended binary tree, so with N leaves it will have 2 N - 1 total vertices and depth at most N - 1. 4 4 T h e d e p t h of a Huffman tree is also b o u n d e d by O(log~gN/pl]), where PN and pl are the largest and smallest nonzero occurrence probabilities, respectively. In practice this is often much smaller t h a n N - 1.
196
CHAPTER
6.
REDUNDANCY
AND
root
A
A
B
C
D
E
F
G
H
~
(~15)
~ ~
INFORMATION Code: A=O F-lO B = 110 C= 1,,00
E=11101 0-11110 G= 111110 H = 1111110
(I)
Figure 6.9: Example Huffman trees for a given alphabet and occurrence probabilities. Left: One possibility. Right: Canonical tree, after rearrangement.
The maximum number L of bits in a Huffman codeword is actually the generation number of the leaf with smallest positive weight, since deeper leaves with zero weight give i n a c t i v e codewords that will never be transmitted. A Huffman tree of L small nonnegative thus determines an ordered list M = ( m l , m 2 , . . . , m L ) integers. No integer in this list can be larger than N, the number of letters in the original alphabet. The element m k is both the number of leaf vertices at generation k and the number of active codewords of length k. For the tree of depth L = 3 in Figure 6.3, we have M = (1, 1, 2). Since many equivalent trees will give the same list M, we will choose one of them to be the c a n o n i c a l tree. Our choice is the tree built from a rearrangement of occurrence probabilities such that, at each prefix node, the deeper subtree lies on the right. Figure 6.9 shows one such rearrangement. This convention fixes the sequence of 0s (left turns) and ls (right turns) needed to go from the root to any leaf. Thus there is one and only one canonical Huffman tree for a given L and M. Even given L and M, the Huffman code is not determined. Any permutation of the codewords of equal length k gives a code with the same bit rate, so we must also specify how leaves relate to letters. We thus provide an ordered list A t of the active letters of the alphabet A, giving the order in which they appear in the canonical tree, reading from left to right in increasing depth order. Thus letters am , t for m - m k + 1,. • • , i n k + l , are assigned to the leaves at generation number k in left-to-right order in the canonical tree. If mk = 0, there are no codewords of length k. These three data L, M, A t completely describe the canonical tree and are sufficient to encode and decode all the a c t i v e letters of the alphabet, that is, those whose occurrence probabilities are nonzero. For example, the canonical tree on the right side of Figure 6.9 is uniquely described by L = 7, M = (1, 1, 1, 0, 3, 1, 1), and A t = a, f , b,, ced, g, h. Commas in A t and M correspond. A useful trick is to append an extra letter to the alphabet, with occurrence probability zero. This will guarantee that no active codeword consists of all 1 bits. It makes the decoding algorithm more robust, as the bit string of codewords can
(i.2. E R R O R C O R R E C T I O N
AND DETECTION
197
I)e end-padded with 1 bits t h a t cannot be confused with extra letters. An inactive letter adds no cost to the canonical Huffman tree description, but it does make the resulting code less emcient by an amount equal to the smallest nonzero occurrence probability. The letter i plays this special role in Figure 6.9, since its occurrence probability is 0, and it is not listed in A t.
Error C o r r e c t i o n a n d D e t e c t i o n
6.2
Suppose that a bit in a stored or t r a n s m i t t e d binary string flips to the other value: from 0 to i or from 1 to 0. This may result from some physical process such as a disk crash or line noise. A fixed-length encoding with a single flipped bit will decode into a message instance containing a single incorrect letter, with all the letters before and after it being correct. The shorter, variable-length Huffman encoding of the same message instance might suffer much greater damage. The flipped bit may divert the decoder to a deeper or shallower subtree, so t h a t the wrong codeword and length will be read. The decoder will then try to decode the next letter starting in the middle of a codeword. The misalignment could even propagate so t h a t all letters after the bit flip will be misread. We are willing to pay some cost in extra bits to detect bit flips, as long as it does not negate the savings from redundancy removal. We will see t h a t with a very few extra bits we may buy much more confidence in the correctness of a bit string. In some cases, a few extra bits even buy us the location of bit flips and allow us to correct them.
6.2.1
Parity bits
E x t r a bits can be added to a codeword bit string to detect errors. If seven bits within an eight-bit byte define an ASCII character, the extra bit can be set to zero if there are evenly many ones among the first seven bits, or set to one otherwise. Then the total number of one-bits in the string will always be even. Transmitter and receiver can agree to use this even parity condition to increase confidence in the correctness of the received data. How much confidence is gained? To analyze this procedure in somewhat more generality, suppose t h a t a bit string consists of N independent d a t a bits plus one parity bit. Let p be the probability t h a t a bit is flipped to the wrong value during transmission. Then the probability t h a t exactly k d a t a bits are flipped is (~r)pk(1p ) N - k . It m a t t e r s whether k is even or odd, and if even, whether k is zero, so we define the sets E = {0, 2, 4 , . . . } and O = {1, 3, 5 , . . . } of even and odd nonnegative integers, and put E + = E \ {0} = {2, 4, 6 , . . . } . The receiver gets N + 1 bits, and there are four possible outcomes: A l l ' s well. The parity is consistent and the d a t a bits are all correct. Probability: Paw - (1 - p ) N + l . F a l s e a l a r m . The parity is inconsistent but the d a t a bits are all correct. Probability" P/a - P(1 - p)N.
CHAPTER 6. RED UNDANCY AND INFORMATION
198
D e t e c t e d e r r o r . The parity is inconsistent and at least one d a t a bit is incorrect. Probability:
Pd~--(1--p)E (N)pk(1-p)N-k+pE kEO
(Nk)Pk(1--p)N-k
HEE+
U n d e t e c t e d e r r o r . The parity is consistent but at h'ast one d a t a bit is incorrect. Probability:
Pue - P E (Nk)pk(1--p)N-k ÷ (1--P) E (Nk)Pk(1--p)N-k kCO
kCE+
The sums may be evaluated by algebra. Note that
E(Nk)Pk(1--p)N-k--(p+l--p)N--1 k
We may break the sum into even-index and odd-index parts:
x - E
pk(1--p)N-k; l--x-- E
kCE
Pk(1--P)N - k
•
(6.7)
kCO
But then, x-
(l-x)
-- E (Nk)pk(1--p)N-k--E (Nk)Pk(1--p)N-k kCE
kEO
= Z (Nk)(--P)k(1--p)N-k+ E (Nk)(--P)k(1--p)N-k kEE
" kCO
= E(Nk)(-p)k(l-p) N-k
=-(1-2p)
N.
k
Solving for x gives x--
1 + (1
-
2p)N
2
;
1 --(1--2p) N
l-x--
2
and the probability t h a t the d a t a Thus, Pu¢ - - 1 1 1 -t- (1 - 2 p ) N + I - 2(1 - p ) N + l ] bits are all correct given that the parity is correct is
Paw Paw -Jr-Rue
2(1 _ p)N+l 1 + (1 - 2p) N+I"
p)N]
Pale -~
- - 1 [ 1 - - (1 - 2 p ) N + I - 2p(1 and the probability t h a t all of the Likewise, data bits are actually correct given that the received codeword has bad parity is
Pfa Pde -k-Pfa
2p(1
_p)N
1 - (1 - 2p) N+I"
6.2. ERROR CORRECTION AND DETECTION
199
1
1.175[
0.8
1"21
1.15~
\ 0 ~
'
. . . . . . . . . . . . . . . . . . . . 0.2 0.4 0.6
0.8
.
0
1
0.i
0.2
.
.
.
.
0.3
.
.
.
.
0.4
.
.... I ~ .... I .................
.
0.5
0
0.i
0.2
0.3
0.4
0.5
Figure 6.10: Parity checking performance with 7 data bits, as a function of bit flip probability p. Left" Data confidence increase. Center: Undetected error rate reduction. Right" False alarm rate increase. The blind probability that all N data bits are correct is ( 1 - p)N. By accepting only strings with consistent parity, our confidence in the data's correctness is increased by a factor of 2(1 - p ) / ( 1 + (1 - 2p)N+l), which is plotted for N - 7 and 0 < p < 1 at left in Figure 6.10. In this case, confidence is increased by the largest factor for bit flip probabilities near a decidedly unsatisfactory 0.2. When p > 0.5, parity checking actually reduces confidence in the data! In the limit p ~ 0, where the data is pretty reliable even without parity checking, there is not much room for increased confidence, so error-rate reduction gives a more meaningful figure of merit. Parity checking multiplies the blind undetected error rate by a factor of [ 1 - l@-'~(1----2--p-~ 2(1--p)N+Iykl ]/[1 - (1 - p) N] ; this is plotted for N - 7 and 0 < p < 0.5 at the center of Figure 6.10. For small values of p, one parity bit reduces the undetected error rate by a factor proportional to p, as shown by Taylor's formula: 1-
2(1--p)N+l 1q-(1--2p) N+I
1 + (1
1--(l--p) N
-
2p) N+I
-
2(1
-p)N+l
[1 + (1 - 2p)N+l][1 --(1 --p)N] 2(N+1 ~, 2 ) p2 + O ( p 3 ) X+l =
[2 -
O(p)][;N +
P'2
as p - + 0. Parity checking slows transmission not only because N + 1 bits need to be transmitted for each N bits of data, but because false alarms occasionally cause good data to be discarded. False alarms increase the volume of rejected strings by Psa
2p(1-p) N
a factor of 1 + PSa+P~e = 1 + l _ ( l _ 2 p ) N + 1 . This function is plotted for N - 7 and 0 < p < 0.5 at right in Figure 6.10. As p ~ 0, Taylor expansions show that the volume increase behaves like 2p(1 - p)N 1 - ( 1 - 2p) N+I
z
2p + O(p 2) 2(N + 1)p + O(p 2)
1 N + 1'
This is to be expected, since for tiny p it is very unlikely that more than one bit in a string will be flipped, and the parity bit has one chance in (N + 1) of being the one, resulting in a false alarm. However, only the volume of bad-parity data
CHAPTER 6. REDUNDANCY AND INFORMATION
200
is increased by false alarms, and since these occur with probability Pfa + Pac, the expected cost of false alarms is an average increase of Pfa ~ P bits per string, for p~0. A single parity bit can detect one bit flip in a string of any length N, but this observation is misleading. For any fixed bit-flip probability p > 0, the undetected error probability Puc ~ ~1 as N ~ oc simply because the chance of a double bit flip becomes very great. Crossed parity checks Parity bits can locate errors, as well as detect their presence. Suppose t h a t n × n "data" bits are arranged in a square array of n columns and n rows, and 2n parity bits are appended, one to each column and one to each row. The value of each parity bit is chosen to make its row or column sum even. Each data bit is checked by two parity bits, and this cross-checking gives position information when something goes wrong. Any single bit flip in the data will cause one row and one column parity test to fail, and will indicate the location of the bad data bit. A single flipped parity bit causes an inconsistency that cannot result from a flipped data bit, so it need not cause a false alarm. If exactly two data bits get flipped, then either two or four parity bits will be inconsistent, but it will not be possible to determine which data bits were bad. Thus, this scheme gives one bit error correction and two bit error detection. W h a t is the probability of an undetected error? For this to happen, all parity checks must be consistent despite some flipped data bits. There is no way for this to happen unless at least three of the N -- n 2 4- 2n bits are flipped, and only very special arrangements of three or more flips actually results in an undetected error. Let U(N,k) be the number of k-bit flips among N total bits that results in an undetected error. Then 0 <_ U(N, k) _< (N), and N
N
-- E U(N, k)pk(1 - p)X-k <_ E k=3
( ? ~ ) p k ( 1 - p)X-k.
k=3
For fixed N, P,~ = O(p 3) as p ~ 0. Such two-dimensional parity checking costs 2n parity bits for n 2 data bits, or 2/n. An obvious generalization is to arrange the data into an n × n × n cube with 3n 2 parity bits along three of the faces. To get an undetected error in the threedimensional setup, at least four bits must be flipped, so P,~ = O(p 4) as p ~ 0. In many cases, though, more data bit flips can be detected and even corrected. The cost is 3/n parity bits per data bit. The parity information should be more reliable than the data, if it will be used for correction: the parity bits may be protected with 6n parity bits of their own, along the data cube's edges. Generalizing further, n d data bits may be arranged in a d-dimensional array with dn d-1 parity bits arranged along the coordinate hyperplanes. This will always detect d bit flips, so P~¢ = O(pd+l), at a cost of d/n parity bits per data bit.
6.2. E R R O R C O R R E C T I O N A N D D E T E C T I O N
201
Thus, for linear growth in the amount of parity overhead, we obtain geometric decreases in undetected error probability. In addition, for large d, the many-bit-flip combinations giving undetected errors become exceedingly rare. 6.2.2
Hamming
codes
Parity checking and cross-checking work by using multiple parity bits to check overlapping subsets of data bits. R. W. Hamming invented a code which identifies the location of a single bad bit by giving its index in binary. Parity bits are sprinkled throughout the codeword and are themselves included in the parity checking. To see how this works, consider an example in which four data bits are protected with three parity bits. The data bits are in locations 3, 5, 6, and 7, counting from the rightmost bit, which is in location 1. The parity bits are at locations 1, 2, and 4. The parity bit at 1 is chosen so that bits 1, 3, 5, and 7 add up to 0 modulo 2. Parity bit 2 is chosen so that bits 2, 3, 6, and 7 add up to 0 modulo 2, and parity bit 4 is chosen so that bits 4, 5, 6, and 7 add up to 0 modulo 2. Formally, parity bit 2p is chosen so that it makes all those bits whose location index contains 1 x 2p add up to 0 modulo 2, for p = 0, 1, 2. Now suppose that a single bit, data or parity, is flipped in this 7-bit codeword. Let b0 be the sum of bits 1, 3, 5, and 7 modulo 2, bl is the sum of bits 2, 3, 6, and 7 modulo 2, and b2 is the sum of bits 4, 5, 6, and 7 modulo 2. Then the flipped bit is at position I = b02 ° + bl 21 + b222, counting from the rightmost bit. Assuming that at most one bit is flipped, the above provides an error correction method. If I = 0, then all the parities are OK and there is no error, otherwise bit I is wrong and should be flipped back to its correct value. Unfortunately, the decoding gives a wrong answer if two or more bits are flipped, so the m e t h o d is prone to undetected errors. Linear codes Hamming's code is an example of a linear code. The 16 codewords making up all combinations of four data bits are just linear combinations of the four basic codewords given in Table 6.2, and the codewords are constructed using linearity: c(x + y) = c(x) + c(y), for any four-bit strings x, y. For example, the codeword for the data vector 1010 = d3 + d l is c(d3 + d l ) = 1001011+0011001 = 1010010. Coordinates are added using arithmetic modulo 2, which is implemented as the bitwise exclusive-or operator in the C programming language. It is straightforward to verify that the parity conditions are preserved. Linear codes are decoded by linear transformations. We note that the four basic codewords 1001011, 0101010, 0011001, and 0000111 are orthogonal with respect to the usual inner product, if we use addition modulo 2 to add things up. Thus, if we let C be the matrix whose rows are the four basic codewords, then applying the
202
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N Data vector d3 d2 dl do
= = = =
1000 0100 0010 0001
Codeword
7
6
5
4*
3
2*
1"
C3 - - C ( 1 0 0 0 )
1 0 0 0
0 1 0 0
0 0 1 0
1 1 1 0
0 0 0 1
1 1 0 1
1 0 1 1
c2 = c(0100) C l = c(0010) co = c (0001)
Table 6.2: Basis for Hamming's code with four data and three parity(*) bits. matrix C to a received codeword, written as a column vector, produces the four expansion coefficients of the data vector:
it2//1001011/ c2
C
__.
_
Cl
CO
0 0 0
1 0 0
0 1 0
1 1 0
0 0 1
1 0 1
0 1 1
"
However, we must first fix any errors in the received codeword. To do that, we generate the repair vector b = (b2, bl, bo) by applying the following matrix to the received codeword:
(b2) (1
B--
bl b0
-
1 1
1 1 0 0 0)
1 0
1 1
0 0
1 1
0 0
0 1
If b - O, then all is well. Otherwise, interpreting nonzero b as a three-digit binary number gives the position of the single flipped bit. We flip it back and then apply C to decode. Notice that {Co, Cl, c2, c3} U{b0, bl, b2} forms an orthogonal basis for the space {0, 1} 7 of seven-bit codewords. We find the error by orthogonal projection onto a three-bit subspace, and then after correcting it find the data by orthogonal projection onto a complementary four-bit subspace. Hamming's algorithm generalizes to longer codewords. Reserving index 0 to mean "no error" leaves 2 P - 1 total bits that can be protected by P parity bits, leaving 2 g - P - 1 data bits. Parity bits are placed at locations 2p, 0 _< p < P, counting from rightmost bit 1. The parity bit at 2p is chosen so that the sum of all codeword bits whose locations contain 1 × 2p add up to 0 modulo 2. Hamming's algorithm divides the codeword bits into P subsets of 2 P-1 bits each. Computing the parity of the subsets gives a P-bit binary number which, if nonzero, locates the single bit flip in the codeword. The overhead is P parity bits for 2 P - P - 1 data bits; this overhead becomes negligible very fast as P --+ c~. Thus, as for one-parity-bit single-error detection, single-error correction costs arbitrarily little for long codewords. Any single-bit correction code must add at least log2 N bits of overhead to N bits of data, since that is the least information needed to locate a flipped bit. Hamming's algorithm is only one of many ways of inserting this overhead, but it gives an elegant and simple decoding algorithm, and simultaneously protects both parity and data bits.
6.2.
203
ERROR CORRECTION AND DETECTION
Hamming distance Can k > 1 bit flips be corrected? Hamming used a distance function on bit strings to make this question geometric. For integer k > 1, there is a set of codewords that are sufficiently distant from each other so that flipping k bits in any one of t h e m still leaves the correct codeword as the nearest. This restoration to the nearest codeword error correction scheme fixes up to k flipped bits. The H a m m i n g distance function dist counts the number of bits at which two bit strings of equal length differ. For example, dist(010011101, 010101110) = 4. Two bit strings are identical if and only if the distance between t h e m is zero. For each string c of N bits, we may count the number of codewords at each H a m m i n g distance k from c. There are (N) of them, corresponding to the number of ways we may choose the k bits that differ. The H a m m i n g sphere of radius r centered at a bit string c of length N is defined to be the set of bit strings d of length N satisfying dist(c, d) <_ r. The volume enclosed by the H a m m i n g sphere is the total number of bit strings within it, and is found by adding up the counts for distances 0, 1 , . . . , r: VolN(r ) de f ~--~ ( J ~ ) . k=0
(6.8)
Thus VolN(0) -- 1 for every N >_ 1, and VolN(r) -- 2 N for every r >_ N. We may visualize bit strings as the vertices of an N-dimensional unit hypercube. The vertex at the origin corresponds to 0 0 . . . 0, the string of N zero bits, and the vertex farthest from the origin, in both the H a m m i n g and the Euclidean distance, corresponds to the string 1 1 . . . 1 of N ones. Edges connect adjacent vertices, such as 0 0 . . . 0 and 1 0 . . . 0 on the x-axis, if and only if their H a m m i n g distance is 1. Since each vertex in this N-cube has edges to N other vertices, we may estimate VolN(r) <__ 1 + N + . . . + N r < N r+l.
(6.9)
This is very crude, but it is accurate enough for our purposes. 5 The distance between a codeword c and a set C' of equal-length bit strings is dist(c, C') def min{dist(c, c')" c' e C'}. Thus c e C' if and only if dist(c, C') - 0. Likewise, the distance between two sets C and C' of equal-length bit strings is dist(C, C') def min{dist(c,c') • c C C,c' C C'}, with C N C' ~ q) if and only if dist(C, C') - 0. Now suppose we take the set of N-bit strings and select from it a collection of disjoint Hamming spheres of radius r. If we use the bit strings in the centers of those spheres as codewords, then we will be able to correct up to r bit flips by restoration to the nearest codeword. The simplest example of this idea is the repetition code. Suppose a positive integer r is given. We may encode the two-letter alphabet {0, 1 } by 2r + 1 repetitions: 2r+1 c(0) -- 0 0 . . . 0 ;
2r+1 c(1) -- 1 1 . - . 1.
5The solution to Exercise 3 of Chapter 4 provides the sharp estimate VolN(r) -- O(Nr).
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
204
These two codewords are diagonally opposite corners of a (2r + 1)-dimensional unit hypercube, with e(0) at the origin. T h e n dist(c(0), c(1)) = 2r + 1, so we can correct r or fewer flipped bits by accepting the majority. This is a linear code, and the decoding algorithm consists of applying the matrix C = (1 1 . . . 1), using ordinary real arithmetic. If the single scalar o u t p u t is less t h a n r, we record 0 as the received bit. If the o u t p u t is r + 1 or greater, we record 1. T h e repetition code is terribly inemcient, however. It costs 2r parity bits to protect just one d a t a bit, although they protect themselves at the same time. T h e inefficiency stems from the small n u m b e r of codewords. If there are M = 2 "~ codewords in the code, then we may t r a n s m i t m = log 2 M d a t a bits per codeword. If the codewords are N bits long, then we may say t h a t there are p = N - m parity bits included in each. This is a reasonable cost assessment even if we choose not to identify particular bits as parity bits or d a t a bits. One way to increase efficiency is therefore to increase the n u m b e r of codewords t h a t are protected against r or fewer flipped bits. We must control the growth in codeword bit length N as we build larger codes, so t h a t p = N - m, or at least p / N , tends to some finite limit. In fact, there are codes for which p / N ~ 0 as N ~ oc. W i t h our h y p e r c u b e intuition, we may describe their construction as follows: T h e o r e m 6.12 (E. N. Gilbert, 1952) For any positive integer r and any ~ > O, there is an integer N and a binary code consisting of 2 "~ N - b i t codewords such that
1.
restoration to the nearest codeword corrects up to r bit flips; we may transmit m > (1 - c ) N data bits per codeword, with fewer than e N of the bits being needed for error correction.
Proof: Suppose we choose codewords from the set of all N - b i t strings, which we imagine as the vertices of the unit N-cube. We begin with the origin, and remove the VolN(2r) vertices within H a m m i n g distance 2r of it. For the second and subsequent codewords, we choose one of the remaining vertices and remove its H a m m i n g sphere o f V o l N ( 2 r ) v e r t i c e s . We may do this at least M = [2N/VolN(2r)J times, since there were 2 N bit strings to begin with. The M codeword bit strings thus chosen will be our code. It evidently satisfies condition 1, as each codeword is at least H a m m i n g distance 2r + 1 away from all the others. We now count M using Inequality 6.9:
12 1
M - 2 m _> N2r+ 1 Since (log 2 N ) / N (1 - c)X.
2N
> N2r+ 2,
=~ m > N
[
1 - (2r + 2) l°g2NN-
~ 0 as N -~ ec, we may choose N large enough so t h a t m _> []
Note t h a t some bit strings might be outside the H a m m i n g spheres of the codewords generated by T h e o r e m 6.12. If the receiver gets one of these, which cannot be decoded, it may declare a detected error and request retransmission.
6.2. E R R O R C O R R E C T I O N AND D E T E C T I O N
205
Gilbert's coding theorem is constructive, but it does not produce a linear code in general. It also does not provide a decoding algorithm other than a table search through a possibly large number of codeword strings. Although the fraction of parity bits needed to correct up to r bit flips can be made arbitrarily small, the price is using long codewords which are likelier to have multiple bit errors. There is also a lower bound on the absolute number of parity bits needed to correct up to r bit flips, generalizing the 1-bit correction bound mentioned earlier: 6.13 Any N-bit code that can correct r bit flips by restoration to the nearest codeword must consume at least p - log 2 VolN(r) bits of each co&word for parity information. Theorem
Proof: Let m be the number of data bits, so M - 2 ~ is the number of codewords and p - N - m is the number of parity bits. Each codeword is the center of a Hamming sphere containing VolN(r) vertices. These spheres are disjoint, and the union of all of them makes up at most 2 N vertices. Thus MVolN(r) <_ 2 N, and so p - N - rn > log 2 VolN(r). [] Note that log 2 VolN(r) < (r -+- 1) log 2 N -- O(log N) by Inequality 6.9.
6.2.3
Checksums
and
cyclic
redundancy
codes
An old method for checking arithmetic, which was once taught in elementary schools, is casting out nines. We observe that if d n " " dido is the base-ten representation of the integer x > 0, where 0 _< dk < 10 for all k - 0, 1 , . . . , n and x -- dn x 10 ~ + . . . + dl × 10 + do,
(6.10)
then z - d~ + . . . + do
(mod 9).
(6.11)
In other words, the sum of the decimal digits of x has the same remainder as x after division by 9. This is proved using the congruence 10 - 1 (mod 9), which implies 10 k - 1 (mod 9) for every integer k > 0, to reduce Equation 6.10. We may write x' - d n + ' . . + do and expand x' - d ' , x 10 n' + . . . + d~ and apply Equation 6.11 again to get x - x' - x" . . . . (rood 9). We continue until we have a single digit, for then the values stop changing. Let c - cg(x) be this digit. For example, c 9 ( 1 8 7 2 ) - 9 and c9(22 8 8 3 ) - 5. This digit is called the checksum. In the C programming language, its formula would be c9(x) - x%9, although the limited integer sizes in most common computers limit the domain to numbers x with ten or fewer decimal digits. However, the special properties of the modulus 9 allow us to compute cg(x) for much larger x presented as a string of decimal digits, using the following algorithm:
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
206
Casting-Out-Nines castout9(
digit[J,
Checksum
L ):
[0] Initialize chksum = 0 [I] For k=O to L-l, replace [2] Return chksum
chksum = (chksum + digit[k])X9
The checksum from casting out nines can be used to detect addition errors, since (mod 9), so c9(x + y + . . . ) = c9(c9(x) + c9(y) + . . . ) . It can also check products, since c9(xy...) = cs(c9(x)c9(y)...). For example, the product 1872 x 22 883 is not equal to 42846 976, since c9(42 846 976) = 1 whereas c9(cs(1872)c9(22883)) = c9(9 x 5) = 9. However, the method does not locate the error. Also, it fails to detect some errors: the product 1872 x 22 883 is not equal to 42846 966 either, even though c9(42 846 966) = 9. If our numbers are random in the sense that c9(x) is uniformly distributed over {1, 2 , . . . , 9}, then casting out nines has an 8/9 probability of catching an error. Still, one such error in nine goes undetected. We could also use "casting out elevens" to compute a checksum e l l = Cll (Z) satisfying x = ell(X) (mod 11). But 10 = - 1 (mod 11), so
c9(x + y) = c9(x) + c9(y)
10 k _ ~ 1 ( m o d l l ) , [ -1 (modll),
ifkiseven, ifkisodd.
Thus to compute e l l ( Z ) , we must add the even-position digits starting with digit 0, and then subtract the odd-position digits. For example, c11(1 872) = (8 + 2) ( 1 + 7 ) = 2 and c11(22 883) = ( 2 + 8 + 3 ) - ( 2 + 8 ) = 3. Note that C l l ( - 1 8 7 2 ) = - 2 , as all digits keep the sign of x. The process is repeated until the result lies in the range [-10, 10]. If it is not positive, 11 is added to get a result in the range [1, 11]. This method may be applied to large numbers x presented as long arrays of decimal digits: Casting-Out-Elevens
Checksum
castoutll( digit[], L ): [0] Initialize chksum = 0 [I] For k=O to L-l, do [2] to [3] [2] If k is even, let chksum = (chksum+digit[k])Xll [3] Else let chksum = (chksum + Ii - digit[k])7,11 [4] Return chksum
We add 11 in step 3 to guarantee that the left-hand operand of % is never negative. It is an easy exercise to prove that Cll detects all one-digit errors in decimal arithmetic. However, one multiple-digit error in 11 will go undetected using this checksum. Notice that Cll catches the error 1 872 x 22 883 ¢ 42 846 966, since e l l (42 846 966) -- (2 + 4 + 9 + 6) -- (4 + 8 + 6 + 6) -- --3 -- 8 (mod 11), and 8 7~ 2 x 3. In general, we can combine checksums to decrease the probability of undetected errors.
6.2. ERROR CORRECTION AND DETECTION
207
Checksums are also used to detect corrupted data. Both x and y = c(x) are stored, and then c is recomputed from the retrieved x and compared to the retrieved y. If they disagree, then either x or y was corrupted during storage. If they agree, there is a high probability that neither was corrupted. Humans use casting out nines because one-digit decimal arithmetic is considered easy, so the effort of checking is low. Digital computers can perform multi-bit binary arithmetic easily, and analogs of casting out nines exist to check calculations and data. We expect different kinds of errors than humans make. For example, a single bit might be flipped, or a segment of bits might be set all to zero, due to faulty memory or a bad connection. So, if x is the nonnegative integer representing a string of bits, we may wish to compute a checksum c(x) with the following desirable properties:
C h e c k s u m Goals CSG-I:
Any single-bit error is detected.
C S G - 2 : Any double-bit error is detected. C S G - 3 : Certain special kinds of errors like truncations of the bit string are detected with probability 1 - e. C S G - 4 : Any multiple-bit error is detected with probability 1 - e. The undetected error probability, e, will depend on the formula used for c(x). With the casting out nines checksum, e = 1/9 ~ 11%. It is dependent on the range of values taken by c(x), which is a measure of the amount of information that c(x) retains from x and so can be measured in bits. If c(x) takes all values in {0, 1 , . . . , 216 - 1}, we will call it a 16-bit checksum, and so on. Let X = X(s) = c - l ( s ) be the set of bit strings with checksum s. If properties 1 and 2 hold, then we must have it that the Hamming distance dist(X(s),X(s')) > 2 whenever s ~ s'. Such a code contains enough information to correct one flipped bit, so it must contain log 2 N bits of redundancy for N bits of data. Hence, a 16bit checksum can protect at most 216 data bits, which is 8 kilobytes, and a 32-bit checksum can protect at most 512 megabytes. To accomplish CSG-3, detecting truncations, the number of data bits can be transmitted as a second checksum, or better yet appended to the data bits before the checksum or CRC is computed. The receiver compares the portion of the received bits which contains the length to the actual number received. Any inconsistency is cause for rejection. In the 16-bit case, with the length appended to the data, the probability is only 1/216 ~ .000015 that chopping off the end exposes bits claiming the right length. Thus truncation is detected with probability 1 - e ~ 99.9985%, assuming that all 16-bit strings are equally probable in any 16-bit segment of the data. CSG-4 can be restated as follows: the probability that c(x) = c(x') given that x -¢- x' must be less than e. Using values of s to partition the space of bit strings, this requires that c - l ( s ) contains fewer than eK of the K total bit strings. This implies that the number of checksum values call it S must be larger than
CHAPTER
208
6. R E D U N D A N C Y
AND INFORMATION
l/e, and that e must be larger than 1/S. 16-bit checksums thus at best allow 1 - e ~ 99.998%. Note t h a t achieving CSG-4 does not necessarily achieve CSG-3, since truncations are a tiny subset of the possible errors and may, in principle, have a high probability of going undetected without defeating goal 4. Modular
implementations
Let 0 _< x < 2 N be the number represented by an N-bit string. For each fixed integer S > 1, consider the modular checksum cs(x) - x % S given by the remainder after division by S. If b is a positive integer such t h a t 2 b-1 < S < 2 b, then 0 _< cs(x) < 2 b and we will say t h a t cs gives a b-bit checksum. In any case, cs(x) - x (rood S), so two bit strings z /= y are distinguishable from just this checksum if and only if x ~¢ y (rood S). Such remainder checksums are easy to analyze because c s ( x + y) - cs(x) + cs(y) and c s ( x y ) - c s ( x ) c s ( y ) for all integers x, y. We now find some values of S t h a t achieve checksum goals 1-4. To meet CSG-1, we must have t h a t x - y is not a multiple of S if x and y differ at exactly one bit. But in t h a t case, x - y - +2 k for some integer 0 _< k < N, so by unique factorization, S l ( x - y) only if S is an integer power of 2. Hence any S > 1 which is not an integer power of 2 will satisfy CSG-1. In particular, S - 2 6 - 1 gives a b-bit checksum for every b > 0, and since 26 - 1 (mod S), we can simply add the b-bit "digits" of x to compute cs(z), just as in casting out nines. Similarly, if S - 2 b + l , t h e n 2 b - - 1 ( r o o d S ) , and we can use an alternating sum as in casting out elevens. For b - 8 on a typical computer t h a t uses 8-bit characters and 32-bit integers, we may us the following functions to compute the S - 255 and S - 257 modular checksums" C h e c k s u m M o d u l o 255 castout255( octet[], L ): [0] Initialize chksum = 0 [i] For k=O to L-l, do [2] [2] Replace chksum = (chksum+octet [k] )7.255 [3] Return chksum
Checksum
M o d u l o 257
castout257( octet [], L ) : [0] Initialize sE = 0 and sO = 0 [I] For k=O to L-l, do [2] to [3] [2] If k is even, then replace sE = (sE+octet[k])~o257 [3] Else k is odd, so replace sO = (sO+octet[k])~.257 [4] Let chksum = sE - sO [5] If chksum
chksum += 257
6.2. E R R O R C O R R E C T I O N A N D D E T E C T I O N
209
To meet CSG-2, note t h a t if the N-bit integers x and y differ at exactly two bits, then x - y - +2J(2 k + 1), for some integers 0 <_ j < N and 0 < k < N. If cs(x) - cs(y), then S divides 2J (2 k + 1). Hence, to achieve CSG-2, it sumces to find an S which is not an integer power of 2 and does not divide 2 k + 1 for any 0 < k < N. There are just 2 N such numbers, so it is a simple m a t t e r of performing O(N) trial divisions 6 to find an S t h a t avoids dividing any of them. We are sure to find a b-bit non-divisor if 2 b > N. Unfortunately, this excludes the fast implementation choices S - 2 b ± 1. In the next section, we will modify the arithmetic to obtain a fast algorithm despite this prohibition. Checksum goals 3 and 4 are accomplished by choosing S > 1/e. If all N - b i t string differences x - y are equally probable, then the chances t h a t x ¢ y but c s ( x - y ) - 0 are just 1 / S < e, and no particular multi-bit error is more likely t h a n any other. Mod-2 polynomials
arithmetic
without
carries
The special values S - 2 6 ÷ 1 for a modular checksum cs give fast algorithms" each block of b bits contributes its share to the checksum independently of the other blocks. For computers with fixed integer bitwidth b, this means no carries are needed. However, having just two choices is a big limitation, especially as b o t h choices interfere with CSG-2. This problem can be overcome with alternative arithmetic. Instead of treating bit strings as ordinary numbers written in binary, we consider t h e m to be coefficients of a polynomial and m a n i p u l a t e t h e m using the rules for polynomial algebra. Polynomials whose coefficients are just 0 or 1 can be added and multiplied termwise, using arithmetic modulo 2. We shall call these objects raod-2 polynomials and use the qualifier raod-2 to designate the new arithmetic operations. For example, if p(t) - t 2 + t + 1 and q(t) - t + 1 are rood-2 polynomials, then their m o d - 2 s . m is p ( ~ ) + q(t) - t 2, s i n c e 1 + 1 - 2 - 0 ( m o d 2) a n d t + t - 2~ - 0~ - 0 (rood 2). Likewise, their rood-2 product is p(t)q(t) - t 3 + 1, which we get by adding t 3 + t 2 + t to t 2 + t + 1. The coemcients of these rood-2 polynomials determine numbers in binary: p is 111 (base 2) - 7 (base 10), and q is 11 (base 2) - 3 (base 10), so these polynomial operations give an alternative addition and multiplication in which 7 + 3 - 4 and 7 x 3 - 9. The rood-2 values can also be determined by reconsidering the coefficients as integers and evaluating the polynomial at 2" p(2) -- 5 and q(2) - 3. Likewise, given a nonnegative integer, we can find its mod-2 polynomial by computing its binary expansion. Table 6.3 shows the addition and multiplication facts for the first eight of these rood-2 polynomials. Mod-2 polynomial addition may also be interpreted as componentwise addition in the vector space of sequences whose components are the integers modulo 2. Addition in this space is the same as ordinary binary addition, only without carries. Hence, addition may be performed on each bit independently, using the addition facts 0 + 0 - 0, 0 + 1 - 1 + 0 - 1, and 1 + 1 - 0. Such carry-free addition is the 6But half of the numbers {2k + 1 • 1 <_ k _< N} will have at least N/2 digits, so the cost of testing S is actually O(N2).
210
CHAPTER 6. RED UNDANCY AND INFORMATION + 10 0 1
2 3 4 5 6
415
× 10
2
3
4 5 6 7 0 1 2
0 1 2 3 4 5 6 7
0 2 4 6 8 10 12
0 3 6 5 12 15 10
5 4 7 6 1 0 3
7
0 0 0 0 0 0 0
4
0 4 8 12 16 20 24
5
6
0 5 10 15 20 17 30
0 6 12 10 24 30 20
0 7 14 9 28 27 18 21
Table 6.3: Arithmetic with the first eight mod-2 polynomials. Left" Addition table. Right" Multiplication table.
same as the bitwise exclusive-or operation, which in the C programming language is denoted by the caret (^) operator. In the following implementation, a new array is allocated to hold the sum, and the exclusive-or assignment operator ^= is used to accumulate the mod-2 sums in it:
Mod-2 Polynomial Sums mod2polysum(
[0] [I] [2] [3] [4]
p[],
alp,
q[],
dq
):
Let ds = max(dp,dq) and allocate sum[O] .... ,sum[ds] For d=O to ds, let sum[d] = 0 For d=O to dp, replace sum[d] ^= p[d] For d=O to dq, replace sum[d] ^= q[d] Return sum[] and ds
Putting the operands into arrays allows arbitrary degree polynomials, but is inefficient. However, if the degrees dp and dq of the summand polynomials are both less than the bitwidth of an unsigned integer type known to the computer, then they may be encoded as integers by evaluating p(2) by Horner's method: 7
Convert an Integer-Size M o d - 2 P o l y n o m i a l to an Integer mod2polyint(
p[],
dp
):
[0] Initialize ip = 0 [i] For d=dp down to O, let ip = 2,ip + p[d] [2] Return ip
The sum of mod-2 polynomials that fit into integers may be performed by a single bitwise exclusive-or operation:
Integer-Size M o d - 2 P o l y n o m i a l S u m s intmod2polysum( [0] sum = p^q [I] Return sum
p, q ) :
7A more robust implementation would test the size of overflow and wrong return value.
dp, or else there could be a silent integer
6.2. E R R O R C O R R E C T I O N AND D E T E C T I O N
211
Mod-2 polynomial multiplication is given by combining index shifts with ands and exclusive-ors. Using arrays of bits, this may be implemented as follows:
Mod-2 Polynomial P r o d u c t s mod2polyproduct( p [ ] , dp, q [ ] , dq ): [0] Let ds = dp+dq and allocate prod[O],...,prod[ds] [i] For d=O to ds, let prod[d] = 0 [2] For i=O to dp, do [3] [3] For j=O to dq, replace prod[i+j] ^= p[i]~q[j] [4] Return prod[] and ds If ds = dp + dq is small enough, then all of the mod-2 polynomials will fit into some integer type and the above may be performed more efficiently with bit shifts and bitwise exclusive-ors. The C programming language supplies the operators <<= and >>= for bitshift-left and bitshift-right assignment, respectively: Integer-Size Mod-2 Polynomial Products intmod2polyproduct( p, q ) : [0] Initialize prod = 0 [i] While p>O, do [2] to [4] [2] If p is odd, then replace prod ^= q [3] Replace q <<= i by its bitshift left [4] Replace p >>= i by its bitshift right [5] Return prod
The degree, written degp, of a mod-2 polynomial p = p(t) is defined as for ordinary polynomials: it is the highest power of t present in p(t). The degree of the zero polynomial is undefined, though it can be set to - c o with the convention that ( - o o ) + d = d + ( - o c ) = - o c for any integer d. The degree function then satisfies two equations: deg(p + q) deg(pq)
_< max{degp, degq}; -
degp+degq.
In practice, a degree function may return - 1 as the degree of the zero polynomial: Mod-2 Polynomial Degree mod2polydegree( p [], dp ) : [0] For d=dp down t o 0, do [1] [I] If p[d]==l, then return d [2] Return -i An initial estimate dp of the degree must be supplied. If this is small enough, then the mod-2 polynomial will fit into an integer and we can be more efficient"
C H A P T E R 6. R E D U N D A N C Y
212
Integer-Size Mod-2 Polynomial
AND INFORMATION
Degree
i n t m o d 2 p o l y d e g r e e ( p ): [0] I n i t i a l i z e degree =-1 [1] W h i l e p>0, do [2] to [3] [2] B i t s h i f t r i g h t p >>= 1 [3] I n c r e m e n t d e g r e e += 1 [4] R e t u r n d e g r e e T h e division t h e o r e m for ordinary polynomials applies to mod-2 polynomials" T h e o r e m 6.14 For any mod-2 polynomials pl and p2 ~ O, there are unique mod-2 polynomials q, r such that pl (t) - p2(t)q(t) + r(t) and 0 < deg r < degp2.
Proof: For existence, we construct the quotient q and remainder r using synthetic division. The following implementation produces arrays of 0s and ls representing the mod-2 polynomials q, r, given input arrays p l [0] ,... ,pl [dl] and p2 [0] ,... ,p2 [dd] :s
Mod-2 Polynomial Quotient and Remainder mod2polydivision( [0] If dl
pl[],
all, p 2 [ ] ,
d2 ):
then let dq = -i and let dr = dl
[1] E l s e do [2] t o [5] [2] Let dq = all-d2 and l e t d r = d2-1 [3] For d=dl down t o d2, do [4] t o [5] [4] I£ p l [ d ] = = l , t h e n do [5] [5] For n=0 t o d2, r e p l a c e p l [ n + d - d 2 ] [6] Let d r = m o d 2 p o l y d e g r e e ( p l [ ] , d r ) [7] R e t u r n p l [ ] , dq, d r
^= p2[n]
Upon termination, the r e t u r n e d array pl will contain the coefficients of the remainder and quotient mod-2 polynomials as subarrays: p l [0], . . . , p l [dr] will be r, while p l [d2], . . . , p l [d2+dq] will contain q. If the r e t u r n e d value dr - - 1 , then the remainder r is zero and its part of the array is not present. Likewise, if dq - - 1 , then the quotient q is zero and it is not present in the r e t u r n e d array pl. For uniqueness, suppose t h a t Pl (t) p2(t)ql ( t ) + fl (t) p2(t)q2(t)+ r2(t) with 0 _< d e g r l < degp2 and 0 <_ degr2 < degp2. Thenp2(t)[q2(t)-ql(t)] - r l ( t ) - r 2 ( t ) . Suppose toward contradiction t h a t ql 7£ q2. T h e n P2[q2- ql] ¢ 0, so we may c o m p u t e mod-2 degrees: deg(rl - r2) - deg(p2[q2 - ql]) - degp2 + deg(q2 - ql) >_ degp2, but this contradicts deg(rl - r 2 ) _< m a x { d e g r l , degr2} < degp2. Hence we must have ql - q2, so rl - r2 - P2[q2 - ql] - O, so rl - r2. [] -
-
-
-
We will reuse symbols and denote the quotient and remainder by p(t)/q(t) and
p(t) % q(t). SThis function assumes that the denominator polynomial p2 is nonzero, or else the results will be nonsense. How could this assumption be tested in practice?
6.2. E R R O R C O R R E C T I O N A N D D E T E C T I O N
[I
1 1,0 2,0 3,0 4,0 5,0 6,0 7,0
2 0,1 1,0 1,1 2,0 2,1 3,0 3,1
a14 0,1 1,1 1,0 3,1 3,0 2,0 2,1
0,1 0,2 0,3 1,0 1,1 1,2 1,3
213
5
6
7
0,1 0,2 0,3 1,1 1,0 1,3 1,2
0,1 0,2 0,3 1,2 1,3 1,0 1,1
0,1 0,2 0,3 1,3 1,2 1,1 1,0
0,1 0,2 0,3 0,4 0,5 0,6 0,7 1,0
Table 6.4: Quotients q and remainders r from division y(t) = q(t)x(t) + r(t) of mod-2 polynomials x, y expressed as base 10 versions of their coefficient bit strings. Here x is at the top of the column and y is at the left of the row.
If both the numerator and denominator polynomials fit into an integer type, then there is a more efficient mod-2 division implementation using bit-shifts:
Integer-Size Mod-2 Polynomial Quotient and Remainder intmod2polydivision( pl, p2 ): [0] Initialize q=O and r=pl [I] Let sh = intmod2polydegree(r)-intmod2polydegree(p2) [2] If sh >= O, then do [3] to [4] [3] Replace r ^= (p2<<sh) and replace q ^= (i<<sh) [4] Go to [i] [5] Return q, r
Table 6.4 shows the quotients and remainders for the first eight nonzero mod-2 polynomials. If the remainder is zero, so that Pl (t) = p2(t)q(t), then we say that p2 divides Pl. Having Theorem 6.14, we can implement Euclid's algorithm for mod-2 polynomials, so each pair x = x(t), y = y(t), not both zero, will have a unique greatest common divisor not equal to zero. In the following implementation, derived from the one on page 4, we assume without loss that x is not the zero polynomial:
Euclid's Algorithm for Mod-2 Polynomials mod2polygcd( x[], dx, y[], dy ): [0-] Let dz = dx and allocate z[O],...,z[dz] [0] For d=O to dx, copy z[d] = x[d] [I] Compute dr,dq,y[] with mod2polydivision(y[] ,dy,x[] ,dx) [I+] Let dx = dr, and for d=O to dr, copy x[d] = y[d] [2] Let dy = dz, and for d=O to dz, copy y[d] = z[d] [3] If dr>O, then go to [0] [4] Return y[], dy
214
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
The more efficient implementation for integer-size mod-2 polynomials is left as an exercise. We may reuse the notation gcd() for the result. Now gcd(x, y) is again a mod-2 polynomial. We will say t h a t z, y are relatively prime if deg gcd(x, y) = 0. We will say t h a t a mod-2 polynomial x of positive degree is irreducible if x is relatively prime to every rood-2 polynomial y of strictly smaller degree. 9 Equivalently, x is irreducible if no rood-2 polynomial of smaller positive degree divides x. It is straightforward to prove the following generalizations to mod-2 polynomials of Lemmas 1.1 and 1.3: Lemma
6.15 If deg y >_ 0 and x(t) divides y(t), then deg x _< deg y.
Proof: Write y(t) = x(t)q(t) and note t h a t q ~ 0 since deg y _> 0 ::~ y ~ 0. But then deg y = deg qx = deg q + deg x, so deg y - deg x = deg q _> 0, so deg y _> deg x. [] 6.16 If z(t) divides x(t)y(t) and x, z are relatively prime rood-2 polynomials, then z(t) divides y(t). []
Lemma
The proof is left as an exercise. 6.17 Every rood-2 polynomial p can be factored into irreducible rood2 polynomials, and the factorization is unique except for the order. Namely, if p(t) = p l ( t ) - . "pn(t) = q l ( t ) ' " "qm(t) are two factorizations, then n = m and, possibly after re-indexing, Pi = qi for all i = 1 , . . . , n. [] Theorem
The proof is substantially the same as t h a t for Theorem 1.4. It leads immediately to the following: C o r o l l a r y 6.18 If an irreducible rood-2 polynomial z(t) divides a product of rnod-2 polynomials x(t)y(t), then either z(t) divides x(t) or z(t) divides y(t). [] To check whether a mod-2 polynomial x(t) of degree d = deg(x) > 0 is irreducible, it is only necessary to perform trial divisions with irreducible mod-2 polynomials of degree 1 through [d/2]. There are fewer t h a n 2 d/2 of those, and except for t ~ 2 they all correspond to odd numbers. It is easy to list all these trial divisors if the candidate irreducible mod-2 polynomial is integer-sized: T e s t if a n I n t e g e r - S i z e M o d - 2 P o l y n o m i a l is I r r e d u c i b l e
intmod2polyirreducible( x ): [0] Let d2 = intmod2polydegree(x) [1] For y=2 and odd y=3 to (1<
6.2. E R R O R C O R R E C T I O N A N D D E T E C T I O N
215
÷110
7
× tl0
7
0
0
1
1
2 3 4 5 6 7
2 3 4 5 6
7 6 5 4 3 2
0 1 2 3 4 5
0 0 0 0 0 0
0 7 6
1
6
0
0
7
1
4 3 2 5
Table 6.5" Left" Arithmetic with the eight mod-2 polynomials, reduced modulo t a. Left" Addition table, same as before. Right: Multiplication table.
The returned value will be TRUE if the rood-2 polynomial is irreducible, or FALSE if a factor of degree 1 or more is found. Mod-2 polynomials modulo a mod-2 polynomial Yet another kind of modular arithmetic is possible, using the set of mod-2 polynomials reduced modulo a fixed mod-2 polynomial S = S(t). For example, Table 6.5 shows the entries of Table 6.3, reduced modulo the polynomial S(t) = t a. In this kind of arithmetic there are only finitely many distinct elements, in fact 2deg s of them, with deg S = 3 in the example. That is because the degree of the remainder mod-2 polynomial after division by S must be strictly less than deg S, which means it can have at most deg S coefficients, and there are exactly 2 degS such mod-2 polynomial remainders. Addition and multiplication are commutative, associative, and distributive just like for ordinary integers. Each element has a unique additive inverse, since there is a unique 0 in each row and column. However, if S is reducible then its factors will not have multiplicative inverses. In the example, S(t) = t a is evidently reducible, and the factor t 2 corresponding to 4 has no multiplicative inverse. This is the only source of trouble: an irreducible polynomial such as S(t) = t a + t + 1 will give every nonzero element a unique multiplicative inverse as well. Table 6.6 illustrates how: there is a unique 1 in each nonzero row and column of the multiplication table. Now suppose that S = S(t) is a fixed mod-2 polynomial. We define the checksum cs(x) = x ( t ) % S(t) to be the remainder polynomial, of degree less than b = deg S, produced by the p o l y d i v 2 ( ) function. The coefficients of that remainder will be a b-bit checksum for x. For example, Table 6.7 shows the checksums of the 32 five-bit strings, namely the 32 mod-2 polynomials of degree four or less, reduced modulo the polynomial S(t) = t a + t + 1. Note that mod-2 polynomial checksums may be computed very efficiently with just bit-shift and exclusive-or operations. It is not necessary to keep the quotient polynomial, and the degree of the modulus rood-2 polynomial S(t) limits the number of bits that must be stored. If there are b such bits, for deg S = b, then the
C H A P T E R 6. R E D U N D A N C Y A N D I N F O R M A T I O N
216
+110
7
×11o
0 1 2 3
7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7
5 6 7
0 1 2 3 4 5 6
0 0 0 0 0 0 0
0 5 1 4 2 7 3
0 6 7 1 5 3 2
0 7 5 2 1 6 4
Table 6.6: Arithmetic with the first eight mod-2 polynomials, reduced modulo t 3 + t + 1. Left: Addition table, same as always. Right: Multiplication table.
x [ xbase2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111
cs(x) [I x I x b a s e 2 0 1 2 3 4 5 6 7 3 2 1 0 7 6 5 4
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111
cs(x) ] 6 7 4 5 2 3 0 1 5 4 7 6 1 0 3 2
!
Table 6.7: Three-bit checksums for all strings of five bits, reduced modulo S(t) ta+t+l.
6.2. E R R O R C O R R E C T I O N A N D D E T E C T I O N
217
total number of operations will be O(bN) for N bits of data. Note that in the following implementation, the bit strings are stored in reverse order, with the first or highest-order bit occupying index 0, and the last or lowest-order bit at index nb: Compute
a Mod-2 Polynomial Checksum
mod2polychecksum( msg[], nb, mod2poly[], dm ) : [0] For n=O to rib-din-l, do [I] to [2] [i] If msg[n]==l, then do [2] [2] For d=O to dm, replace msg[n+d] ^= mod2poly[dm-d] [3] Let chksum = 0 [4] For n=nb-dm to rib-l, replace chksum = 2,chksum+msg[n] [5] Return chksum
For CSG-1, suppose that x(t) and y(t) are mod-2 polynomials that differ at exactly one coefficient. Then x(t) - y(t) = t k for some nonnegative integer k, so cs(x) = cs(y) if and only if S(t) divides t k. If S(t) is irreducible and deg S > 1, then this is impossible: S(t) must divide t by Corollary 6.18, but then L e m m a 6.15 gives the contradiction deg S < deg t = 1. For such S, cs will detect all l-bit errors. For CSG-2, suppose that x(t) and y(t) differ at exactly two coefficients. Then x ( t ) - y ( t ) = t J ( t k + l ) for some i n t e g e r s j >_ 0 and k > 0. Thus cs(x) = cs(y) if and only if S(t) divides tJ(t k + 1) as a mod-2 polynomial. If S(t) is irreducible and d e g S > 1, then S(t) will not divide tJ for any j, as shown in the preceding paragraph. Thus, Corollary 6.18 implies that cs(x) = cs(y) if and only if S(t) divides t k + 1, which it must do for some big enough k: 6.19 If S(t) is any rood-2 polynomial with at least two terms, then there is an integer N > O, depending on S, such that S(t) divides t N + 1, but S(t) does not divide t k + 1 for any integer 0 < k < N.
Theorem
Proof." tative many Since (mod
Consider the set {t k % S(t) : k = 0, 1 , . . . } , which consists of represenmod-2 polynomials of degree less than deg S. Since there are only finitely of those, there must be integers p > q _> 0 such that t p = t q (mod S(t)). S(t) has at least two terms, it cannot divide t k for any k, and thus t q :/: 0 S(t)). But then tp-q = 1 (rood S(t)), so since 1 + 1 = 0 (mod 2) we have def
foundn - p-q>0suchthatt n-1 (modS(t)). Since the set of positive integers { n : t n = 1 (rood S(t))} is nonempty, it has a smallest element which we may call N. By construction, S(t) does not divide t k + 1 for any integer 0 < k < N. [] Let N be the minimal positive integer for an irreducible polynomial S(t) with at least two terms. Then CSG-2 is achieved for all strings of N or fewer bits, as they correspond to mod-2 polynomials of degree N - 1 or less. For checksum goals 3 and 4, detecting other bit errors, note that the mod2 polynomial S(t) yields 2 d different checksums, 1° where d = degS. Under the assumption that all values of cs(x) are equally likely with our potential bit strings 1°Why doesn't it yield
S(2)
checksums?
CHAPTER 6. REDUNDANCY AND INFORMATION
218
x, the probability that two different bit strings have the same checksum is e = 2 -d. This is made small by choosing S with large degree d.
CRC-32 The standard 32-bit cyclic redundancy code, or CRC-32, gives a comprehensive example of checksum principles. It is defined by the rood-2 polynomial S(t) = t 32 q- t 26 -+-t 23 -Jr t 22 q- t 16 q- t 12 -Jr t 11 q- t 1° q- t 8 q- t 7 q- t 5 q- t 4 q- t 2 q- t -+- 1. (6.12) This is represented by the coefficient bitstring 1 0000 0100 1100 0001 0001 1101 1011 0111 (base 2) = 4 374 732 215 (base 10) = 1 0 4 C l l D B 7 (base 16). Trial division with the 216 = 65536 rood-2 polynomials of degree 16 or less shows that S(t) is irreducible. Likewise, after a few billion shift and exclusive-or operations, we can show that S(t) divides t N + 1 for no smaller exponent than N = 4294967295 = 2 a2 - 1. Hence, using S(t) as a checksum modulus achieves CSG-1 and CSG-2 for all strings of fewer than 4 gigabits. Degree 32 insures that CSG-4 is achieved with probability e = 2 -32 < 10 -9 The POSIX 1003.2 and ISO 8802-3 standard implementation of the CRC-32 checksum is based on computing the remainder modulo S(t), but it performs a few more steps to achieve CSG-3. The checksum s = cs(x) of a bitstring x, where s(t) and x(t) are both treated as mod-2 polynomials, satisfies t322(t) =
q(t)S(t) + g(t),
where 2 is derived from x by padding the end with zero bits to get an integral number of 8-bit bytes, then appending this number of bytes in binary to the end of x in the fewest bytes sufficient to encode it. Thus the degree of ~:(t) is a little greater than deg z. Finally, the checksum s is derived from g by complementing each bit, which of course makes no practical difference.
6.3
Exercises
1. Label the vertices in the two graphs of Figure 6.1, and use your labeling to list the set of edges for each. Then pick a root for the right-side graph, which is a tree, determine the depth, and list the vertices by generation. 2. Construct a prefix code for the alphabet A = {a, b, c, d} with codeword lengths 1,2,2,3, or prove that none exists. 3. Suppose we have two prefix codes, c0(a, b, c) = (1, 00, 01) and el(a, b, c) = (0, 10, 11), for the alphabet A - {a, b,c}. Show that the following dynamic encoding is uniquely decipherable by finding a decoding algorithm:
6.3. E X E R C I S E S
219
Dynamic Encoding Example dynamicencoding( msg [], M ) : [0] I n i t i a l i z e n=0 [1] For m=l t o M, do [2] to [3] [2] Transmit msg[m] u s i n g code n [3] I f msg[m]=='c', t h e n t o g g l e n = 1-n (This encoding is called dynamic because the codeword for a letter might change as a message is encoded, in contrast with the static encodings studied in this chapter. It gives an example of a uniquely decipherable and instantaneous code which is nevertheless not a prefix code.) 4. Suppose that pS _ p ( x l x 2 . . " X s ) d e f p(xl)p(x2) " " "p(Xs) is a probability function on A s derived from the probability function p on A. Show that H ( p s) =
5. Count, with proof, the binary trees of depth 3 or less. 6. Suppose n > 0. Show that there are infinitely many binary trees with n leaves. (Hint: Consider the case n = 1 and linear trees of K daughters between the root and the leaf.) 7. Generalize Huffman's algorithm to 10-ary trees, which would be used to build codes from strings in base 10. (Hint: consider the 3-ary case first.) 8. Construct a Huffman code for the alphabet A = {a, b, c, d, e, f, g, h} with occurrence probabilities p = (.20, .05, .08, .17, .30, .05, .10, .05). Compare its bit rate with H(p). 9. Find a Huffman code for the following message, compute its bit rate, and compare it to the entropy of the message: Trustworthy, loyal, helpful, friendly, courteous, kind, obedient, cheerful, thrifty, brave, clean, reverent. For simplicity, ignore all spaces, punctuation marks, and capitalization. 10. Construct a canonical Huffman code for the alphabet and occurrence probabilities of Exercise 8, with the property that no letter has a codeword consisting of just l-bits. Compute its bit rate. 11. What is the probability of an undetected error in N data bits if they have probability p of being flipped but the parity bit has a possibly different probability q of being flipped? 12. Find a binary code with four 10-bit or shorter codewords, wherein restoration to the nearest codeword corrects any two or fewer bit flips.
CHAPTER
220
6. R E D U N D A N C Y
AND INFORMATION
13. Prove t h a t casting out elevens will detect all one-digit errors in decimal arithmetic. Find an example one-decimal-digit error u n d e t e c t e d by casting out nines. 14. Will the combination of checksums c9 and Cll detect all 2-digit errors in decimal arithmetic? 15. Suppose t h a t z and y are integer-size mod-2 polynomials for your computer. Find an alternate implementation of Euclid's algorithm on page 213 using bitwise integer operations. (Hint: look at Euclid's algorithm for integers on page 4.) 16. Suppose t h a t z, y, z are rood-2 polynomials. Prove t h a t if z divides z y and z, z are relatively prime, then z divides y. (This is L e m m a 6.16.) 17. a. Show t h a t the rood-2 polynomial t a + t + 1 is irreducible. b. Find a factorization of the mod-2 polynomial t 4 + t 2 + 1. 18. For the following mod-2 polynomials s(t), find the least positive integer N such t h a t s(t) divides t N + 1:
a.
s(t)=ta+t+l
b.
s(t) = t 12 -4- t 11 -t- t 3 + t 2 + t + 1.
c.
s(t) = t 1 6 + t 1 5 + t 2 + 1 .
d.
s(t) -- t 24 -4- t 23 -4- t 14 -Jr-t 12 -t- t 8 -~- 1.
19. For the CRC-32 mod-2 polynomial s(t) = t a2 + t 26 + t 23 + t 22 + t 16 + t 12 4t 11 -4-t 1° -4-t 8 -4-t 7 + t 5 + t 4 + t 2 + t + 1, or 100000100110000010001110110110111 (base 2), show t h a t the least positive integer N for which s(t) divides t N + 1 is N = 4294967295 = 232 - 1. 20. Encode the text string "Elephants are approaching from the South!" into ASCII, using seven low-order d a t a bits plus one leading parity bit per character to preserve even parity. 21. Using the rood-2 polynomial S ( t ) = t 3 + t + 1, c o m p u t e the three-bit checksum for the encoding of "Elephants are approaching from the South!" obtained in previous Exercise 20. Do the same for a similar encoding of "Elephants are approaching from the North!" and "Elephants are approaching from the NORTH!" Do the checksums distinguish these messages?
6.4
Further Reading
• R o b e r t B. Ash. I n f o r m a t i o n Theory. and 1990. ISBN 0-486-66521-6.
Dover Publications, New York, 1965
6.4. FURTHER READING
221
• Richard W. Hamming. Coding and Information Theory. Prentice-Hall, Englewood Cliffs, New Jersey, second edition, 1986. ISBN 0131390724. • Andrew S. Tanenbaum. Computer Networks. Prentice Hall, Englewood Cliffs, New Jersey, third edition, 1996. ISBN 0-13-349945-6. • Stephen B. Wicker. Error Control Systems for Digital Communication and Storage. Prentice-Hall, Upper Saddle River, New Jersey, 1995. ISBN 0-13200809-2. • Ross N. Williams. A Painless Guide to CRC Error Detection Algorithms. Rocksoft Pty Ltd., Adelaide, South Australia, 1993. Available from URL f t p : / / f t p , r o c k s o f t , com/papers/crc_v3, t x t .
This Page Intentionally Left Blank
Appendix A
Answers A.1
... to Chapter
1 Exercises
1. S o l u t i o n : []
If a divides b and b divides a, one can only conclude t h a t ]a I = Ibl.
2. S o l u t i o n :
T r a n s l a t e t h e p s e u d o c o d e on page 4:
Standard C Function: Greatest Common int
gcd(
int
a,
int
Divisor
b ) {
int c; while ( a != 0 ) { c = a; a = b~a; r e t u r n b;
b = c; }
N o t e t h a t Euclid's a l g o r i t h m is recursive: if a = O, t h e n gcd(a, b) = b; otherwise, gcd(a, b) = gcd(b%a, a). Hence it has a n o t h e r i m p l e m e n t a t i o n :
Recursive Standard C Function: Greatest Common
Divisor
±nt gcd ( int a, int b ) { if ( a==O ) r e t u r n b; r e t u r n gcd ( b~a, a ); }
3. S o l u t i o n : S u p p o s e p a n d q are p r i m e w i t h p ~= q, a n d let c = gcd(p, q). Recall t h a t their definitions require c > 0, p > 1 a n d q > 1. Since c divides p, either c = 1 or c = p. Since c also divides q, either c = 1 or c = q. Since p ~- q, t h e only solution is t h e r e f o r e c = 1. u 223
224
A P P E N D I X A. A N S W E R S
4. S o l u t i o n : Using trial division, we discover that the numbers factor as follows: 299792458 = (2)(7)(73)(293339), 6447287 = (7)(11)(31)(37)(73), and 256964964 = (2)(2)(3)(73)(293339). The only prime factor common to all three is 73. However, finding these factorizations required v/293339 ~ 103 operations, because of the large prime factor 293339. Euclid's algorithm finds the solution with far fewer operations. We first compute gcd(299792458,6447287) = 511, by 299792458%6447287
=
3217256,
6447287%3217256
=
12775,
3217256%12775
=
10731,
12775%10731
=
2044,
10731%2044
=
511,
2044%511
0.
Then gcd(256964964,511) = 73, since 256964964%511
=
438,
511%438
=
73,
438%73
0.
Then we use the fact that gcd(a, b, c ) = gcd(a, gcd(b, c)). 5. S o l u t i o n : First compute gcd(2301, 19687) = 1, using Euclid's algorithm, to insure by Lemma 1.6 that a quasi-inverse exists. Then, translate the pseudocode on page 8 to compute it: Standard C Program: Quasi-inverses #include <stdio.h> int main ( void ) int a, b, x, y, xo, yo, c, d, t, q, r; a = 2301; b = 19687; c=a; d=b; x=O; yo=O; y=l; xo=l; while ((r=c~d) > 0 ) q=c/d; c=d; d=r; t=xo; xo=x; x=t-q*x; t=yo; yo=y; y=t-q*y; }
printf ("Inputs a=~d, b=~d; \n", a, b ) ; printf("Outputs x=~d, y=~d, gcd(a,b)=d=Y~d\n", x, y, d ) ; return 0 ;
This prints
A.1 . . . .
TO CHAPTER
225
1 EXERCISES
Inputs a=2301, b=19687; Outputs x=-3294, y=385, and gcd(a,b)=d=l T h e quasi-inverse x - - 3 2 9 4 should be a d j u s t e d by adding 19 687, m a k i n g it 16393 and bringing it into the range {0, 1 , . . . , 19686}. [] .
Solution: Overflow occurs if and only if the sum of two positive n u m b e r s x, y gives the w-bit twos c o m p l e m e n t r e p r e s e n t a t i o n of a negative number, which will h a p p e n if and only if 0 < x < 2 w-1 and 0 < y < 2 w - l , but 2 w-1 _< x + y < 2 TM considered as counting numbers. But t h e n the sign bit, n u m b e r w - 1, of b o t h x and y m u s t be 0, so t h a t x + y causes no carry out from bit w - 1 to bit w. However, sign bit w - 1 of x + y is 1, which must have come in as a carry. Underflow occurs if and only if the sum of two negative n u m b e r s x, y gives a w-bit twos c o m p l e m e n t positive number. This will h a p p e n if and only if 2 w-1 _< x < 2 w and 2 w-1 _< y < 2 w, but 2 w < x + y < 2 TM + 2 w - l , where everything is considered a counting number. But t h e n the sign bit, n u m b e r w - 1, of b o t h x and y must be 1, so t h a t x + y causes a carry out from bit w - 1 to bit w. However, sign bit w - 1 of x + y is 0, which m e a n s t h e r e cannot have been a carry in to bit w - 1 from bit w - 2. []
7. S o l u t i o n :
14600926 (base 10) equals D E C A D E
(base 16).
8. S o l u t i o n : If v/~ were a rational number, we could write x/~ = a / b in lowest terms, n a m e l y using relatively prime a, b c Z. But t h e n b2p = a 2, so p divides a 2. By L e m m a 1.3, p divides a, so we can write a = pao with a0 c Z. But t h e n p - p2a~/b2, so b 2 - pa~ and consequently p divides b2. Again by L e m m a 1.3, p divides b. Hence a, b share the c o m m o n divisor p > 1, contradicting the hypothesis t h a t t h e y are relatively prime. []
9. Solution:
Below is a S t a n d a r d C i m p l e m e n t a t i o n of the a l g o r i t h m on page
9:
S t a n d a r d C P r o g r a m : D e c i m a l to H e x a d e c i m a l and B i n a r y #include <stdio.h> int main ( void ) { int x; printf("Enter a positive integer (base 10): ") ; scanf( "~d", &x) ; printf("Y.d (base i0) = ~x (base 16) = (2 esab) ,, , X , X ) ., for ( ; x>O ; x /= 9 ) putchar( x&l ? 'I' : '0' ); put char (' \n' ) ; return 0 ;
226
APPENDIX
A.
ANSWERS
10. S o l u t i o n : T h e integer part of rr, namely 3, will be the first hexadecimal digit. The remaining seven, plus one more for use in rounding, will be brought to the left of the decimal point if we multiply by 16 s = 232 = 4 294 967 296 to get 2327r ~ 13 493 037 704.5. T h e n we use a variation of the p r o g r a m from the solution to Exercise 6:
Standard C Program: Print Eight Hexadecimal Digits of Pi #include <stdio.h> int main(void) { long long int pihex; pihex = (long long int) (3. 1415926535897932.(1LL<<32)) printf ("Reversed PI : ") ; do { printf("~X ", (int) (pihex~,16)) ; pihex/=16; } while(pihex) ; printf (" (esab 16) \n") ; return 0 ;
;
Its o u t p u t is:
Reversed PI: 8 8 A 6 F 3 4 2 3 (esab 16) which means t h a t rr ~ 3.243F6A88 (base 16). Since the least significant digit is the middle value 8, b o t h &digit hexadecimal approximations rr 3.243F6A9 (base 16) and 7r ~ 3.243F6A8 (base 16) are equally close. [] 11. S o l u t i o n : T h e t r u n c a t i o n error will be 2 -52, or a b o u t 2.2 x 10 -16 so there are 15 decimal digits of accuracy. [] 12. S o l u t i o n : The sum in exact arithmetic is 1.0 x l0 s, of course, but on the example machine with ef = 1.19209290 x 10 - r , the following p r o g r a m printed sum = i . 6 7 7 7 2 2 e + 0 7 :
Standard C Program to A d d l0 s F l o a t i n g - P o i n t
1.0's
#include <stdio.h> int main ( void ) { f Ioat sum=O; long i ; for ( i=O; i
The following S t a n d a r d C code reads the bits as a text string:
A.1 . . . .
TO C H A P T E R
1 EXERCISES
227
S t a n d a r d C Program: R e a d IEEE 32-bit F l o a t i n g Point #.include <stdio.h> # i n c l u d e <math. h> int main ( void ) { int s, e, f, power; printf("IEEE reader: Enter 32 bits, each 0 or l:\n"); s = ( getchar()=='0' ) ? '+' : '-' ; /. sign */ for( e=0, power=l<<7 ; power>0 ; power/= 2 ) if( getchar()=='l' ) e += power; /* exponent ,/ for ( f=0, power=l<<22 ; power>0 ; power/=2 ) if( getchar()=='l' ) f += power; /* mantissa ,/ if( e==255 ) if( f==0 ) printf("~c infinity", s) ; else printf ("NAN") ; else if( e==0 ) if( f==0 ) printf("~c 0", s); else printf ("~c ~ . 7 e (subnormal)", s, pow(2.0,-126.0)*(f/(double)(l<<23)) ); else printf("~c X.Ye", s, pow(2.0,e-127.0)*(l.0+f/(double) (1<<23))) ; put char (' \n' ) ; return 0;
14. S o l u t i o n : Let F(x) - Xl/X2, so V F ( x ) - ( 1 / x 2 , - X l / X l ) . T h u s M1 1/Ix2 ] and/1//2 ~ Xll/[x21, so the r i g h t - h a n d side of Inequality 1.11 simplifies to
( 1 + 'Xl//X2J --l- JXl//X2J )
17;17 i
3cf,
-
which is slightly b e t t e r t h a n Inequality 1.7. 15. S o l u t i o n :
a. Well-conditioned: Let F(x, y) - V/x 2 + y2, so
Vr(x, y)
+
y/v/
+ y:).
T h e r i g h t - h a n d side of Inequality 1.11 becomes 2ef. b. Well-conditioned except near x 1 + log x. N o t e t h a t
1" Let F(x)
IxF'(x)/F(x)[ - I(x + x l o g x ) / x l o g x [
-
- x logx, so F'(x) 1 1 + log x
228
APPENDIX A. ANSWERS which is large near x = 1 b u t b o u n d e d elsewhere. c. Ill-conditioned n e a r a n y integer x = k: T h e f u n c t i o n F(x) = Lx] is disc o n t i n u o u s at each integer k, so for a n y e > 0 we can find real n u m b e r s x, y withk<x
A.2 . . . .
TO CHAPTER 2 EXERCISES
A.2
...
to
Chapter
229
2 Exercises
Solution: The 5-cube is created by sweeping the 4-cube t h r o u g h a fifth axis. It has 25 - 32 vertices. We get 64 edges from the front and back 4-cubes, plus 16 new edges joining corresponding vertices on the front and back, for a total of 80.
A general formula m a y be developed recursively. Let v ( N ) , e ( N ) ber of vertices and edges, respectively, of an N-cube. We m a y 0-cube to be a single point, so v(0) = 1 and e(0) = 0. The 1-cube segment, so v(1) = 2 and e(1) = 1. Counting the vertices gives and for the edges we reason as in the previous p a r a g r a p h to get
+ 1) -
-
This has the closed form solution e(N) induction.
2
be the numconsider the is a unit line v ( N ) = 2x , the relation
N>I.
N 2 N-1 , as m a y be proved by []
2. S o l u t i o n : The zero subspace {0} C R N is zero-dimensional. For k 1 , . . . , N, let Yk - span { e l , . . . , ek}. T h e n Yk is a k-dimensional subspace of R N.
[]
3. S o l u t i o n : Fix N and let {en} be the s t a n d a r d basis for C N. Then el = (1, 0 , . . . , 0) satisfies [lel ]1 -- [lel [[2 -- []ell]~ -- 1, making the right column into equalities, while fN - e l - ~ - . . . - J r - e N - - ( 1 , 1 . . . , 1 ) s a t i s f i e s [IfNI]I -- N , [[fN]]2 -- v/N, and []fN[[oc -- 1, giving equalities in the left column. [] 4. S o l u t i o n : (i) ::> (ii): Given vectors x', y ' and scalars a, b, s u b s t i t u t e x ~ a x ' and y ~-- by' into the triangle inequality ]Ix + y][ _< ]Ix][ + ]]y[] from (i), and then expand. (ii) =~ (i): For the triangle inequality, take a = b = 1 in (ii). To show t h a t [lax]l = Ia] ]lxll, start by taking b = 0 in condition (ii) to get ][ax[] _< [a] ]]x]] for every scalar a. T h e n using this inequality with a - 1 - 1 . C s h o w s t h a t for all c ~: 0, 1
I xll-
-c. c x l l < _
1
IIcxl
Ilxll < II xll.
But 0 - ] 0 [ ]Ix[] < ]]0x]] - 0, so this second inequality a ]x]] _< ]lax]] actually holds for all scalars a. Combined with the first inequality, it implies t h a t [laxll- lal I xl[ for all scalars a. [] If x E Y and x E Y ± , then (x, x) - 0, so x - 0 because the inner product is nondegenerate. For the second part, apply definition 2.30: for any
5. S o l u t i o n :
y E Y, we have ( x , y ) - 0
for all x C Y ± , so V C ( V ± ) ±.
[]
230
APPENDIX
6. S o l u t i o n : al,... ,aN.
hypothesis.
Any y E Y m a y be expanded as y
-
A.
ANSWERS
EnN=I anYn for some scalars
Thus (x,y} - EnN=I an (X, yn} -- 0, since every t e r m is zero by []
7. S o l u t i o n : First note t h a t these three vectors are linearly independent: if a x + by + cz = 0, then (a + b + c, a, a + b, a + c) = (0, 0, 0, 0), which implies a = b = c = 0. Applying the recursive G r a m - S c h m i d t construction gives the o r t h o n o r m a l set {p, q, r}, where
P
=
q'-
r'
--
1 Ilxll x -
(1111) 2'2'2'2; 1 2'
Y-(P'Y)
P--
z-(p,z)
p-(q,z)q-
1)
1 1 2'2'
(1
2
- q; 1 2'
2'
11) 2' 2
- r,
since both q~ and r ~ h a p p e n to be unit vectors. 8. S o l u t i o n : If/=
Recall t h a t {en : n = 1 , . . . , N } is an o r t h o n o r m a l basis for E N.
j, then (f~, f i ) = ( e i - ei+l, e l nt - ' ' ' nt- e l ) z
If i > j, then (f~, fj) = (ei - ei+l, el -1- .. • nc the left factor is present in the right.
ej)
=
(ei, e i ) =
1.
0, since
no
c o m p o n e n t of
If i < j, then the left and right factors of the inner product share exactly two components: (f~, fj) = (ei - e i + l , e l + . . .
-t- e j ) = (ei, ei) + ( - e i + l ,
e i + l ) = 1 - 1 = 0.
Thus (f~, fj) = 5(i - j ) .
[]
9. S o l u t i o n : If u and v are continuous functions, then so is gv, so the R i e m a n n integral of gv exists. H e r m i t e a n s y m m e t r y follows from the identities ~u - gv and f o ~ ( t ) d t
-
fo Nondegeneracy follows from the fact t h a t if w -
w ( t ) is nonnegative and
continuous on [0, 1] and satisfies f l w ( t ) d t - O, then w ( t ) - 0 for every t c [0, 1]. Taking w ( t ) = ]u(t)] 2 then shows t h a t (u, u) = 0 if and only if u(t) = 0 at all t E [0, 1]. Linearity follows since ft(av + bw) = arty + bftw for any continuous functions u, v, w on [0, 1] and any complex numbers a, b. The linearity of the R i e m a n n integral then implies (u, av + bw) = a (u, v) + b (u, w). [] 10. S o l u t i o n :
By the triangle inequality, for every x ~: 0 we have ][(S + T)xI] < ]]Sx]] + ]ITxI] _< ]]Sllop[]X][ +
IITllopllXll.
A.2 . . . .
TO C H A P T E R 2 EXERCISES
231
Now divide by Ilxll > O to get IIS + rllo p ~ IlSllop + Ilrllop. Sinc~ I l a Z x l l - lal IITxll for every x, ~nd for every ~ > 0 there is some x with (lITllop- ~)llxll < IIrxll <_ IITllopllxll, we conclude that for every e > 0 there is some x with (lal IITIIop -la ld llx ll < IlaZxll ___ Lal IIZllopllxll. But then we must have II~Tllop- lal IITllop. To show that IISrllop ___ IISlloplIZllop, observe that IISZxll ___ IISllopllTxll <_ IISllop IITIIop Ilxll. [] 11. S o l u t i o n : The Hilbert-Schmidt norm is derived from the Hermitean inner product (A, B} - }-~.,~,nA(m, n)B(m, n) on MN-dimensional complex Euclidean space, with IIAllHS -- v/(A, A}. Hence it is nondegenerate, and it is sublinear by the Minkowski inequality. To prove submultiplicativity, we first expand in matrix coefficients. Since A, B can be composed into AB, we must have A c M a t ( M x K) and B c M a t ( K x N) for positive integers M, K, N. But then M
N
IIABII~Is- ~ ~ m=ln=l
K
2
~ A(m, k)B(k, n) - E I(A~,
Bn}
12,
m,n
k=l
where Bn is the n TM column of B and A~ is the m t h column of A*, namely the complex conjugate of the ?n th r o w of A, and (x, Yl - ~ k 2(k)y(k) is the usual Hermitean symmetric inner product on complex Euclidean K-space. By the Cauchy-Schwarz inequality relating this inner product to the norm Ilxll- v/(x, x>, w~ have
I(A~, Bn> 12 ~ IIA~ll2IIB~ll 2 since
I~1-
Izl for every z. After summing in m and n we get
- -
,
HS"
Taking square roots gives the desired inequality. 12. S o l u t i o n : Write A - { A ( m , n ) } and B in Equation 2.46 gives tr ( A ' B ) -
EEA*(n,k)B(k,n) n
k
{ B ( m , n ) } . Substituting A ~ A*
- EEA(k,n)B(k,n) n
- (A,B I .
k
Equation 2.46 also gives t r ( B A * ) - t r ( A * B ) - ( A , B I. Next, note that tr (C*) - tr (C) for any square matrix C. Since AB* - ( B A * ) * and B * A (A* B)* are square, we get tr (AB*) - tr (B* A) - (A, B).
APPENDIX A. ANSWERS
232
Finally, substituting B ~ A in the first result yields (A,A} - tr (A'A) tr (AA*), since (A, A) is real-valued, and the second result follows since IIAIIHS is the derived norm. [] F
13. S o l u t i o n : First note that P y is linear, since the inner product is linear in the second factor. Second, note that P y x c span Y for each x E X. Third, note that P v y k - - y k for k - 1 , . . . , N , so s p a n Y C P y X . H e n c e P v is a linear transformation of X onto Y. For the projection property, use linearity to compute P~x
-
Py
(Yk,X) Yk
--
Yj,~(Yk,X)
k=l N
-
j=l
N
E E
Yk
Yj
k=l N
lye.x//y,.y
/y
-
j=l k=l
E/y,.x/y,
-
..x.
j=l
since (yj, Yk) -- 1 for k - j and is zero otherwise. Thus P ¥ is a projection. To show that it is an orthogonal projection, we show that P y is selfadjoint and use Lemma 2.21. But for arbitrary x, z c X,
(z. P . x/
-
z. y : (y~. x/y~
- y : (y~. x/(z. y~/
k=l
k--1 N
N
=
~(Yk,
z)(Yk,X) -
~((yk,
k=l
=
z}yk,x)
k=l
(Yk, z) Yk, x
-
( P y z, x},
which shows that P{, - P y .
[]
14. S o l u t i o n : a. The set YN -- {Y~ " n -- 1 , . . . , N} is orthonormal in X for any N, so by Exercise 13, the following is an orthogonal projection onto span YN"
PNX
N de__f ~ - ~ ( y n , X )
yn.
n=l
Evidently XN -- PNX, so I XNII ___ I xll, and thus IIXN 12 < Ilxll 2, by Lemma 2.20. Finally, we use the orthonormality of Y N and the linearity and Hermitean symmetry of the inner product to expand
IIxNII 2
-
(XN,XN)
-n=l
N
=
~
N
~
n=l m=l
( y n , X ) Yn, ~ ( y m , X ) Ym m=l N
c(n)c(m)(Yn,Ym)
-- ~'~ Ic(n)l 2. n=l
A.2 ....
TO CHAPTER
233
2 EXERCISES
b. We begin by expanding I l x - X N I I 2 -- ( x - X N , X - XN) --Ilxl] 2 -]-IIXN[ 2 -{X, XN) -- (XN, X). Now let PN be the orthogonal projection defined in part (a), so XN -- PNX. Then (X, X N > -
<X, P N x > - { x , P~vX> -
< P N x , PNX> -
IIXNII2,
<XN,XN>-
and also (XN, x) --IIXNll 2, by Hermitean symmetry. Substitution for the two inner products in the initial expansion gives IIx - xu II2 --
IxLI 2 -
IIxu II2
Thus if I l x - XNI I --+ 0 as N ~ oc, t h e n IIXNII 2 -+ IIx 12 , as N ---, oc. Part (a) then implies convergence of the series: (x)
N
c(n)l 2 n=l
lim ~ l c ( n ) l 2 -
N--+oc
n=l
lim [IXN 1 2 - Ilxll2
N--+oc
Conversely, if En°°=l c(n)l 2 - I l x l l 2, t h e n IIXNII 2 ---+ ]lxl 2 a s N ~ I l x - XN 2 __+ 0, and so I I x - XNII --+ 0, as N ~ oc.
~.
Thus []
15. S o l u t i o n : Let en E g2 be the elementary sequence ( 0 , . . . , 0, 1, 0 , . . . ) , where the single nonzero coordinate appears at index n. Then Ilenll = 1, but IITenll = n, which grows without bound as n -~ oc. Hence there is no finite c satisfying IITenll <_ cllen lI for all n. [] 16. S o l u t i o n :
To prove the first equality, write G i j ( O ) G i j ( - O ) as
[Id - (eii + e j j ) + cosO ( e i i + e j j ) + sin 0 (eij - eji)] x x [Id - (eii + e j j ) -Jr- c o s 0 (eii + e j j ) - sin 0 (eij -- eji)]
= Id-(eii+ejj)+(cos
20+sin 20)(eii+ejj)
The second equality follows from s i n ( - 0 ) since Gij(O) is real-valued. 17.
-
-sin0,
-
Id.
and the third follows []
Solution: Write L - I d + L ' for the matrix, where I d is the N x N multiplicative identity matrix. I d is zero except for ones on the main diagonal, and L' is the matrix of zeroes except for the subdiagonal part of column k. We need to show that L -1 - I d - L'. But ( I d + L ' ) ( I d - L') - I d + L' - L' + L ' L ' = I d + L ' L ' , so it suffices to show that L ' L ' - O. But that is evident, since L ' ( i , j ) - 0 if j ~ k or i _< k, so the product L ' ( i , n ) L ' ( n , j ) is zero for all i , j , n , so L ' L ' ( i , j ) - y ~ . n L ' ( i , n ) L ' ( n , j ) - 0 for all i , j . The result now follows from the uniqueness of inverse matrices. []
18. S o l u t i o n : Suppose A, B are lower-triangular N x N matrices. Then A ( i , j ) 0 and B ( i , j ) - 0 i f i < j. But then A ( i , k ) B ( k , j ) - 0 i f i < k or k < j,
234
APPENDIX A. A N S W E R S and one of these will be true for all k c { 1 , . . . , N } if i < j, so A B ( i , j ) = ~-]k A(i, k ) B ( k , j ) - 0 for i < j, so A B is also lower-triangular. The proof for upper-triangular A, B is obtained by replacing 'lower' with 'upper' and replacing ' < ' with ~>' in the previous paragraph. []
19. S o l u t i o n : A Pascal program to perform these calculations and graphical displays is available at the author's web site, h t t p : / / w w w . m a t h . w u s t l , edu/ ~victor/software/qube/cube. pas. []
A.3 . . . .
TO CHAPTER
A.3
...
to
1. S o l u t i o n :
235
3 EXERCISES
Chapter
3 Exercises
The 1-periodization of the function f ( x ) - e-lxl, for 0 _< x < 1,
is given by cx~
-1
k=-c~
k=-~
c~
k=O -1
oc
ex E
ek-+-e-xEe
k=-c~
-k
k=O 0
x_l E
O<)
k÷ _xEc k
k=-oc
k=0
e x -4- e 1 - x
e-1 a. That 6~ and T~ are linear transformations follows from their pointwise operation:
2. S o l u t i o n :
T~[au + bvl(t) 5e[au + bv](t)
-
au(t - a) + bv(t - a) - aT~u(t) + bT~v(t); a e - 1 / 2 u ( t / e ) -4- be-1/2v(t/e) - aScu(t) + b6ev(t).
To show invertibility, compute ~_~(t)
-
[~_~](t-
~) -
5e61/eU(t)
--
e-1/2[(~l/eu](t/e)
=
~(t).
~ ( [ t - ~] - ( - ~ ) )
-
~(t);
(
-- e - 1 / 2 ( 1 / e ) - l / 2 u
1 ) [t/e]" (1/e )
Invertibility in the other order is shown by substituting a +--- - a and e +--- l/e, respectively. b. First compute 5~[T~w](t) - e-1/2[Taw](t/e) -- e-1/2W (t + ct). In the other order, 7-~[5~wl(t) - [5~w](t - c~) - - ~ - l / 2 w (t-c~ -7)c. Using parts a and b, we compute v ( t ) - 6~-17~lu(t) - el/2u(et+ct). we may compute r ~ 5 ~ F a j l r g l u ( t ) from Equation 3.14 as follows:
7~ 5~ F v ( t ) -
£-1/2
x
r ( - t-~ - c ) v ( -t-~ r-)+r(~-~-r-)v(~) , ~ ( ~_=d!t) V ( - T - ) -- ~ ( t - ~_T_ ) v ( ~ - t_T_) , v(-~l~),
Thus,
i f tt-~ -~ > 0 , if t -~a < 0, if ~ - 0,
Now note that ~-1/2v ( t ~ _ ) - u(t), while ~-1/2v (a-~ct) - u ( 2 a - t ) , for every t c R. Combining this with a simplification of the range limits gives:
--j-)
~-~6~ F 6-~l~-glu(t) -
u(t) + r ( ~ - t (2c~ t), ~ ,(c~-t)~ u(t) - ~ ( t ~-~--i-)u(2ct - t), u(a), _
i f t > c~, if t < c~, if t - c~.
236
APPENDIX
A. A N S W E R S
Finally, observe that (t-~) r
{1, --
e
ift>a+e,
O,
(a-t){0, r
ift
e
,
if t > ~ - + - e , --
1,
ift
These valuations result in the formula in Equation 3.20. d. Performing the previous calculation, but starting from Equation 3.15, we get
s(~, ~, ~)~(t)
--
7-a (~e S 5 ~ - 1 7 a - 1 u ( t )
{~(t-~ =
--7-)~(t) ~("-~)~(t) ~(t),
~-t
-
~(--7)~(2~
-
t),
+
~(~-"
-
t)
)~(2~
i f a < t <_ a + e , ifa-e
Finally, since the inverse of 7~5~ is 5 e 1 7 - ~ -1 - 51/eT_o~ , we can simplify
s(~, ~, ~)r(~, ~, ~) ---
since S F - Id. from F S - Id.
To~(~C S F
5e-17-~ -1
--
7"oLSeS-e-17-~ 1
The other order, F ( r , a , e ) S ( r , a , e )
= Id,
- Id, likewise follows []
3. S o l u t i o n : Suppose that r is a rising cut-off function and e < T / 2 . Write Fo - F ( r , O, e) and FT -- F ( r , T , e) for the fraying operators at 0 and T, def
respectively. Since u(t + T) - u(t) for all t, the function v - FoFTU satisfies T -< t -< 7" T In particular, that means v I ( t ) - - v ( t ) v(t + T) -- v(t) for all --5for all - e _< t < T + e. Also, v(t) - u(t) if t lies between e and T - e, outside the reach intervals of F0 and FT. Now put I - [0, T]. The second formula for the loop operator, Equation 3.23, simplifies to
{
s(~, 0, ~)~(t),
Liv(t) -
S(r, T, e)v(t), ~(t),
if0
Writing So - S(r, O, e) and ST -- S(r, T, e) for the splicing operators at 0 and T, one calculates
{ SoFo~(t)= ~(t), Liv(t) -
S T F T U ( t ) = u(t),
~(t) = ~(t),
if0
Thus LIFOFTU -- u on I, so ( L I F o F T u ) I -- u I -- u on R. 4. S o l u t i o n : (i) t > 1 implies F u ( t ) - i u ( t ) - u(t) and S u ( t ) - l u ( t ) - u(t). Likewise, t < - 1 implies F u ( t ) - l u ( t ) - u(t) and S u ( t ) - l u ( t ) - u(t).
A.3 ....
TO CHAPTER
3 EXERCISES
237
The rest may be shown directly by modifying Equations 3.18 and 3.19 and the proof of L e m m a 3.4. However, notice t h a t /~ - R F R and S - R S R , where the reflection R is defined by R u ( t ) - u ( - t ) "
RrR~(t)
-
r(-t)Ru(-t) + r(t)Ru(t), f(t)Ru(-t) - f(-t)Ru(t), u(0),
--
r(-t)u(t) + r(t)u(-t), ~(t)u(t)- ~(-t)u(-t), u(0),
=
RSR~(t)
-
=
=
if - t > 0, if - t < 0, if t -- 0,
if t < 0, if t > 0, if t -- 0,
P~(t);
{ {
f(-t)Ru(-t)r(t)Ru(t), r(t)Ru(-t) + f(-t)Ru(t),
if - t > 0, if - t < 0,
u(0),
if t -- 0,
~(-t)u(t)- r(t)u(-t), r(t)u(t) + ¢(-t)u(-t), u(0),
if t < 0, if t > 0, if t -- 0,
s~(t).
(ii) R is a linear transformation, since R[au + bv](t) - a u ( - t ) + b v ( - t ) a R u ( t ) + bRv(t)_ Since F, S are also linear transformations, the compositions F - R F R and S - R S R are linear transformations as well. (iii) R 2 Id, s o / ~ S - ( R F R ) ( R S R ) similarly, S F ( R S R ) ( R F R ) - Id. -
- RFR2SR-
RFSR-
(iv) By the chain rule, R u has the same smoothness as u, with ( - 1 ) ~ u ( n ) ( - t ) . Thus for odd n it is [/>u](~) (0 - ) - [ R F R u ] ( n ) ( O - ) - ( - 1 ) ~ [ F R u ] ( n ) ( O + ) -
R 2 - Id, and
[Rul(~)(t)
-
O,
since by L e m m a 3.4, [FRu](n)(o+) - 0 for odd n. Likewise, [/~u] (n) (0+) -
[RFRu](~)(0+)- (-1)~[fRu](~)(0 - ) - 0 for even n. (v) Note t h a t [Ru] (n) (0+) - - u ( n ) ( 0 - ) - 0 for odd n, and [Ru](n)(0 - ) u(~)(0+) - 0 for even n. L e m m a 3.4 implies t h a t S R u belongs to C d, but then so does its reflection R S R u - Su. Finally, observe t h a t r is a rising cut-off function if and only if f is, so t h a t replacing r ~ ~ in the definitions of F and S, o r / ~ and S, gives two more fraying-splicing pairs. Note too that if r - ~ t h e n / ~ - S and S - F , so t h a t fraying and splicing are the same except for a reflection of t. [] 5. S o l u t i o n : Start by proving that if all the higher-order derivatives of f - f ( t ) exist and are b o u n d e d at all t ¢ +1, and f has k vanishing derivatives at
A P P E N D I X A. A N S W E R S
238 t = il
and also satisfies f ( - 1 ) =
9(t) de__f
0, f ( 1 ) = 1, then
f 0'(sin~t), ,
ift _ -1, if-1
1,
is also smooth for t ~= +1, but has 2k + 1 vanishing derivatives at t = 1 and t=-l. It is clear that g is as smooth as f off t = +1, and that the one-sided limits still match up: 9 ( - 1 - ) = 0 = g ( - 1 +) and g ( + l +) = 1 = g ( + l - ) . Also, all onesided derivatives over the constant parts vanish: g ( n ) ( - l - ) = 0 = g ( n ) ( + l + ) for all n = 1, 2, .... Hence, it remains to evaluate 2k + 1 one-sided derivatives over the nonconstant parts of g near +1. This will be done by induction on k. If k - 0, then ~ g ( + l m ) - ~ f ( s i n ~t)l+l~: - ~ I + I T . one continuous derivative.
cos(-t-~) - 0, so g has
Now suppose that any function with n < k vanishing derivatives at +1 gives a g with 2n + 1 vanishing derivatives there. A function f with k vanishing derivatives certainly has k - 1 < k of them, so the first 2 k - 1 derivatives g ' ( t ) , . . . , g ( 2 k - 1 ) ( t ) vanish at t = +lm. It remains only to show that g(2k)(+lm) = 0 and g(2k+l)(-+-i q:) = 0 as well. But rrt) f (sin -~
_
d ~
2k 1 f ' (sin -~71"t ) . -~71"• cos -~71"t
= 2~1(2k--l) rr [(d)J j=0
J
-2
d-t
7r ] cos~t
x
× [(d)2k-l-JfZ(sinrrt) -~ • Now f ' has k - 1 vanishing derivatives at +1, so by the induction hypothesis, the last factor in the sum vanishes as t --+ +1, for all j = 0, 1 , . . . , 2 k - 1. Thus g(2k)(+lm) = 0. Likewise, using the fact that the first 2 k - 1 derivatives of f'(sin ~t) vanish at +1, the following sum simplifies to the j = 0 term:
(dl2k+l a7
g(t)
-
2j~o(2j/g)71 [(/d J a7
cos
71] t
×
-__
x
=
-[cos
2
t]
~
f ' (sin ~ t )
f'(sinrrt)
~.3 . . . .
TO CHAPTER
3 EXERCISES
239
But cos 571"t --* 0 as t --* +1, so g(2k+1)(+1) - 0, completing the induction. Finally, apply the result just proved to r~(t). Let v(n) be the n u m b e r of vanishing derivatives of rn (t) at t = +1. This is also the n u m b e r of continuous derivatives of rn, since it is infinitely s m o o t h with b o u n d e d derivatives at all t strictly inside or strictly outside ( - 1 , 1). But v(0) = 0, since to(t) is merely continuous at t = - 1 (though it has one continuous derivative at t = 1), and v(n) = 2 v ( n ) + 1 for n = 1, 2, .... This recurrence is solved by v(n) = 2 ~ - 1, proving the result. [] 6. S o l u t i o n :
First note t h a t by 1-periodicity,
~01
sin 2 27rt dt -
a 1 sin 2 27rt dt Jf~g ~0 cos 2 27rt dt.
Thus, integrating sin 2 0 + cos 2 0 = 1 over one period is the same as c o m p u t i n g 2 fo sin2 27rt d t -
fo 1 - 1, proving E q u a t i o n 3.66.
Second, recall t h a t 2 sin A sin B = cos(A - B) - cos(A + B). Thus, if n and m are nonnegative with n =/= m, then n - m ~ 0 and n + m ¢- 0, so by calculus, / v ~ sin 27rnt, v ~ sin 27rmt} -
2
]i 1cos 27r(n -
sin 2 7 r ( n - m ) t
=
m ) t dt - 2
1
~01cos 27r(n + m ) t dt
sin 27r(n + m ) t
11
--
--
0
0,
l0
proving E q u a t i o n 3.65. An almost identical a r g u m e n t from the identity 2 cos A cos B = cos(A - B) + cos(A + B) proves E q u a t i o n 3.64. Finally, recall t h a t 2sin A cos B = s i n ( A nonnegative n and m, (x/~ sin 27rnt, x/~ cos 27rmt} -- 2
B) + sin(A + B). Hence for any
~01[sin 27r(n -
rn)t - sin 27r(n + rn)t] dt.
But f l sin27rktdt - 0 for every integer k, in particular for k - n k = n + m, so b o t h of the integrals are zero, proving E q u a t i o n 3.63.
7. S o l u t i o n :
Since c o s 2 0 -
1 1
~ + ~ cos 20, the Fourier series OO
f (x) - a(O) + x/~ E [ a ( n ) c o s ( 2 7 r n x ) + b(n) sin(27rnx)]
n=l
has just two nonzero terms: a ( 0 ) -
~
and a ( 2 ) -
2~"
m or []
240
APPENDIX
A.
ANSWERS
8. S o l u t i o n : Note that sin(2:rkt - d) - sin(2:rkt)cos(d) - cos(27rkt)sin(d). Hence its real Fourier series has a ( k ) - - sin(d)/v/2 and b(k) - cos(d)/v/-2, with a ( n ) - b(n) - 0 for all n ~ k. This can be converted to a complex Fourier series ~-~ c ( n ) e 2~int with the formula c(k) -
[a(k) - i b ( k ) ] / v ~ ;
c(-k)
for all n ~= +k. Substituting gives c ( k ) -
-
[a(k) + i b ( k ) ] / / v ~ ; : ~ e - i d and c ( - k )
c ( n ) - O, -
i eid. -~
9. S o l u t i o n : The series f ( t ) - ~ - ~ c z c ( n ) e 2Èint converges absolutely and uniformly at every t, by comparison with the absolutely convergent series ~ ¢ 0 In[ -3 that does not depend on t. Likewise, differentiating each term of
the sum gives a series g ( t ) - 27ri ~-~ncz n c ( n ) e2Èint which is uniformly absolutely convergent by comparison with ~-~-~¢0 In -2. Thus g - f~ by Apostol, Theorem 9.14, page 230. [] 10. S o l u t i o n : If n ~ m, then C n ( t ) ¢ ~ ( t ) - 0 for every t C [0, 1], since one of the factors must be zero. The collection {¢k " 0 _< k < N} can be made orthonormal by defining Ck(t) -- v / - N I ( N t k). Its span is the step functions defined on [0, 1) which are constant on subintervals JAN,k+__A1)for 0 _< k < N. 7~ 11. S o l u t i o n : the factor
Make the change of variable x ~ y + k, so d x ~ dy, and extract
e-2~ik~:
fCk(
)
-
/? (x)
=
k)dx
/?
¢(y)ay
_
oo
12. S o l u t i o n : Make the change of variable x ~-- ay, so d x ~-- a d y , and extract the factor a: 9C¢a(~) -
F
e -2~ix~ ¢ ( x / a ) d x - a
(x)
13. S o l u t i o n :
F
e -2~iy(a~) ¢ ( y ) d y - agC¢(a~).
(x)
From Exercise 12, with fa(X) de_f f ( x / a ) , ~--lfa(~) - ~fa(-~)
- aSf(-a~)
we get the identity
- a~-l
Thus, using the hint with the definition 9Clz - s i n c ,
f(a~).
we calculate
9c-1¢(x) - 29c1i(2x) - 9 e l i ( x ) - 2sinc (2x) - sinc (x).
A.3 ....
TO CHAPTER
14. S o l u t i o n :
241
3 EXERCISES
F i r s t n o t e t h a t i n t e g r a t i o n by p a r t s yields
jfa b
cCX b x e cx d x -
x--
C
a
fb
eCX
-- ] a
C
beCb _ aeCa dx--
ccb
-
C
eCa
_
C2
T h u s t h e F o u r i e r i n t e g r a l t r a n s f o r m of t h e h a t f u n c t i o n h ( x ) is:
h(~)
F
-
/o
--
--1 --
h(x)~ -~x~
dx
(1 + x ) e -2~ix~ d x +
e -27rix~ dx q- ;
fl
h(x)~ -~~x~
dx
1
/o1
(1 - x ) e -2~ix~ d x
xe -27rix~ d x - ~0 1 xe -27rix~ dx
1
1
e -27ri~ -- e 27ri~ =
f
-
e 27ri~ t
-2~i~
1 -- e 27ri~
-2~i~
e -27ri~
e -27ri~ -- 1
(_2~i~)2 -2~i~
(-2~i~)~
(27ri~)2
27ri~
7r~
B u t this last is j u s t sinc (~)2. 15. S o l u t i o n :
Use t h e g e o m e t r i c series s u m m a t i o n formula:
Z
-Eu
k=0
N
k=0
1 1--e2~i(rn-n)
N ---~j~-=-~ , =
1-~ ~
k=0
if n 5¢ m;
~
=
N,
~(n\
if n - m,
16. S o l u t i o n :
F2-~
1(1 1). 1
1 f4-~
1 1 1 1
H2 - ~
1(1 1). 1
1
g4-~
1 1
1 1
1 -i -1 i 1 1 -1 -1
1 -i 1 -i
1 i --1 -i
1 -1
1 -1
1 -1
1
~.
]
APPENDIX A. ANSWERS
242 17. S o l u t i o n :
Fix N > 0. Then 1 ~1
Y~(~,y)
-
X
_
{0, 1,
k
j
1 ~1e--27ri(j+n)k
~ ~ -
N
k=0
k=0
ifj+n¢Oandj+nCN; ifj+n-Norj+n-0.
The resulting matrix has ones at (0, 0) and along the antidiagonal (n, N - n), for n - 1, 2 , . . . , N - 1, with zeroes at all other locations• [] 18. S o l u t i o n :
Fix N > 0.
(Vo~ Vl ~ • • • ~ V N - 1
)~
By the previous calculation, for any vector v -
V0
V0
Vl
VN-1
V2
--
VN-2
•
.
o
VN--1
Vl
Thus,
r4 ~-
F~
V0
V0
V0
Vl
Vl
VN-1
~.
- (F~ ) ~
~
- F~
VN-2
V0
Vl --
V2
•
VN-1
Vl
VN--1
VN-1
That is, F } is the N x N identity matrix•
CX2V and C TM are
19. S o l u t i o n :
cos g
cos
co~ cos~
and
cos ~
cos ~37r
c o s ~37r
c o s ~9~-
co~ co~ 7rr cos~ cos~ 571-
57r cos ]-6
77r cos Y6
cos~
cos
co~ cos~
cos~ cos~
respectively. Split the sum for HNv(m) into its odd and even parts:
20. S o l u t i o n : N-1
27rmn
n=0
= ~Z- 1 v(2~)c~s 27rm(2n) N n=0
N 1 27rm(2n+l) + E v ( 2 n + l ) cas
N
n=0
.
A.3 ....
TO CHAPTER N
1
2 E
=
243
3 EXERCISES N
27rmn 2 v(2n) cas N / 2 + E
n=O
1
[27rmn 27rm v ( 2 n + l ) cas L N / 2 +
n=O
Now cas (A + B) - cos B cas A + sin B cas ( - A ) . 27rm gives: B ~ --yH N v ( m ) -- H ~ v e ( m ) + cos
P u t t i n g A ~--
27rmn N/2
and
27rm 27rm N H ~ - v ° ( m ) + sin N H - } v ° ( - m ) '
where v e and v ° are the even- and odd-indexed parts of v, respectively. Finally, we use the -~N-periodicity of and HNV°(m)T as needed for
HNve(m)~_
indices m -- ~N- , . . . , N HN v°(N - m).
1 , and to write H N2_ v ° ( - - m ) -- H N V ° ( N - m )
-[]
2
21. S o l u t i o n : S y m m e t r y is evident, since the (m, n) entry is unchanged when m and n are swapped. To show orthogonality, it remains to establish that for any 0 <_ m , n _< N - 1,
N-1
1 (m 1 1 (n+ 7)(k+ 7) sin 7r(k -~- -~)
71"
k=0 sin
N
1 -Jc-~)
N = { -5-,,
N
0,
ifm--n, if m ¢ n.
But 2 s i n A s i n B - c o s ( A - B) - c o s ( A + B), so the sum can be rewritten as I - I I , in the notation of the proof of Theorem 3.15. But if m ¢ n, then I - I I - 0 as before. On the other hand, if m - n, then the equation holds if 1
N-I~ sin 2 7 r ( n + 7 ) ( k + ~ ) z_.
N
k=0
1
N =
Using Equation 3.59 and the identity sin 2 0 + cos 2 0 - 1 yields N-1
Esin2 k=0
as in the previous proof.
71"(Tt +
1)(k + ½) 1 ~1 N =~ 1-
N 2'
k=0
[]
244
A.4
APPENDIX
... to Chapter
A.
ANSWERS
4 Exercises
1. S o l u t i o n : T h e L a g r a n g e p o l y n o m i a l t h r o u g h t h e points (0, 0), (1,2), (2, 4) is A2(x) - 2x. This is a d e g e n e r a t e case of three collinear points; it yields an i n t e r p o l a t i n g polynomial of degree 1. [] 2. S o l u t i o n :
T h e L a g r a n g e p o l y n o m i a l is px
A2(x) - q -
~
r x
+ ~
px 2
÷
qx 2
r x 2
Its derivative with respect to q is ~qA2(x) - 1 - x 2.
3. S o l u t i o n : a. We use equispaced samples xi - i with h - 1 in E q u a t i o n 4.6 to get the N e w t o n form of Ak. We claim t h a t f ( j ) - 2J gives t h e differences A J f ( j ) - 1 for all j - 0, 1 , . . . , k. This follows from a stronger s t a t e m e n t , A i r ( j ) - 2 j - i for all i - 0 , 1 , . . . , j , which we will prove by i n d u c t i o n on i. B u t 1 - A ° f ( j ) - f ( j ) - 2J proves the i - 0 case, a n d we get the inductive step from the recursive formula: A i f ( j ) - 2 j - i implies A i + l f ( j ) Aif(j)Aif(j1) - 2 j - i - 2 j - l - i z 2 j - l - i z 2J--(i+l). 1)...(n-[j1]) is just the jth t e r m of Ak(x), w r i t t e n in N e w t o n form as in E q u a t i o n 4.6 a n d e v a l u a t e d at x - n .
b. (~.) = ~ ( n - O ) ( n -
c. Since Ak is a polynomial of degree k or less, we have Ak(n) -- O ( n k) as n -~ oc. In fact, the coemcient of x k in Ak(x) is l / k ! , so deg Ak -- k. []
4. S o l u t i o n : Since f itself is a p o l y n o m i a l of degree 2, it equals its C h e b y s h e v polynomial expansion" f ( x ) - c o T o ( x ) + C l T l ( x ) + c 2 T 2 ( x ) , for all x E [ - 1 , 1]. T h e expansion coefficients m a y thus be found by the m e t h o d of u n d e t e r m i n e d coefficients. B u t T o ( x ) - 1, T1 (x) - x, a n d T 2 ( x ) - 2x 2 - 1, so: 1 - x2
-
SO C1 - - 0, C2 _
co.
1 + Cl.X
- - 31'
andc0-
-~- c 2 .
(2x 2 -
1) -
[co - c2] -Jr-[Cl]X -Jr- 2 x 2 [ c 2 ] ,
1 2"
[]
5. S o l u t i o n : Pick two sample points X k _ 1 < X k . T h e n Y k - 1 - m x k - 1 + b a n d Yk - m x k + b, so t h e piecewise linear function a p p r o x i m a t i n g f on the interval x k-1 <_ x _< x k will be xH
y (x - x k - 1 ) + Y k - l ( X k - x) X k -- X k - 1
6. S o l u t i o n :
=mx+b.
.4.4 . . . .
TO CHAPTER
245
4 EXERCISES
Equispaced piecewise linear evaluation e p w l i n e a r ( x, y [ ] , a, b, N ) : [0] I f xb, t h e n r e t u r n y[N] [2] Let h = ( b - a ) / N , l e t k = f l o o r ( ( x - a ) / h ) , [3] R e t u r n ( y [ k + l ] * d x + y [ k ] * ( h - d x ) ) / h
7. S o l u t i o n :
dx=x-k*h
First note t h a t y l / y 2 < 0 and y 2 / Y l < 0 if Y l y 2 < 0. T h e n x2Yl
XO - - X l
let
-- xly2
-- XlYl
(x2 -- x l ) Y l
÷ XlY2
--
~
X2 -- Xl ----
Yl - Y2
Yl - Y2
~
O~
~
O.
1 - y_a Yl
and x2Yl Xo -- X2
-- xlY2
y2(x2 -- X l )
x2yl + x:y2
--
--
--
X2 -- Xl --
Yl-Y2
Yl-Y2
yY2l _ 1
8. S o l u t i o n : First note t h a t the formula for x, is preserved by a change of sign (Yl, Y2, Y3) ~ ( - Y l , - Y 2 , - Y 3 ) . Thus we may assume without loss of generality t h a t Y2 ;> Yl and y2 > y3, so x, will be a local maximum. Second, note t h a t the denominators of x , - Xl and x3 - x , will be the same, namely D
-
xl(y3 - y ~ ) + x~(yl - y3) + x3(y2 - yl)
=
y~(x~ - x~) + y~(x~ - Xl) + y~(Xl - x~).
Puttingp-x2-xl>0andq-x3-x2 we see t h a t
>0, sothatp+q-x3-xl>0,
D -- (p + q) ( y 2 -
since ~ y 3
÷ ~Yl
>0,
+ P q y3 - P +q q y l
lies between Yl and Y3, hence below y2.
It remains to show t h a t the numerators of x , - X l positive. But,
and x 3 -
x,
are b o t h
1 x, - xl
=
2D (-
x ~ ( y 3 - Y2) + ( x 2 - 2 X l X 2 ) ( Y l ÷
__
1 ((x~ 2D
-- 2XlX3)(Y2
÷ X 2 -- 2XlX3)y
-
__--
( x2
-
2XlX
-
-
Y3)
Yl))
--
2 --(X
-
2 ÷ X 2 -- 2XlX2)y
+
2XlX )y )
1 ((X3 __ X l ) 2 y 2 __ (X2 -- X1)2y3
2D
-- [(X3-
Xl) 2-
(X2-
Xi) 2] Yl).
3
A P P E N D I X A. A N S W E R S
246 Putting r -
(x2-
Xl) 2 > 0 a n d s -
(x 3 - - X l ) 2 -- (X 2 -- X l ) 2 >
0
gives
r + 8 - - ( x 3 -- X l ) 2 > O, SO
x , - x l - ~ - ~ 1 (r + s)
Y2 -- ~ Y 3
--
r+s
r+s
>0,
Yl
8 since 7 -r ~ Y 3 + 7-~Yl lies between Yl and y3, hence below Y2.
Likewise, x3 - x,
--
1
2D
((2XlX3 - x21)(y3 - y2) + (2x3x2 - x2)(yl - y3)
+ __
1 ((x2 2D
yl))
q- X~ -- 2 X l X 3 ) y 2 - - ( X 2 __!._X 2 __ 2 X l X 2 ) Y l -- (X21 -- 2 X l X 3 -- X 2 -Jr- 2 X 3 X 2 ) Y 3 )
=
1
2D
((x3 _ Xl)2y 2 _ (x3 - x2)2yl
-- [ ( X 3 Putting u U -[- V
(X 3 - - X 2 ) 2 >
0
Xl) 2-
and v -
X2) 2] Y3).
(X3-
(X3-
X l ) 2 -- (X 3 -- X2) 2 >
0
gives
_ (X3 -- Xl )e > 0, SO X3 -- X , m ~
U since ~--47Yl --I--
9. S o l u t i o n :
V
1 (u+v)(
Y2
-- ~ Y l
u+v
v u+v
Y3
)
> 0,
Y3 lies between Yl and Y3, hence below y2 •
For M < N, define the partial sum N
n=M N SO ( P u ) o N -- ~
(¢n, it)Cn for any N k 0. By Lemma 2.9,
n--0
N
II(P )ON
-
I
I
n=O
since {¢1, qhl,..., qhN} C B is a finite orthonormal set. By Bessel's inequality N (see Exercise 14(a), Chapter 2), we have X:,~=0 I(¢n,U} 12 < Ilul 2 for every N > 0. This can only happen if for every e > 0, there is some integer T + > 0 such that [I(PU)MN[I < e for all N > M > T +. A similar argument applied to (Pu)MO shows that for each e > 0 there is some integer T~- < 0 such that M < N < T Z implies II(PU)MNII < e. Choosing T~ de_f m a x { _ T _ , T + } satisfies Definition 3 and shows that Pu c span B. []
A.4 . . . .
TO C H A P T E R 4 EXERCISES
247
10. S o l u t i o n : For integers M < N, let fMN(t) def - - ~ n =NM C ( n ) ¢ ( t -- n ) e span { ¢ ( t - n ) : n E Z}, and note that this partial sum is bounded, continuous, and compactly supported on the interval [ M - 1, N + 1]. Thus fMN E L2(R), JM-1 with [IIMNII2 - F y+l IfMY(t)l 2 dr. But f M Y is piecewise linear and interpolates the points { ( M - 1,0); ( M , c ( M ) ) , . . . , ( N , c ( g ) ) ; ( g + 1, 0)}, so we may compute the square integral in pieces. To do this, we first find the formula for the square integral of a linear function g through (0, y0) and (1, yl), using a special case of Equation 4.13:
j£01Ig(t)l = dt - j'£01Ity~ + (1
-
1(2ly0
t)y01 = d r - ~
+ lyl
12+
y0 + yll
2)
•
We now apply this formula to evaluate the integral of IZMN(t)I ~, which is linear between adjacent integers. Accounting for the end terms, we get" 1
If.N
Nit(M)
2
1 1(
+ ~ N
1
n--M
1
+ 5lc(N)q 2 +
n=M
1(
+ g
)
c(n)l 2 + Ic(n+l)l 2 + It(n) + c ( n + l ) l 2
N1
)
I~(M)I 2 + ~:~ I~(n) + c(n+l)J 2 + I~(N)I 2 • n--M
But IP + ql 2 < 21pl ~ + 2lql 2 for any p, q C C, so we may estimate the second term as follows: 1
o <_ ~ Therefore,
N-1
I~(M)I ~ +
) 2 N I~(,~) + c(n-I-1)l 2 ÷ Ic(N)l ~ _ N ~ I~(n)l ~.
n--M ~
n--M
N
N
1 5 ~
Ic(n)12 -< IlfMNll2 <- ~
n--M
c(n)12"
(A.1)
n--M
If f C L2(R), then Ilf-NN[I --* Ifll as N ~ oc, so by the left-hand inequality, N [2 the partial sums ~ n = - N [c(n) increase and thus converge to something no bigger than 311Ill ~ ~s x --, o~. Therefore, c belongs to e 2. Conversely, if c E e 2, then y'~nN___N c(n)l 2 converges to I1~11~ as x --, oo, so for every c > 0 there is some T - T~ > 0 such that for every N _> M > T, N
-M
I ( 11
÷ n--M
n---N
A P P E N D I X A. A N S W E R S
248
But for all integers M ' < M < N < N', we have
M-1 fM,N,(t) - fMN(t) -
E
N' c(n)¢(t- n)+
n),
E
n=N+l
n=M'
so by the right-hand inequality in Equation A.1, for any N' > N > T~ and M ' < M < -T~, we will have
M-1
N' [c(n)[ 2 < ~ .
Ic(n)12 +
I l f M ' g ' - fMg[] 2 < ~ n=M'
n=N
But this means that the partial sums f M N converge as N + oc and M + - o c to some limit f C span { ¢ ( t - n ) ' n C Z} satisfying Ilfll 2 <_ Ilcll2, so this f belongs to L2(R). [] 11. S o l u t i o n : a. A counter that always fails to count the first item, but never fails to count all subsequent items, will be inaccurate by one count but with zero variance. b. A perfect counter has zero imprecision and zero inaccuracy, since recounting will always yield the same correct measurement. But its measurements, nonnegative integers, are quantized with interval 1. [] 12. S o l u t i o n :
a. First note that l ( N t -
k) - 1 if and only if t c [ ~ , k+__A1]. Thus
Ill - / N i l 2 -- f l If -- fNI 2 dt breaks up into
N-1/i+l
~ It
k
/VI 2 d t -
k=0
~lj~0~ k=0
Itl 2 d r -
3 N 2"
We have performed the substitution t ~-- t + k in the k th integral. b. Since Ilfll 2 - fo Itl 2 dt - 1/3, we simply use Equation 4.36 with fs - f and fq - fN -- f to compute S N R ( f N ) - 20 log 1 ON. [] 13. S o l u t i o n : a. That integral is the volume under the graph of f, and f(x, y) 2 is nonzero only if (x, y) lies in the subset of Q bounded by the lines x - 0, y - 1, and x - y. This is the upper-triangular half of Q, and has area 1/2, so the volume ffQ f ( x , y ) d x d y ( 2 ) ( 1 / 2 ) - 1. b. Using Equation 4.38, we get Cy - 2y and so f ( x l Y) - (2y)-l f ( x, Y). c. Using Equation 4.37, we compute
0, P r ( X C [a,b]ly ) - { ( y - a ) / y ,
(b-a)/y,
if 0 _ y ~ a; ifa
A.4 . . . .
TO C H A P T E R 4 EXERCISES
249
d. Using Equation 4.43, and writing I -
R:(d,y)
[0, 1], we compute
~I " "~I [d(xl' " " 'XN) - Yl 2 x × f ( x l l Y)"" f ( x g l y ) d x l ' " dxy (2y)-N
~II " " " ~I l m a x { X l ,
. . . , X N } -- Yl2 ×
× f ( x l , y ) ' ' " f ( X N , y) d x l " " 2 N (2y) -NN!
dxN
f o od xYl f o Xdlxj2~" ' "o xN-1IX1 -- yl 2 dXN
--__ y - N N ! f0 y IX1 -- yl 2
XlN-1
x -1 ix 1 _ focal
=
Ny -N
=
N y - N [ xNly2N
dXl
(N-
y 2 dxl
2xNI+IYN+I+ N+2xlN+2] 0
_
y2 1
]VT1 t - N + 2
-
(N+I)(N+2)"
The factor N! appears on the third line since that is how many permutations there are of the N variables 0 _< XN < "" < Xl < y, which is the only ordering that we integrate. Iterating the N - 1 inner integrals successively produces XN-1, X2N_2/2!,... , x N - 1 / ( N - 1)!, as in Equation 4.42, and the remaining steps are straightforward. Ny in the above calculation, which produces Substituting y ~ E(d l y ) - N+I Var(d I y ) _< R 2 (d, y), gives y
Var(d I y ) - ~
XlN-1 Xl
Ny N+I
y2
2
d x l --
(N + 1)2(N + 2)"
Thus v/Var(d I y) - O(1/v/N 3) and R(d, y) - O(1/v/N 2) as N - , oc, so both decrease faster than the 1 / x / ~ rate one might expect from the Cram~r-Rao lower bound, which of course does not apply. []
A P P E N D I X A. A N S W E R S
250 ~b
] /1/a
(-1/2 < b < 0)
(-1< b _<-1/2) +l
-b
1/a
-1/2
I I
liI iT.1 b~.lill /2
~.. i"
t
I I'
"
-1/2
Figure A.I: Graphs of Haar wavelets w(at) and w ( t - b) in the configuration of 1 where their inner Case 6 and the two subcases o f - 1 < b < 0 and 0 < a < 2(b+l) product is nonzero.
A.5
... to Chapter 5 Exercises
1. S o l u t i o n : The graphs are shown in Figure A.1. In Case 6, the integrand of f ~ ( a t ) w ( t - b)dt is nonzero only on [0, 1], where half the time it is 1/xfd and the other half it is -1/v/-a. To prove Equation 5.3, note that
f
fb+l
ff~(at)w(t - b)dt -
(1)(-1) dt - - ( b + 1),
i f - 1
1
2"
dO
Otherwise, if - ~1 < b < 0, the integral splits into the sum of three pieces:
j~0 b-+-1
/2(b+ 1 ) (1)(1) dt + Jb+ 1
fb+l
(1)(--1) d t + J2(b+ 1) ( 1 ) ( - 1 ) dt.
The first two integrals cancel and the third evaluates to b. Multiplying by v/~ gives the result. [] 2. S o l u t i o n : It is evident that p(a, b) - p(a', b')if and only if a - a' and b - b', since two matrices are equal if and only if their coefficients are equal. Thus p is one-to-one, and it remains to check that p preserves the group multiplication. But
p(a',b')p(a,b)
_
(a ~
=
p(a'a, a'b + b')
k
b~
a
o 1)(o
-
p ( ( a ' , b ' ) ( a , b)).
3. S o l u t i o n : Right invariance of the integral requires that the Jacobian of the change of variable b ~ b b ~ is the constant 1. Since db - k(b)dadb -
A.5 . . . .
TO C H A P T E R 5 EXERCISES
251
k(a, b)dadb for some unknown function k, the right invariance condition can be written: da '1
da"
k(bb') k(b)
_ k(bb')
d(bb') db
m
db"
db"
aI 0 b' 1
-
k(bb')
la'l.
(a, b)(a', b') - (a", b") defines the coordinate functions a" - aa', b " - ab'+ b from Equation 5.5. Thus k(bb') - T~,Ik(b), so putting b - (1, 0) to force b b ' - b ' yields k ( a , b ) - lal-lk(1, 0).
Here b b ' -
But a > 0, so
la[ -
a.
Choosing k(1, 0) -
1 gives the normalized right
invariant integral of f over Aft: f ( b ) db
f(a, b)
def
ff
---ec
dadb
--0
Note that this differs from the left-invariant integral on Aft. 4. S o l u t i o n :
Translating Equation 5.21 by t ~-- t - k, write
c~
J
Z2-J/2Wu(2 j k)-
lim Z 2 - J / 2 W u ( 2 j k ) -
j=l
where CkJ (t)
lim (¢J u}
j=l
-
-
CJ (t
-
-
k) --
E j =J I ~1W ( - ~t - .k )
Equation 5.4 then implies:
if t < k or t > 2 a + k;
0,
i-2
--2 -J,
ifk
J.
Finally, O0
J--,oo
j=l
dk
U
(t) d t - 2
-J/ d k+ l
u(t) dt
fk-t-1
=
[
u(t)dt
-u(k).
dk
5. S o l u t i o n " Function ¢ is differentiable by calculus techniques everywhere except possibly at the origin, where it must be shown that the limits of ¢ and all its derivatives are zero. But l i m ~ 0 ¢(~) - 0 because - ( l o g ~1) 2 ~ - o c as ~ ~ 0. For the derivatives, it is enough to prove that at each ~ ~= 0, P(l°g I~l)e -(~°g I~1): ¢(d)
_
U
(A.2)
A P P E N D I X A. A N S W E R S
252
where P is some polynomial. But this can be established for every d > 0 by induction. Starting with d -
1 , it is immediate that ¢'(~) -
-21og15]e_(logl~l) 2 at each
Next, assuming that ¢(a) satisfies Equation A.2, calculate
¢(d+l) (~)
d
=
d~
=
P ' ( l o g I l) -
log
p ( l o g I l) - d P ( l o g I l) ~d+l
which is of the desired form with a new polynomial Q(z) = - 2 z P ( z ) + P ' ( z ) dP(z). This completes the induction step. To complete the solution, note that lim ¢(d)(~) _ lim P(log [~[) -Oog I~l)~ ~---~0 ~---~0 ~d e z 0, by L'H6pital's rule.
[]
6. S o l u t i o n : For any fixed d and any n _> O, ¢(n)({) < 1/]~]d as ~ --+ - c ~ , since ¢(n)({) = 0 for all ~ < O. To show that for some positive constant C, [{[de(n)({) _< C as { --+ +oc, note that [{]d¢(n)(~) _ {dP(lo/~)e_(log~)2 = ~d-~-l°g~P(log{), where P is some polynomial depending on n. But this expression will tend to zero as ~ -+ oc, since the exponent d - n log will become more and more negative as ~ -+ oo, eventually cancelling the fixed-degree growth from P(log ~). [] 7. S o l u t i o n :
One solution is to use Plancherel's formula to write:
Wu(a, b) -
e -2~ib~ ¢(a~)3Cu(~) d~. (:X:)
Again by Plancherel's theorem, ~'u(~) is square integrable. Let the other factor, e-2~ib~¢(a~), be called ~ab(~). Solution 5 implies that 'I2ab(~) is continuous in ~. For any a ¢- 0, Solution 6 implies that it decreases rapidly enough as ~ -~ +oc to be absolutely integrable: being O(l~[ -2) is sufficient. Thus, it is square-integrable, so ~ab(~).Tu(~) is integrable, and the integral converges absolutely. Next, note that: 0 (~ab(~)
02
Oa2Oab(~)
~e-2~ib~¢'(a~)" ~2e-2~ib~¢,,(a~)
--
Oa
--
02 OaOb ~ a b ( ~ )
02 -- ~(I2ab(~)
0 Oab(~) -- --27ri~e -2~ib~ ¢(a~); (92
cob2 O a b ( ~ ) --
--
--271"i~2
--47r2~2e-2~ib~¢(a~);
e-27rib~ ¢ I
(a~).
By Solutions 5 and 6, all of these are continuous in ~ and, for a ~: 0, decrease fast enough to be absolutely integrable and square-integrable with respect to
A.5 ....
TO CHAPTER
5 EXERCISES
253
~. Thus, it is legal to differentiate once or twice with respect to a or b under the integral sign: 0 W u ( a , b) Oa
-
0 Wu(a Ob
-
b)
F
~e -2~ib~ ¢' ( a { ) Y u ( { ) d{;
OO
-2
i
/?
OO
It remains to show t h a t these derivatives are continuous functions of a, b away from the line a = 0. But in b o t h cases, this follows from the observation t h a t the integrands are continuous functions of a, b. [] 8.
Since w ( x ) - ;g[-l~,l/2](x), Plancherel's t h e o r e m implies I l w l l -
Solution:
11~[-1/2,1/2] 9.
Solution:
that Yw
=
II =
1.
[]
By the previous solution and by combining integrals, calculate Thus,
~[-1,-1/2]u[1/2,1].
Cw - -
/
d~ f~edit
~[-1/,-1/2]u[1/2,1](~)]~
-- 2
-- 2 log 2 <
(20,
which in particular means t h a t w is admissible. 10. S o l u t i o n :
[]
T h e Fourier integral t r a n s f o r m of w is ~ e-2"iX~w(x) dx. (:X)
1
51 and w ( x ) - - 1 if ~ < x < 1 t h a t simplifies to
Sincew(x)-lif0<x< 1
/0
1
e
-
"
e
--
27ri~
" []
11. S o l u t i o n : It is necessary to show t h a t (¢j, Ok} -- 5(j -- k). But Plancherel's t h e o r e m allows writing --
-
e 2~i(k-j)~ d{ - 5 ( j -
k),
J-l~2 since ¢"k({) -- e2'~ik~sin-"~ ({) 12. S o l u t i o n : E
-
e2rrik{)(.[_l/2,1/2](~ ). 1 o v~"
Show t h a t E k g(2k) - - f'~-k g(2k + 1) g(2k)
-
k
E(-1)2kh(2M-
1 - 2k) -
k
=
Eh(2(M-k)-l) k
Eh(2M-
1 - 2k)
k
-
Eh(21+l) l
--
1 V/2'
APPENDIX A. A N S W E R S
254 after the substitution 1 ~ M -
Eg(2k+
1)
-
k. A similar change of the index gives:
E(-1)2k+lh(2M-1 - ( 2 k +
k
1))
k
-Eh(2(M-k-1))
-
-Eh(2/)
k
13. S o l u t i o n :
=
1
1 First note that 1 + c 2 - 8 - 4 v ~ - 4c, so c/(1 + c 2) - ~.
h(2)-
Thus
c(c + 1) c+ 1 (2 - v/-3) + 1 3 - x/~ v / ~ ( 1 + c 2 ) = 4v/~ = 4v/~ = 4v/~ .
Likewise, h(3)-
c ( c - 1) c-1 1-x/~ v ~ ( l + c 2) = 4v/2 = 4x/~ "
Finally,
1 h(0)-v/~
1+~ h(2)-
1
4-~-;
h(1)-~-h(3)-
3+~ 4v/~ .
14. S o l u t i o n : We begin by substituting t ~- 2 - J - i t and then multiplying by 2 -(j+1)/2 on both sides of Equation 5.33:
2-(J+l)/2¢(2-J-lt- It) -
E
h(k)2-J/2 ¢ ( 2 - J t -
2n - k)
k
=
E
h ( k ' - 2n)2 -j/2 ¢ ( 2 - J t -
k').
k~ Taking inner products on both sides with u gives the first result. Similarly, we may substitute t ~- 2 - J - i t in Equation 5.50 to get
2-(J+l)/2~)(2-J-lt- rt) -
n and then multiply by 2 -(j+l)/2
Z g(k)2-~/~ ¢(2-Jt- 2 ~ - k) k
= Z g(k'- 2~)2-~/~ ¢(2-Jt- k'). k'
Taking inner products on both sides with u gives the second result. For the third result, we take inner products with u on both sides of Equation 5.55. []
A.5 . . . .
TO CHAPTER 5 EXERCISES
15. S o l u t i o n :
255
First check the odd and even cases to show t h a t for any integers
P, q,
a. S u b s t i t u t e p ~-- x - b and q ~-- y - a to get
2
x-b 2
+a
<
2
+b
-
I
Thus [2 [~-~] + a, 2 k ~ - J if and only if b - a - 1. b. S u b s t i t u t e p ~-- x -
x-b+l) 2
2
2
+a
-
x-(b-a-i);
+b
-
y+(b-a-1).
+ b] _D [ x - ( b - a -
b and q ~- y -
1), y + ( b - a -
1)], with equality
a to get
l+k aJ2 Ix bl l+
a2
x b+12
T h e n s u b s t i t u t e p ~-- x - d and q ~ y - c to get
l+k cJ Fx2
1+ c12
x +12
Adding these inequalities and simplifying the smaller right-hand side to 1 + y -- X ÷ b - 2 - 1 ÷ d - 2 - 1 finishes the proof. [] 16. S o l u t i o n : First note t h a t if P - 2 P ~ is even, then for each k E Z there are unique j E Z and k' E {0, 1 , . . . , P ' - 1} such t h a t 2k - 2 ( k ' + j P ' ) and 2k + 1 - 2(k' + j p t ) + 1. Thus, for any finitely-supported sequence f with P - p e r i o d i z a t i o n f p , we can sum P~-I
P~-I
k 1=0
k'=0
P/-1 j
k'=0
j
k
and likewise, gtm 1
P~-I
E
f p ( 2 k ' + 1)
-
M=0
E k'--0
Ef(2k'+jP+l) j
P'-I
=
E k'=0
E/(2(k' j
+jP')
+ 1)
-
Ef(2k+l)" k
S u b s t i t u t i n g normalized h or g for f shows t h a t normalization holds for hp and gp.
APPENDIX A. ANSWERS
256
Second, note t h a t if e a n d f are f i n i t e l y - s u p p o r t e d sequences with respective P - p e r i o d i z a t i o n s ep a n d fp, t h e n P-1
E ep(k'+ 2n)fp(k'+
2m)
--
kt=0 P-1
= E E E e(k' + 2n + jP)f(k' + 2m + iP) k'=O
j
i
P-1
= E E E e(k' + jP + 2n)f(k' + jR + 2 ( m k'=0
j
+
1P')),
l
after s u b s t i t u t i n g i +-- 1 + j. T h e sums over 0 _< k' < P a n d j E Z c o m b i n e into a s u m over all integers k C Z, a n d t h e 1 a n d k sums m a y be i n t e r c h a n g e d , giving P-1
E ep(k' + 2n)fp(k' + 2m) - Z E e(k + 2n)f(k + 2 ( m k'=O
l
+
1P')).
k
If e = f = h a n d h is self-orthonormal, t h e n the inner s u m over k is 5(n(m + lP')). T h u s t h e o u t e r s u m over 1 is 5e,(n- m), which is 1 if a n d only if n m ( m o d P ' ) ; otherwise it is zero. T h e same holds i r e = f = g is self-orthonormal. If e = h a n d f = g are i n d e p e n d e n t , t h e inner s u m over k is always zero, so t h e t o t a l is zero. This establishes periodic i n d e p e n d e n c e a n d self-ort honormality. Finally, P'--I
Z
f (2k' +
+
-
k'--0 P'-I
= E k'=O
E E f(2k' + n + jP)f(2k' + m + iP) j
i
P~-I
= E k'=0
E E f(2(k'+jP') + n)f(2(k'+jP') + m + (i-j)P), j
i
so s u b s t i t u t i n g i ~-- l + j a n d k' s u m m a t i o n s into one makes this
~-- k - j P'
a n d combining t h e k' a n d j
~ f(2k + n)f(2k + m + 1P). k
l
T h e 1 a n d k sums m a y be interchanged. T h e cases f ~ h a n d f ~ g give pt-
1
M=O
l
k
A.5 . . . .
TO CHAPTER 5 EXERCISES
257
g/-- 1
g.(2k + k'=O
)g.(2k
-
l
Z
g(2k + )g(2k
+ 1P).
k
If h and g satisfy the completeness condition, adding these together gives E 1 5 ( n - (m + IP)) = 5 g ( n - m), proving periodic completeness. []
17. S o l u t i o n : The following is a Standard C implementation. implementing the inverse filter transform:
We begin by
Contents of ipcqfilt, c
int mod(int x, int M) { /, xZM for M>I and any x ,/ if(x
R e c o n s t r u c t i o n from Mallat's Periodic Wavelet E x p a n s i o n ipdwt( u[], N, J, h[], g[], L ): [0] If J>O, then do [i-] to [4] [I] Compute ipdwt(u[], N/2, J-l, h[], g[], L) [2] Allocate temp [0] =0,..., temp [N-l] =0 [3] Compute ipcqfilter(temp[], u[], N/2, h[], g[], L) [4] For i=O to N-l, let u[i] = temp[i]
For practical reasons, we should place the allocation and deallocation of temp [] as close as possible to the filter transform. This frees unneeded mereory for the recursive function call. In Standard C, this becomes:
APPENDIX A. ANSWERS
258
Contents of ipdwt, c #include
}
Finally, we generate the samples for a graph of the Daubechies 4 wavelet and scaling function. We start with an array containing a single nonzero wavelet coefficient at what would be level 5 of a 128-point periodic discrete wavelet transform, and invert to get the one-wavelet signal t h a t would have produced it: Standard
C Program:
Graph Daubechies 4 Functions
#include <stdio.h> #define L 4 static const float h[L] = { 0.48296291314453416, 0.83651630373780794, 0.22414386804201339, -0. 12940952255126037}; static const float g[L] = { -0. 12940952255126037, -0.22414386804201339, O. 83651630373780794, -0. 48296291314453416 } ; #include "ipcqfilt. c" #include "ipdwt. c" int main (void) { float scaling [128] ={O} , wavelet [128]={0}; int i; scaling[l] =i. O; wavelet [5] =i. O; ipdwt( scaling, 128, 5 ); puts("# 128 point Daubechies 4 scaling, level 5""); for(i=O; i<128; i++)printf("~,lO.6f\n", scaling[i]); ipdwt( wavelet, 128, 5 ) ; puts("# 128 point Daubechies 4 wavelet, level 5"") ; for(i=O; i<128; i++)printf("°/.lO.6f\n '', wavelet[i]); return 0 ; The indices 1 and 5 are chosen so t h a t the functions, of scale 2 5-7 = ia relative to the width of the plot, are offset by 1 from the left edge and thus
A.5 . . . . TO CHAPTER 5 EXERCISES
259
Figure A.2: Graphs of Daubechies 4 wavelets. Left: scaling function ¢. Right: mother function ¢. approximately centered. The results are plotted in Figure A.2. 18. S o l u t i o n : a. After steps 1 and 2, u(2n + 1) contains u(2n + 1 ) - u(2n) and u(2n) contains l[u(2n + 1 ) + u(2n)]. After steps 3 and 4, those values are scaled so that u(2n + 1) contains [u(2n + 1 ) - u(2n)]/x/2 and u(2n) contains [u(2n + 1) + u(2n)]/v/2. This shows that h a a r l ± f t () implements a combined filter transform with the Haar filters of Equation 5.46. b. After steps 1' and 2', u(2n) contains u(2n)/sqrt2 and u(2n + 1) contains x/2u(2n + 1). After steps 3' and 4', those values are combined so that u(2n) contains [u(2n)-u(2n+l)]/V~ and u ( 2 n + 1)contains [u(2n)+u(2n+ 1)]/v~. This shows that ± h a a r l ± f t () implements an adjoint filter transform with the Haar filters of Equation 5.46. c. Write v(2n) d~j [u(2n + 1) + u(2n)]/X/~ and v(2n + 1) dej [u(2n + 1) -u(2n)]/v#2 for n = 0, 1 , . . . , q - 1. Then v is a copy of u after the (a) substitutions. Applying the (b) substitutions leaves [v(2n) - v(2n + 1)]/x/~ = u(2n) at index 2n, and [v(2n) + v(2n + 1)]/v/2 = u(2n + 1) at index 2n + 1. d. We use induction on J to prove that for any dq E Z +, the function l d h t 0 (u [], J, dq) is inverted by i l d h t 0 (u [], J, dq). Case J = 0 holds since both l d h t 0 (u [], 0, dq) and l d h t 0 (u [], 0, dq) are the identity on one-point signals u. For J > 0, assume that i l d h t 0 ( u [ ] , J - l , d q ) recovers the array u after it is transformed by ± l d h t 0 ( u [ ] , J - l , d q ) , for all dq c Z +. Now consider l d h t 0 ( u [ ] , J , d q ) . This consists o f h a a r l ± f t () applied to the array elements u(0), u ( d q ) , . . . , u([2 a - 1]dq), followed by l d h t 0 ( u [ ] , J - 1 , 2 . d q ) which acts just on the even elements u(0), u(2dq),..., u([2 J - 2]dq). By the inductive hypothesis, that is inverted by ± l d h t 0 ( u [ ] , a - l , 2 . d q ) , which inverts the Haar-transformed even elements u(0), u(2dq),..., u([2 a - 2]dq), followed by i h a a r l i f t () applied to u(0), u(dq),..., u([2 a - 1]dq). [] 19. S o l u t i o n : The filter transform w s 1 9 7 f i l t e r ( ) is already implemented, so we simply use it recursively, following ws142dwt ():
APPENDIX A. A N S W E R S
260
Figure A.3: Graphs of 9,7-biorthogonal wavelets on 100 points. Left" index 32, level 3. Middle: index 36, level 4. Right: index 41, level 5.
W S Lifting: 9 , 7 - B i o r t h o g o n a l D i s c r e t e W a v e l e t T r a n s f o r m wsl9?dwt( u [ ] , N, dq, J ): [0] If J>O, then do [i] to [2] [i] Compute ws197filter( u[], N, dq ) [2] Compute ws197dwt( u[], N, 2,dq, J-i ) The inverse filter transform requires one normalization, two updatings, and two predictions, with inverted coefficients: W S Lifting: I n v e r s e 9 , 7 - B i o r t h o g o n a l wsl9?ifilter( u[], N, dq ): [0] Compute l n o r m a l i z e ( u [ ] , N, dq, [1] Compute wslupdate( u [ ] , N, dq, [2] Compute w s l p r e d i c t ( u [ ] , N, dq, [3] Compute wslupdate( u [ ] , N, dq, [4] Compute w s l p r e d i c t ( u [ ] , N, dq,
Filter Transform l/zeta97 ) -delta97 ) -gamma97 ) -beta97 ) -alpha97 )
Reconstruction from the output coefficients is accomplished by the inverse" W S Lifting: 9 , 7 - B i o r t h o g o n a l I n v e r s e W a v e l e t T r a n s f o r m wsl9?idwt( u [ ] , N, dq, J ): [0] If J>O, then do [i] to [2] [I] Compute ws197idwt( u[], N, 2*dq, J-I ) [2] Compute ws197ifilter( u[], N, dq ) To plot the requested wavelets, we create three arrays u0, Ul, U2 of 100 locations each. We put zeroes everywhere except for u0(16) - 1, u1(16) - 1, and u2(31) - 1, then call ws197idwt(u0,100,1,3), w s 1 9 7 i d w t ( u l , 1 0 0 , I , 4 ) , and ws197idwt(u2,100,1,5). The piecewise linear functions through the three resulting sequences {(k, ui(k))" 0 < k < 100}, i - 1, 2, 3, are plotted in Figure A.3. [] 20. Solution: First implement hMf-sample symmetric prediction and updating, by modifying wslpredict () and wslupdate ()"
A.5 . . . .
261
TO CHAPTER 5 EXERCISES
HS Lifting: Prediction Step h s l p r e d i c t ( u [ ] , N, dq, coeff ): [0] Let i = dq [l] While i
HS Lifting: U p d a t i n g S t e p h s l u p d a t e ( u [ ] , N, dq, coeff ): [0] Let ± = 0 [1] While i+dq
do [2] t o [3] u[i] += coeff*u[i+dq] i += 2*dq
To implement the Haar filter transform by lifting, we predict with c~ = - 1 , update with ~ - ~, 1 and normalize with ¢ - v~. When N / d q is odd, the last coordinate should be left alone, rather than divided by coeff, if we want the transform to be orthogonal: O r t h o g o n a l Lifting: Normalization Step onormalize( u [ ] , N, dq, coeff ): [0] [1]
[2] [3] [4]
Let i = 0 W h i l e i+dq
do [2]
to
[4]
Replace u [ i ] ,= coeff Replace u[i+dq] /= coeff Increment i += 2,dq
The inverse has the same operations in reverse order, with inverse coefficients:
HS Lifting: Haar Filter Transform h s l h a a r f i l t e r ( u [ ] , N, dq ): [0] Compute h s l p r e d i c t ( u [ ] , N, dq, alpha ) [1] Compute h s l u p d a t e ( u [ ] , N, dq, b e t a ) [2] Compute onormalize( u [ ] , N, dq, z e t a ) HS Lifting: Inverse Haar Filter T r a n s f o r m h s l i h a a r f i l t e r ( u [ ] , N, dq ): [0] Compute onormalize( u [ ] , N, dq, 1 / z e t a ) [1] Compute h s l u p d a t e ( u [ ] , N, dq, - b e t a ) [2] Compute h s l p r e d i c t ( u [ ] , N, dq, - a l p h a ) Finally, inspired by ws142dwt() and ws142idwt(), we employ these filter transforms recursively to get the discrete wavelet transform and its inverse:
APPENDIX A. A N S W E R S
262
HS Lifting: D i s c r e t e Haar Transform h s l d h t ( u [ ] , lg, dq, J ): [0] I f J>0, t h e n do [1] t o [2] [1] Compute h s l h a a r f i l t e r ( u [ ] , N, dq ) [2] Compute h s l d h t ( u [ ] , hi, 2 , d q , J-1 )
HS S y m m e t r i c Lifting: Inverse D i s c r e t e Haar Transform hslidht( u[], N, dq, J ): [0] If J>O, then do [I] to [2] [i] Compute hslidht( u[], N, 2*dq, J-I ) [2] Compute hslihaarfilter( u[], N, dq ) To check the sum-of-squares preserving property, we fix a length N, generate an array u of N random numbers with I l u l l - 1, save a copy in array v, apply h s l d h t (u,N, l , J ) , and check whether Illull- Ilvlll is less than a few truncation errors cf. Here J def [log 2 N] is the deepest level of decomposition possible with N elements. To check invertibility, we then apply h s l i d h t ( u , N , 1 , J ) and see whether I1 - vii is less than a few truncation errors. Note that both l n o r m a l i z e ( ) and o n o r m a l i z e ( ) will yield perfect reconstruction, but o n o r m a l i z e ( ) will yield an orthogonal Haar transformation. [] 21. S o l u t i o n :
First note that e0, el, e2, e3 are step functions, so the inner product
(ei, ej} - / R 2 ei(x, y)ej(x, y) dxdy, quadi, j e {0, 1, 2, 3}, can be evaluated by a finite Riemann sum. We can also iterate the integration and write
Ile~LI2 fR 2(x'y)dxdy-(/aa2(x)dx)(/ib2(y)dy)-ItallZllbll 2
2 ei
where a and b are either 1 or w, depending on i. But then Ilall- Ilbll- 1, proving that ]]eil] - 1 for i - 0 , 1 , 2 , 3 . Likewise, i f / # j and ei(x,y) ai(x)bi(y) and e j ( x , y ) - aj(x)bj(y) with ai, bi,aj,bj c {w, 1}, then
/1~2 ei(x, y)ej(x, y)dxdy
since at least one of
-
(/Rai(x)aj(x)dx)(/Rbi(y)bj(y)dy)
-
(ai,aj} (bi, bjl
(ai, aj) -- 0 or (bi, bj) - O.
- O,
A.6 ....
TO CHAPTER
263
6 EXERCISES
2
4
0
Figure A.4: Two example graphs with labeled vertex sets V1 = {0, 1 , . . . , 9} and V2 = {a, b, . . . , n } .
A.6
... to Chapter
1. Solution:
6 Exercises
Figure A.4 gives the labeling, and the edge lists are respectively E1
{{4, 1}, {4, 2}, {4, 5}, {4, 8}, {5, 2}, {5, 6}, {5, 8}, {6, a}, {6, 9}, {9, 0}, {3, 7}, {7, 0}},
for the left graph, and E2
{{a, b}, {a, c}, {b, d}, {b, e}, {c, f}, {c, g}, {e, h}, {e, i}, {h,j}, {i,k}, {i,l}, {i,m},
{j, n}},
for the right tree. If we designate a as the root, then generation 0 is {a}, generation 1 is {b, c}, generation 2 is {d, e, f, g}, generation 3 is {h, i}, generation 4 is {j, k, l; m}, and generation 5 is {n}. []
None exists, since prefix codes are uniquely decipherable codes and 2 -1 + 2 -2 + 2 -2 + 2 -3 = 9/8 > 1 fails the necessary condition for existence stated in Lemma 6.1. []
2. S o l u t i o n :
The receiver must keep track of the decoded message and alter the decoding every time a 'c' is encountered:
3. S o l u t i o n :
A P P E N D I X A. A N S W E R S
264
Dynamic Decoding Example dynamicdecoding( b i t [ ] , L ): [ O] Initialize n=O and k=l [ i] While k<=L, do [2] to [20]
[ 2]
I f n==O, then do [3] to [9]
[ 3] [ 4] [ 5] [ 6] [ 7] [ 8] [ 9] [I0] [Ii] [12] [13] [14] [15] [16] [17] [18] [19] [20]
If bit[k]==l, then do [4] to [5] Let OUT='a' Increment k += 1 Else do [7] to [9] If bit[k+l]==O, then let OUT = 'b' Else let OUT = 'c' Increment k += 2 Else do [II] to [17] If bit[k]==O, then do [12] to [13] Let OUT = 'a' Increment k += 1 Else do [15] to [17] If bit[k+l]==l, then let OUT='b' Else let OUT = 'c' Increment k += 2 If OUT=='c', then toggle n = l-n Print 0UT Go to [I]
4. Solution:
First note that p(XlX2"''Xs)
--
xEA s
~
p(Xl)p(X2)'''P(xs)
xEA ~
Xl EA x2 EA
-
x~ EA
(~~~(~1/),~
~(~t
-
~
Thus p~ gives the occurrence probabilities on A ~. We compute its entropy:
H(p s)
-
1 ~ p(xlx2 " "xs) log2 xEA~ p(xlx2 ""Xs)
xcA~
:
i=l
p(xi)
A.6 . . . . TO CHAPTER 6 EXERCISES
265
where we have interchanged the order of summation and then extracted one factor p(xi) from the ith new summand to combine with its corresponding logarithm. But each xi is an independent random variable with occurrence probabilities p, so for all k = 1 , . . . , s,
E
p(xk)--i
and
x~cA
E
p(xk)log2,(
~A
1
~ =H(p)
~.,xk,
independent of k. We conclude that H(p 8) - }--~=1 H ( p ) - sH(p).
[]
S o l u t i o n : Let Nd be the number of binary trees of depth d or less. Then No = 1, since the only depth=0 binary tree is the one consisting of just the root. Also N1 - 4, with the only possibilities being root, root+son, root+daughter, or root+son+daughter. Now observe that any tree of depth at most d + 1 consists of a root with a possibly empty left subtree of depth at most d, and a possibly empty subtree of depth at most d. These left and right subtrees may be chosen independently from the 1 + Nd possibilities (the empty subtree is not counted in Nd), so the following recursion relation holds:
Nd+l
-~
(1 + Nd) x (1 + Nd).
Thus N2 = 25 and N3 = 676.
6. S o l u t i o n : Suppose that there are only T < oc binary trees with n leaves. Pick one with maximal depth d, and find one of its vertices with generation number d. That vertex must be a leaf; adding one daughter to that vertex creates a new binary tree which has n leaves and depth d + 1, so it cannot be among the original T. Hence there must be at least T + 1 trees. Hence there cannot be just a finite number. [] 7. S o l u t i o n : If there are 10 or fewer letters in the alphabet, each gets a unique one-digit codeword. Otherwise, suppose that the alphabet consists of the consecutive integers A = { 1 , 2 , . . . , N } , where N > 10. Let the occurrence probabilities be Pl, P 2 , . . . , PN. Then, 1.
Create N orphan vertices with weights P l , . . . , P N .
2.
Find the 10 orphans with smallest weights. Label them xo, X l , . . . , x9 and denote their respective weights by Pxo,...,Pxg. Use some convention to break ties.
3.
Create a new orphan vertex x, give it weight Pxo + " " + Pxg, and make it the common parent of vertices x0 through Xg, which are no longer orphans. Label the edge between x and Xd with the digit d, for d = 0,1,...,9.
A P P E N D I X A. A N S W E R S
266
I
a = 11
n(a) = 2
/~p(b)= o.o5 l
b=Olll
n(b)=4
c=OllO
n(c)=4
O.17 ] d = 010
n(d) = 3
i~p(a)=
/ ~
~
~
0.20
SiT Ap(c) =o.o8 I p
(
d
)
=
-
e = O0
n(e) = 2
f = 1001
n(f) = 4
I g = 101
h = 1000
n(g) = 3 n(h) = 4
Figure A.5: Huffman code solving Exercise 8.
.
If there are fewer than 10 orphan vertices left, connect t h e m to a common parent, call it the root, and terminate. Otherwise, return to step 2.
8. S o l u t i o n : A Huffman code for this combination of alphabet and occurrence probabilities is shown in Figure A.5. It has codeword lengths M = (2, 4, 4, 3, 2, 4, 3, 4), and its bit rate is E x c A p(x)n(x) - 2.73, whereas H(p) E z r A p(x) log 2 1/p(x) -- 2.69. [] 9. S o l u t i o n : First count the occurrences of each of the 20 letters in this 85letter message: lkpw, 2bsv, 3acd, 4fhiy, 5nou, 71, 8t, 9r, 12e. One Huffman tree for this set of occurrence probabilities is obtained in these steps: Ik Ip lw 2b 2s 2v 3a 3c 3d 4f 4h 4i 4y 5n 50 5u 71 8t 9r 12e lw 2kp 2b 2s 2v 3a 3c 3d 4f 4h 4i 4y 5n 50 5u 71 8t 9r 12e 2b 2s 2v 3kpw 3a 3c 3d 4f 4h 4i 4y 5n 50 5u 71 8t 9r 12e 2v 3kpw 3a 3c 3d 4bs 4f 4h 4i 4y 5n 50 5u 71 8t 9r 12e 3a 3c 3d.4bs 4f 4h 4i 4y 5vkpw 5n 50 5u 71 8t 9r 12e 3d 4bs 4f 4h 4i 4y 5vkpw 5n 50 5u 6ac 71 8t 9r 12e 4f 4h 4i 4y 5vkpw 5n 50 5u 6ac 7dbs 71 8t 9r 12e 4i 4y 5vkpw 5n 50 5u 6ac 7dbs 71 8fh 8t 9r 12e 5vkpw 5n 50 5u 6ac 7dbs 71 8iy 8fh 8t 9r 12e 50 5u 6ac 7dbs 71 8iy 8fh 8t 9r lOvkpwn 12e 6ac 7dbs 71 8iy 8fh 8t 9r lOou lOvkpwn 12e 71 8iy 8fh 8t 9r lOou lOvkpwn 12e 13acdbs 8fh 8t 9r lOou lOvkpwn 12e 13acdbs 151iy 9r lOou lOvkpwn 12e 13acdbs 151iy 16fht lOvkpwn 12e 13acdbs 151iy 16fht 19rou 13acdbs 151iy 16fht 19rou 22vkpwne 16fht 19rou 22vkpwne 28acdbsliy 22vkpwne 28acdbsliy 35fhtrou 35fhtrou 50vkpwneacdbsliy 85fhtrouvkpwneacdbsliy
These nodes may be rearranged into a tree with its root at the top:
A.6 .... O: i: 2: 3: 4: 5: 6: 7:
TO CHAPTER
6 EXERCISES
267
85fhtrouvkpwneacdbsliy 50vkpwneacdbsliy 22vkpwne 28acdbsliy lOvkpwn 12e* 13acdbs 151iy 5vkpw 5n* 6ac 7dbs 71. 8iy 2v* 3kpw 3a* 3c* 3d* 4bs 4i* 4y, lw* 2kp 2b* 2s* lk* lp*
35fhtrou 16fht 8fh 8t* 4f, 4h*
19rou 9r* lOou 50* 5u*
Leaves are marked with asterisks, and the codeword length is listed at left. The canonical Huffman tree produced by this algorithm is described by the m a x i m u m codeword length L = 7; the number of codewords at each length, M = (0, 0, 3, 6, 6, 3, 2); and the order in which letters appear in the canonical tree at each level, A ' = etr n l f h o u v a c d i y w b s kp. It takes 5 bits per letter to code the letters in a 20-letter alphabet, so the original message occupies at least 8 5 , 5 425 bits. The bit rate of the Huffman tree is its weighted depth, which is 7 • (1+1) + 6 • ( 1 + 2 + 2 ) + 5 • ( 2 + 3 + 3 + 3 + 4 + 4 ) + + 4, (5+7+4+4+5+5)+
3 , (12+8+9)
-
346 bits,
or 4.07 bits per letter. The entropy H ( p ) of the message is computed from the occurrence probabilities p(e) - ~12, p(k) - p(p) - p(w) - 1 and so on:
H(p)
-
1 3,--,log
s5
2
85
T
2
+3,
s5
,log 2
85
T
3 +3,~,log
285
a
4 85 5 85 7 85 + 4 , - - • log 2 + 3 , - - • log 2 + 1 • - - • log 2
s5
8 + 1,--,log 85 -
T
2
85 -8-
s5
9 +1,--,log 85
T
2
85 -9-
s5
12 +1,re,log 85
7
2
85 12
4.02946 bits per letter,
or about 342.5 total bits. 10. S o l u t i o n : In this case, adding an extra letter i with occurrence probability 0 deepens the tree by one level. One canonical Huffman code for this appended alphabet and occurrence probabilities is shown in Figure A.6. It has the description L - 5, M - (0, 2, 2,3, 1), and A' - e a d g c b f h . Its bit rate is y'~xcAP(X)n(x) = 2.78, which is 0.05 bits per character worse t h a n the efficiency of the tree without the extra letter. []
APPENDIX A. ANSWERS
268
e O0
n(e) 2 n(a)=2 n(d)=3 n(g)=3 n(c)=4 ;-O~ln(b)=4 2 n(f) =4 h=llllO n(h)=5 =
"~
~ ~ ~,
~1 ~/ ~
~
[p(e)=0/.30 [
[p(a;=0.20 [ ,/
~
,p(d)=O.17, o~~
=
a=lO d=OlO g= 110 c=OllO
o~l
/
~
[P(g)=O'iO[
,U=2"x
[p(c)=o.08 I IP(b)=0.05 I Ip(f)=0.05 I
L 5 M = {0,2,2,3,1} a'= eadgcbfh
0~1 "
""
Ip(h)=0.05 ] [p(i)=01
Figure A.6: Canonical Huffman code solving Exercise 10.
11. S o l u t i o n : In this case, Paw - ( 1 - q ) ( 1 the notation of Equation 6.7,
p)N, Pfa -- q ( 1 - p)N and using
2)de --
(1-- q) (1-- x) + q[x -- (1-- p)N]
---- -111 - ( 1 - 2 q ) ( 1 2
-Pue
--qZ kCO
12. S o l u t i o n :
2p) N -
2q(1
-p)N];
( N ) pk(l-p)N-k + (l - q ) Z ( N ) pk(I-p)N-k kCE+
--
q(1-- x) + (1-- q) [x -- (1-- p)N]
=
111 + (1 - 2q)(1 2
2p) N - 2(1 - q)(1 - p)N].
We use Gilbert's ideas from T h e o r e m 6.12:
Gilbert's
Algorithm
for a n E r r o r C o r r e c t i n g
Code
gilbertcode( bits, words, corrects ) : [0] Let N = 1<
A.6 . . . .
TO C H A P T E R 6 E X E R C I S E S
269
To generate the code, we call g i l b e r t c o d e ( 1 0 , 4 , 2 ) . This starts with codeword c(0) = 0000000000 and eliminates H a m m i n g spheres of radius 5 = 2 . 2 + 1 from the ten-dimensional unit hypercube. It continues until it has found three additional survivors c(1) = 00001 11111, c(2) = 0111000111, and c(3) = 01111 11000. Note t h a t only nine codeword bits are actually needed, as the tenth bit is constant over the code. [] 13. S o l u t i o n : If x and y differ at exactly one decimal digit, then x - y - :l:d× 10 k for some integers k _ 0 and d c {1, 2 , . . . , 9}. But Cl1 (X) -- Cll(Y) if and only if x - y - - 0 (mod11),whichrequiresd-0 (rood 11) since 10 k ~ 0 (rood 11) for any k _> 0. But no d in the stated range satisfies t h a t congruence. Note that c9(110) - c9(119) is a one-digit difference undetected by casting out nines. In general, changing any 0 digit into 9 will not change c9, since the difference d - 9 satisfies d - 0 (rood 9). Neither will transposing two digits, though transposing unequal adjacent digits will change the value of c11. [] 14. S o l u t i o n :
No. Consider the counterexample 1872 x 22 883 - 42 836 976 J: 42 8~.6 876,
a two-digit error in decimal arithmetic. We have c9 (1872) - 9;
c9(22 883) - 5;
c9(42 846 876) - 9 - c9(9 × 5),
so c9 fails to detect the error. Likewise, Cl1(1 872) - 2;
Cll (22 883) -- 3;
Cll (42 846 876) -- 6 -- Cll (2 X 3),
so Cll also fails to detect the error. 15. S o l u t i o n :
This is a direct translation of the integer Euclidean algorithm"
Euclid's Algorithm for Integer-Size Mod-2 Polynomials i n t m o d 2 p o l y g c d ( x, y ): [0] Let z = x [lJ C a l l i n t m o d 2 p o l y d i v i s i o n ( y , x ) , replace x = remainder [2] Let y = z [3] I f i n t m o d 2 p o l y d e g r e e ( x ) > 0 , t h e n go t o [0] [4] R e t u r n y
16. S o l u t i o n : Write 1 = gcd(x,z) = m o ( t ) x ( t ) + no(t)z(t) as in the proof of Theorem 1.2. Then y ( t ) = mo(t)x(t)y(t) + no(t)z(t)y(t). Since z(t) evidently divides no(t)z(t)y(t), and z(t) divides mo(t)x(t)y(t) by assumption, it follows that z(t) divides mo(t)x(t)y(t) + no(t)z(t)y(t) = y(t). []
270
APPENDIX
17. S o l u t i o n : yields:
A.
ANSWERS
(a) Trial division with all six rood-2 polynomials of degree 1 or 2
t 3 -1- t -F 1
--
(t)(t 2 + 1 ) + 1
=
(t + 1)(t + 1 ) + t
=
(t2)(t) + t + 1
=
(t 2 + 1 ) ( t ) + 1
=
(t 2 + t ) ( t ) + t
=
(t2+t+l)(t)+t2+l.
2+t+1
All of these expressions have nonzero remainders, so t a + t + 1 is irreducible. (b) The factorization t 4 + t 2 + 1 - (t 2 + t + 1)(t 2 + t + 1) + 0 - (t 2 + t + 1) 2 is discovered by trial division with the six rood-2 polynomials of degree 1 or 2. [] 18. S o l u t i o n : Standard
For all of these polynomials, we use the following: C Function: Test Mod-2 Polynomial Divisibility
int least_power ( unsigned int mod2poly, int degree ) unsigned int rem, highbit; int N; highbit=Ox1<<(degree-1); /* Start at t^degree +I for(rem=mod2poly, N=degree; rem! =Oxl ; ++N ) if( rem ~ highbit ) { rem = (rem<<1)^mod2poly; /* shift, add mod2poly } else rem <<= I; /, else just leftshift all the bits return N;
{ ,/ */ */
(a) Call least_power() with mod2poly set to 1011 (base 2) and degree set to 3. The return value shows t h a t t a + t + 1 divides t N + 1, with N - 7 - 2 a - 1, but no smaller N > 0. (b) Mod-2 polynomial 1100000001111, of degree 12, divides t N + 1 for N 2 0 4 7 - 211 - 1, but no smaller N > 0. (c) Mod-2 polynomial 11000000000000101, of degree 16, divides t N + 1 for N - 3 2 7 6 7 - 215 - 1, but no smaller N > 0. (d) Mod-2 polynomial 1100000000101000100000001, of degree 24, divides t N + 1 for N - 7161, but no smaller N > 0. [] 19. S o l u t i o n : On a computer t h a t has integer types with 33 or more bits, we can use l e a s t _ p o w e r ( ) exactly as in Solution 18. Otherwise, on a computer with 32-bit integers, we simply remove the leftmost, most significant, 33rd bit, setting mod2poly to 00000100110000010001110110110111 (base 2), and
A.6 ....
TO CHAPTER
271
6 EXERCISES
call l e a s t _ p o w e r ( ) with that and the same value 32 for degree. Integer overflow eliminates the highest order bit in the remainder computation, and after a rather long while we get the result. [] 20. S o l u t i o n : The encoding, formatted as 8-bit codewords with spaces for readability, is the following: 11000101 11110011 11110000 11100111 11101000 00100001
01101100 10100000 01110010 10100000 01100101 (base 2)
01100101 11100001 01101111 01100110 10100000
11110000 01110010 11100001 01110010 01010011
11101000 01100101 01100011 01101111 01101111
11100001 10100000 11101000 11101101 11110101
11101110 11100001 01101001 10100000 01110100
01110100 11110000 11101110 01110100 11101000
The conversion to bits with the addition of a parity bit was done on a computer with ASCII internal coding by the following function, called with msg [] set to "Elephants are approaching from the South!"
S t a n d a r d C Function: W r i t e A S C I I + P a r i t y B i t s char msg[] ) { [8] ; Stop a t NULL * / { Assume ASCII * /
int ascii_bits(int allbits[], const i n t i , n=0, b, l e t t e r , p a r i t y , b i t f o r ( i = 0 ; l e t t e r = m s g [ i ] ; i++) { / * f o r ( p a r i t y = 0 , b=6; b>=0; b - - ) bit[b] = (letter>>b)&l; /* p a r i t y += b i t [b] ;
b i t [ 7 ] = p a r i t y & l ; / , p r e s e r v e even p a r i t y f o r ( b = 7 ; b>=0; b - - ) a l l b i t s [ n + + ] = b i t [ b ] ; return
n;
/*
Number
of bits
written
,/
*/
21. S o l u t i o n : We first call the function a s c i i _ b i t s () from the previous exercise with msg set to "Elephants are approaching from the North!" to get the following output: 11000101 11110011 11110000 11100111 11101000 00100001
01101100 10100000 01110010 10100000 01100101 (base 2)
01100101 11100001 01101111 01100110 10100000
11110000 01110010 11100001 01110010 01001110
11101000 01100101 01100011 01101111 01101111
11100001 10100000 11101000 11101101 01110010
11101110 11100001 01101001 10100000 01110100
01110100 11110000 11101110 01110100 11101000
Next, we implement mod2polychecksum() on page 217 as follows-
A P P E N D I X A. A N S W E R S
272
Standard C Function: Mod-2 Polynomial Modular Checksum int mod2polychecksum( int msgbit[], int numbits, int mod2poly[], int deg ) { int checksum, d, n; for(n=O; n
01101100 I0100000 01110010 I0100000 01100101 (base 2)
01100101 Iii00001 01101111 01100110 I0100000
Iiii0000 01110010 III00001 01110010 01001110
iii01000 01100101 01100011 01101111 01101111
III00001 i0100000 III01000 iii01101 01110010
III01110 Iii00001 01101001 i0100000 01110100
01110100 Iiii0000 IIi01110 01110100 iii01000
mod2polychecksum() returns its checksum as 0. Thus, this message is distinguished from the first by its 3-bit checksum, but the previous one is not. []
Appendix B
Basics, Technicalities, and Digressions B.1
ASCII and other character sets
The American Standard Code for Information Interchange, variously called ASCII, US-ASCII, ANSI X3.4-1968, or ISO 646, assigns a number in the range 0 to 127 to each of the common English-language typewriter symbols plus some nonprinting control characters. It is a decades-old standard, still commonly used to represent text within computers, even in non-English-speaking countries. Table B.1 gives the ASCII character numberings in decimal, octal, and hexadecimal notation. The caret (^) preceding a character means "hold the Control key while entering." The low code numbers 0-31 plus the highest code number 127 are control characters that have various functions. For example ^G, read "Control-G," rings the margin bell on a teletype, or causes a computer monitor to beep. Codes 20-126 are letters, numbers, and punctuation, with code 20 being the space character. The Standard C programming language does not depend on ASCII numbering, but it uses all the ASCII letters, numbers, and punctuation symbols except codes 24 ($), 40(@), and 60('). Standard C also requires certain of the control characters, referring to them by escape sequences beginning with a backslash (\). These are listed in Table B.2. Because of the way C handles strings, every character numbering scheme must have the same internal representation, 0, for the Null character. Also, Standard C requires that the internal codes for 0,1,... ,9 have sequential values. ASCII codes fit into 7 bits, but most computers use 8 bits per character. Thus, there are various extended ASCII character sets, with codes 128-255 used for accented letters, graphical symbols, Greek letters, or other purposes. Symbols represented by these codes are sometimes called recta-characters. There is a growing family of international standard alphabets using 8-bit character codes, the ISO 8859-n family of national character sets, of which the first ten members are listed 273
APPENDIX B. BASICS, TECHNICALITIES, AND DIGRESSIONS
274
Char Hex Oct Dec
Char Hex Oct Dec
Char Hex Oct Dec
Char Hex Oct
Dec _
^@ ^A ^B ^C ^D ^E ^F "G ^H ^I ^J ^K ^L ^M ^N ^0 ^P ^Q ^R ^S ^T ^U ^v ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^
O0 01 02 03 04 05 06 07 08 09 OA OB OC OD OE OF 10 11 12 13 14 15 16 17 18 19 1A 1B lC ID IE IF
000 001 002 003 004 005 006 007 010 011 012 013 014 015 016 017 020 021 022 023 024 025 026 027 030 031 032 033 034 035 036 037
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Char Hex Oct Dec
!
" # $ % & ' ( ) • + , • / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
040 041 042 043 O44 045 046 047 050 051 052 053 054 055 056 057 060 061 062 063 064 065 066 067 070 071 072 073 074 075 076 077
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
Char Hex Oct Dec
@ A B C D E F G H I J K L M N 0 P Q R S T U V W x Y Z [ \ ] ^
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
I00 i01 102 103 104 105 106 107 110 111 112 113 114 I15 116 117 120 121 122 123 124 125 126 127 130 131 132 133 134 135 136 137
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
Char Hex Oct Dec
c
a b c d e f g h i j k 1 m n o p q r s t u v w x y z {
60
_
_
96
141 142 143 144 145 146 147 150 151 152 153 154 iSS 156 157 160 161 162 163 164 165 166 167 170 171 172 173 174 175 176 177
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
Char Hex Oct
Dec
I
} "
^?
61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
140
Table B.I: ASCII characters and their numerical codes Control function Null Alert Backspace Horizontal tab New line Vertical tab Form feed Carriage return
ANSI Standard C escape sequence
ASCII name
\0 \a
Control-@ Control-G Control-H Control-I Control-J Control-K Control-L Control-M
\b
\h \n \v \f \r
ASCII hex O0 07 08 09 OA OB OC OD
ASCII octal
ASCII decimal
000 007 010 011 012 013 014 015
0 7 8 9 10 11 12 13
Table B.2: ASCII implementation of required control codes in Standard C
B.2. ALGORITHMS ISO Number ISO-8859-1 ISO-8859-2 ISO-8859-3 ISO-8859-4 ISO-8859-5 ISO-8859-6 ISO-8859-7 ISO-8859-8 ISO-8859-9 ISO-8859-10
275 Name Latinl Latin2 Latin3 Latin4 Cyrillic Arabic Greek Hebrew Latin5 Latin6
Examples Basque, English, French, Swedish Croatian, Hungarian, Polish, Sorbian Esperanto, Maltese Estonian, Lappish, Latvian, Lithuanian Bulgarian, Macedonian, Russian Basic Arabic Modern Greek Hebrew, Yiddish Turkish Icelandic, Inuit
Table B.3: The first ten ISO-8859 national character sets in Table B.1. In each of these, the first 128 symbols are the same as ASCII. There are also several using 16-bit wide characters, such as Unicode, or ISO 10646, which encompasses all of Planet Earth's written human languages.
B.2
Algorithms
An algorithm is a step-by-step procedure for computing some quantity. It has inputs, outputs, and an ordered list of instructions. An algorithm is finite if, for any fixed finite inputs, each of its steps is finite and the total number of steps performed is also finite. Notation for the instructions must be unambiguous. For this purpose there exist numerous programming languages with limited vocabulary and rigid grammar and syntax. A nice survey of these, including old and exotic ones like APL, may be found in Tucker's Programming Languages. Algorithms in this text are written in pseudocode that resembles some of these formal programming languages, especially Basic, F O R T R A N and Standard C. They are aimed at humans and are not suitable for direct machine consumption. However, we must still have some rules to eliminate ambiguity. If intermediate quantities are computed and stored, they must be assigned to memory. The equals sign is used in this context, and another symbol "==" is used in tests for equality. We may also use the APL assignment arrow x +- x + 1, read "x gets x plus 1," to signify that the memorized quantity x should be replaced by itself added to 1. Data type and variable declarations are omitted in pseudocode, and there is no FORTRAN-like naming convention to distinguish integers from floats, but new quantities and their types should be inferred from context. Function names will always be in lower-case, followed by parentheses enclosing a parameter list. When a function is defined for the first time, there will be a colon after the parameter list to signify the beginning of the definition. Punctuation marks will also be used
276
APPENDIX
B.
BASICS,
TECHNICALITIES,
AND DIGRESSIONS
to signify parts of data structures. Keywords and action descriptions will either be capitalized or all lower-case, but can be distinguished from function names by the absence of parentheses. Array indexing is signified by placing the index inside square brackets. Members of data structures are set apart with periods. Operations are always evaluated from left to right, so that CW[J]. VAL = X-Y-Z means "assign the value of ( x - y) - z to member VAL of the data structure at index j in the array of data structures CW[] ." Notice how arrays are marked by appending an empty set of brackets. An array of arrays can be denoted by two sets of empty brackets: MATRIX[] []. Likewise, writing s q r t () emphasizes that a function may have a nonempty list of parameters, though at the moment those parameters are not the focus of attention. The operators %, <<, >>, ~, I, and ^, taken from Standard C, mean remainder, left-shift, right-shift, bitwise conjunction, bitwise disjunction, and bitwise exclusiveor, respectively. Following any of these with = means "assign to the left-hand variable the output of the operation." For example, x%=y, means "assign to x the result of x%y," and so on. Likewise, the Standard C logical operators !, ~ , I I, == and != will be used to signify NOT, AND, OR, EQUAL, and NOT EQUAL, respectively. We will assume that logical expressions have the values T R U E or FALSE that can be tested, though unlike Standard C we will not give them arithmetic values or compute with them. Algorithms are set apart from the text in numbered lists. Statements and keywords will be similar to those in the following list of examples: A s s i g n m e n t : Let x = 0, or x ~ 0, assigns the value "0" to the memory location labeled x. F u n c t i o n calls: Compute x = s u m ( a r r [ ] , l e n ) , or x ~-- s u m ( a r r , len), evaluates the function sum() with input values a r t [ ] and len, then assigns its return value to x. R e p l a c e m e n t : Operations sometimes perform arithmetic with a variable and then replace that variable with the result: I n c r e m e n t s : x += dx means "x ~ x + d x " . D e c r e m e n t s : y -= dy means "y . - y -
dy".
M u l t i p l i e r s : z *= c means "z ~--c × z". N o r m a l i z e r s : w /= sum means "w ~-- w / s u m " . The words "Replace," "Increment," "Accumulate," "Decrement," "Multiply," "Normalize," or "Divide" may be used to emphasize the nature of the arithmetic. C o n d i t i o n a l s : The logical expression between "If" and "then" is tested. If its value is TRUE, the "then" action is performed. Otherwise, the "Else" subsequent action is performed, if there is one. After either case, the algorithm moves past both the "If" and the "Else" lines. For example, the following
B.3. BIG-OH N O T A T I O N
277
fragment assigns y -- 2 at the "If" line if z - "Else" line if z - - 5:
4 and assigns y - 3 at the
[0] If x is even, then let y = x/2 [i] Else let y = (x+l)/2 Loops:
These contain a control statement at the top, and a
body consisting of other
instructions grouped below it and indicated by indentation. In a "for" loop, the control statement names and defines the range of the loop index, which is incremented by +1 at each pass through the body: [0] For j = a t o b, do [1] t o [1] Let a r r a y [ 2 * j ] = j [2] Let a r r a y [2*j +l] = 0
[2]
If b < a, then no statement in the body of the loop will be executed. In a "while" loop, the loop index may be altered in any desired fashion within the body: [0] Let k = n [I] While k>0, do [2] and [3] [2] Multiply nfacfac ,= k [3] Decrement k - = 2
Return
statements: ,
o
These indicate the value to be returned by a function:
,
[4] Return nfacfac
If no value is named it means t h a t the function acts solely by side-effect, and returns no explicit output. The return statement can be omitted in this case. P r e d e f i n e d f u n c t i o n s : It will be assumed t h a t common functions are predefined, such as s q r t (x), s i n (x), cos (x), e x p ( x ) , and l o g ( x ) , which respectively return the square root, sine, cosine, exponential and logarithm of x. Exceptions such as x <_ 0 in l o g ( x ) cause immediate termination.
B.3
Big-Oh notation
So-called "big-Oh" notation is used to estimate the rate of increase of a quantity t h a t depends on a parameter. For example, suppose t h a t tn is the number of arithmetic operations needed to compute the square of an n-digit integer on a particular machine. To say that tn = O(n 2) means there is some finite positive constant C such that, for all n = 1 , 2 , . . . and any n-digit number, tn <_ Cn 2. The smallest value of C which works is called the sharp constant and is sometimes of independent interest. In this example, the constant depends on the base of
278
APPENDIX B. BASICS, TECHNICALITIES, AND DIGRESSIONS
the number system used and certain other details about the machine arithmetic, unimportant particulars best hidden by the notation. For example, if a and b are n-digit integers, then the naive paper-and-pencil algorithms for computing a + b, ab, and a/b require O(n), O(n2), and O(n 2) onedigit operations, respectively. These are finite numbers of operations for any fixed a, b on a particular machine. The complexity of an algorithm containing nested loops can be estimated from the depth of the nesting. For example, n x n matrix multiplication has three nested loops each requiring O(n) iterations, and takes O(n 3) total operations. Other increasing functions of n may be used to estimate complexity. For example, the complexity of printing the number n grows like O(logn), since n has O(logn) digits and printing each one should take at most some fixed amount of time. Not specifying the constant allows the estimate to apply to printing in all bases, on any kind of printer. The complexity of a combination of algorithms is determined by the most complex component. For example, solving the n x n linear system A x - b is a combination of inverting matrix A, which costs O(n 3) operations, followed by applying the inverse matrix to the vector b, which costs O(n2). The total complexity is O(n3), since for all large enough n the inversion cost will dominate. In general, a O(n p) algorithm combined with a O(n q) algorithm has complexity O(nmax(p'q)). Memory space requirements for an algorithm can be specified in big-Oh notation as well. For example, to store an n x n image as pixel values will cost O(n 2) memory spaces. The notation hides the details of how many bits are stored per pixel, in the unspecified constant C. Space and time are both important in complexity estimates, and an algorithm that performs O(n) operations on each pixel will cost O(n) x O(n 2) = O(n 3) operations to execute. In general, O(n p) operations on each of O(nq) values will cost O(n p+q) in total. The same notation is used to give estimates of small quantities in terms of a small parameter. For example, suppose that f = f(x) is a real-valued function, defined for values x near 1. To say that f(1 + h ) - f(1) = O(h) means that there is some constant C such that If(1 + h) - f(1)l _< CIh I for all h. If we only care about very small h, we might say f ( l + h ) - f(1) = O(h) as h ~ 0, which is the weaker assertion that for some e > 0, there is a constant C such that If(l+h)-f(1)l <_CIh I for all h with Ihl < e. Size estimates can be combined just like complexity estimates, with the higher order being dominant. For example, if f(h) = O(h p) and g(h) = O(hq) as h --. 0, then f(h) + g(h) = O(h max(p'q)) as h --~ 0. Also, f(h)g(h) = O(h p+q) as h ~ 0.
B.4
Calculus methods
Complete proofs of the lemmas and theorems in this section may be found in Apostol's two-volume Calculus, listed in the further readings, or else in his more advanced book Mathematical Analysis, listed in the further readings in Chapter 3.
B.4. CALCULUS METHODS
B.4.1
279
Techniques of proof
Suppose that P(n) is a property of the counting number n E {0, 1, 2 , . . . } , such as "n is odd" or "the sum of the positive integers up to n is n(n + 1)/2." P(n) is considered verifiable if it can be shown true or false with only finitely many calculations. Both of the example properties are verifiable: the first by dividing n by 2, the second by performing n additions. The verifiability of P(n) for any fixed n sometimes permits verifying that P(n) is true for all the infinitely many n, using the principle of mathematical induction. If P(0) is true, and if it can be verified algebraically for the variable m that P(m + 1) is true whenever P(m) is true, then P(n) is true for every n = 0, 1,2, .... Any doubter worried about a particular n need only consider that P(0) is true, so P(1) is true, s o . . . P ( n - 1) is true, and finally P(n) is true. For the first example, P(0) is false (since 0 is even, not odd) so induction fails at the outset. The second property is true for all n, since P(0) is true (the sum of no integers is 0 = (0)(0 + 1)/2) and P(m + 1) follows algebraically from P ( m ) : m+l
m
Ek-(m+l)+
E
k=l
k=l
k.
If P(m) is true, then the last sum is m(m + 1)/2. Combining this algebraically X--~rn+l with (m + 1) gives z_~k=l k - (m + 1)(m + 2)/2, or P(m + 1). Sometimes it is more convenient to start with P(1) or higher, if the resulting algebraic formulas are nicer.
Enumeration To show that a set is infinite, it suffices to show that it contains at least n members for every integer n. This can be done with mathematical induction, with P(n) being the proposition that the set contains at least n members. Euclid first used this idea to show that there are infinitely many primes. P(1) is true, since 2 is prime. If P(n) is true, let P l , . . . , Pn be n distinct primes and put x = Pl ""Pn + 1. Then x is not divisible by any of the n listed primes, so it is either a new prime number or contains a prime divisor not in the list, so that P(n + 1) is true.
Polynomial a l g e b r a Let p = p(x) be a polynomial with coefficients do, al,... ,an:
p(x) = ao + a l x + a2 x2 -Jr-'" + an_l x n - 1 -~- anX ~.
(B.1)
The degree of p is the nonnegative integer n except when p is identically zero, that is, when a0 = a l . . . . . an = 0. In that case, the degree is conventionally treated as - o c with the arithmetic rules n + ( - o c ) = ( - o c ) + n = - o c for any finite n. If p = p(x) and q = q(x) are polynomials of degrees n, m respectively, then • Both pq - p(x)q(x) and p + q - p(x) + q(x) are polynomials;
280
A P P E N D I X B. BASICS, T E C H N I C A L I T I E S , A N D D I G R E S S I O N S • T h e degree of pq is n + m; • T h e degree of p + q is at most m a x { n , m}; • If q is not identically zero and thus has finite degree m, there are unique polynomials r = r(x) and s = s(x), with the degree of s being less t h a n m, such t h a t for all x,
p(x) =
r(x).
T h e last fact implies t h a t if z is a root of p, then p(x) = s(x)(x - z) for all x. We prove this by dividing p by q(x) = x - z, which has degree m = 1. This gives a r e m a i n d e r polynomial r = r(x) of degree 0 or less. But then r is constant, and since 0 = p(z) = s(z)(z - z) + r(z) = r(z), we conclude t h a t r is identically zero. B.4.2
Limits,
continuity,
and
derivatives
Let f = f ( t ) be a function of one real variable, defined for all values of t in an open interval (a, b). Let to signify some particular fixed value of the variable t, and let and 5 signify small positive real numbers. Function f is said to have a limit L at t = to if, for every c > 0, there is a 5 > 0 such t h a t if 0 < I t - t01.< 5, t h e n If(t) - L I < c. T h a t fact a b o u t f is often a b b r e v i a t e d by the notation lim f (t) - L. t--~ to
It does not require t h a t f be defined at to, but only t h a t it be defined at points t near to, and t h a t its value at those points stays close to L. Sometimes a function has a limit from only one side. For example, f is said to have a left sided limit L at t = to if, for every c > 0, there is a 5 > 0 such t h a t if to - 5 < t < to, then If(t) - L I < e. Such a limit L, if it exists, is usually denoted by f ( t o - ) as follows: lim f (t) = f (to-). t - - * t o --
This does not require t h a t f be defined at any t _> to. Likewise, f is said to have a right sided limit L at t = to if, for every c > 0, there is a 5 > 0 such t h a t if to < t < to + 5, then If(t) - L I < c. Such a limit L, if it exists, is usually denoted by f ( t o + ) as follows: lim f (t) - f (to+).
t---~to +
This does not require t h a t f be defined at any t _< to. If f is defined only on the half-open interval [a, b), t h e n it can at best have a right sided limit at a because its values are undefined at t < a. Note t h a t f might have a left sided limit at b in this case, even t h o u g h it is not defined at b. B . 1 f has a limit L at to if and only if its left sided and right sided limits exist and agree: f ( t o - ) = f (to+) = L. []
Lemma
B.4.
CALCULUS METHODS
281
Function f is said to be continuous at a point to if limt--.to f ( t ) - f ( t o ) . This requires both t h a t the limit exists and t h a t f is defined at t - to. C o r o l l a r y B . 2 f is continuous at to if and only if f ( t o - )
- f(to) - f(to+).
D
Continuity is a concept t h a t applies to functions of more t h a n one variable. A function f = f ( x ) of the variables x = ( X l , . . . ,xn) c R n is said to be continuous at a point z = ( Z l , . . . ,zn) c R n if limx__~, f ( x ) = f ( Z ) . Here x --~ z means t h a t x k --~ zk for all k = 1, 2 , . . . , n. Thus, for any subset I c R n, we may say t h a t f is continuous on a set I if it is continuous at each point of I. We may further say t h a t f is uniformly continuous on a set I if the same 5(e) relation works at each point of I: for every e > 0, there is a 5 > 0 such t h a t I f ( x ) - f(z)l < ~ for all x , z C I satisfying Izk - xkl < 5 for all k= 1,...,n. The behavior of any continuous f has additional restrictions when the set I C R n is closed, bounded, or connected: L e m m a B . 3 I f f is continuous on a closed and bounded set I C R n, then f is uniformly continuous on I. [] L e m m a B . 4 I f f is a continuous real-valued function on a closed and bounded set I c R n, then f takes its m i n i m u m and m a x i m u m values at some points in I. [] T h e o r e m B . 5 ( I n t e r m e d i a t e V a l u e T h e o r e m ) If f is a continuous real-valued function on a closed and bounded interval I - [a, b] c R , and y is any number between f (a) and f (b), then there is some x e I such that f (x) - y. 0 C o r o l l a r y B . 6 I f f is continuous on [a,b] C R , then { f ( x ) closed and bounded interval.
" a < x < b} is a []
Differentiability, or smoothness, is better t h a n continuity. A function f of one real variable is said to be differentiable at a point to if the difference quotient function [f(t) - f ( t o ) ] / ( t - to) has a limit as t ~ to. The value of this limit is denoted by f'(to), and called the derivative of f at to:
f ' ( to ) Lemma
lim
t~to
f(t)t-
f(to) to
B . 7 I f f is differentiable at to, then f is continuous at to.
The last lemma holds because if f is differentiable at to, then f ( t ) - f ( t o ) must go to zero "at least proportionally as fast" as t - to goes to zero as t ~ to. This leads to a notation for comparing rates at which functions approach limits: A function g = g(h) is said to be O(h), or big Oh of h, as h ~ 0, if there is some proportionality constant C such t h a t Ig(h)l _< Clhl for all h sufficiently close to 0. We may ignore h = 0 if g(0) is undefined. This notion can be generalized to O(h 2) and higher powers of h.
282
A P P E N D I X B. B A S I C S , T E C H N I C A L I T I E S , A N D D I G R E S S I O N S
Notice that if f is differentiable at to, then g(h) - f(to + h ) - f( to ) - O(h). However, even if f ( t ) - f(to) - O ( t - to), it does not imply that f is differentiable at to. It does imply that f is continuous at to; in fact, it defines what is meant by Lipschitz continuity of f at to, which is a stronger notion. All Lipschitz continuous functions are continuous, but some continuous functions (such as f ( t ) - t ~/3 at to - 0) are not Lipschitz continuous. Another notion of approach rate is needed, so we will say a function g - g(h) is o(h), or little oh of h, as h ~ 0 if lim g ( h ) / h - O. h---,0
In other words, g(h) should go to zero somewhat faster than h. This notion can also be generalized to higher powers of h. The little-oh notation gives a useful characterization of differentiability" T h e o r e m B.8 f is differentiable at to if and only if there is a number, which shall be called f'(to), such that f ( t ) - f(to) + (t - to)f'(to) + o(t - to) as t --~ to. [] A function f is said to be differentiable on the interval (a, b) if it is differentiable at each point to E (a, b). The function f', whose value at each to E (a, b) is if(to), is called the derivative of f. The Mean Value Theorem is useful for estimating and approximating quantities. It has both a differential and an integral form: T h e o r e m B.9 ( M V T - D ) Suppose that f - f ( x ) is differentiable on the interval (a, b) and is continuous at the endpoints a, b as well. Then there is some z c (a, b) such that i f ( z ) - I f ( b ) - f ( a ) ] / ( b - a). [] T h e o r e m B . 1 0 ( M V T - I ) Suppose that g - g(x) is a continuous function on the interval [a, b]. Then there is some z e (a, b) such that f : g(x) dx - (b - a)g(z). [] Higher order derivatives of f, if they exist, are obtained by the rule f(d+l)(t)-
(f(d)(t))',
for d -
1,2,...,
(B.2)
where f(d) is shorthand for f followed by d apostrophes or primes. For example, f ( t ) - sin2t has f ' ( t ) - 2 cos 2t, f " ( t ) - - 4 sin 2t, f ' " ( t ) - - 8 c o s 2 t , and f(4) (t) 16sin2t. By convention, f(0) means f. Function f is said to be d-times continuously differentiable, for d >_ 1, if f and its derivative functions f~, f " , . . . , f(d) are all continuous. For such f, we write f c C d. For example, f ( t ) - s i n 2t belongs to C ~ , while f ( t ) - t 7/3 belongs to C 2 but not to C 3. By convention, we write f c C O if f is merely continuous. Also, if f C C d for all d - 1, 2 , . . . , we write f c C ~ . B.4.3
Convergence
of sequences,
series
and
products
An infinite sequence { a ( n ) ' n 1, 2 , . . . } is a function defined on Z +. It may take values in R or C. In both cases, the absolute value l a ( n ) - L I measures the distance between some term a(n) and some number L.
B.4.
CALCULUS METHODS
283
Infinite sequence {a(n) • n C Z +} is said to converge if there is some number L such that, for every e > 0, there is some sufficiently large N - N(e) for which n >_ N ~ l a ( n ) - L I < e. In that case, {a(n)} is said to have the limit L as n ~ oc, and we write l i m ~ o ~ a(n) - L. The partial sums sequence of {a(n) • n C Z +} is another infinite sequence { s ( N ) " N E Z +} whose terms are
s(N)
N def E a ( n ) '
for N -
1,2,3,...
n=l These take values in the same set, R or C, as {a(n)}. Now suppose that {a(n)} is an infinite sequence. We say that it is (conditionally) N summable if its partial slims converge, namely l i m N ~ }-]~n=l a(n) exists. We say that it is absolutely summable if the partial sums of {la(n)l} converge, namely l i m N - ~ Y~nN__lla(n)[ exists. We say it is square-summable if the partial sums of {la(n)l 2} converge, namely limN-,cc EnN1 la(n)l 2 exists. An absolutely summable sequence can be added up on a finite precision machine in any order, always yielding the same sum except for rounding error. For a summable but not absolutely summable series, order matters: rearrangement might even make the partial sums diverge, even in exact arithmetic. This is Riemann's Theorem on conditionally summable series, page 197 of Apostol's Mathematical Analysis. Every absolutely summable sequence is summable and square-summable, but { ( - 1 ) n / n " n • Z + } is summable to log 1 and square-summable to 7r2/6 without being absolutely summable. A doubly infinite sequence is a real or complex valued function defined on Z rather than Z +. It can be denoted by { a ( n ) : n = 0, +1, +2, .... } and considered as two infinite sequences. It is called summable if both the positive-indexed and negative-indexed sides individually are summable. Likewise, it is called squaresummable or absolutely summable if both sides have the corresponding property. S e q u e n c e s of f u n c t i o n s A sequence of functions { U n - - U n (t)} is said to converge at a point to if the sequence of numbers { u ~ ( t o ) ' n - 1 , 2 , . . . } converges as n --~ oc. If {Un(t)} converges at each t, then the limits define a function u(t) - limn~o~ un (t). The convergence is said to be uniform if Un(t) ~ u(t) at comparable rates for each t, that is, if for every e > 0 there is a sufficiently large N such that n >_ N ~ lun (t) - u(t)l < e for every t. L e m m a B . 1 1 I f U n is a continuous function for each n and Un(t) --+ u(t) converges uniformly in t, then u - u(t) is a continuous function. [:] This result is proved as Theorem 9.2 of Apostol's Mathematical Analysis. It implies that if {vn - vn(t)} is a sequence of bounded continuous functions and {Cn} is an absolutely summable sequence, then ~ CnVn is a continuous function.
A P P E N D I X B. BASICS, T E C H N I C A L I T I E S , A N D D I G R E S S I O N S
284
One easy way to prove uniform convergence is to compare with an absolutely summable sequence of numbers: B . 1 2 ( W e i e r s t r a s s M - t e s t ) Suppose {fn = f~(t) : n e Z +} is a sequence of functions defined on some domain D C R , and there is a sequence of nonnegative upper bounds (Mn : n C Z +} satisfying If~(t)l <__M~ for all n c Z + and all t C D. If ~-~n Mn converges, then
Theorem
I.
2.
t e D,
~
A(t)
ab ol tdy,
f~ converges uniformly on D;
3. IEn A(t)l_< E~ Mn for every t C D. Proof: See Apostol's Mathematical Analysis, Theorem 9.6, page 223.
Rapid decrease A function f = f ( x ) of one real variable is said to have order-d decrease at infinity if If(x)l = O(1/Ixl d) as x ~ +co, namely, if there are positive constants rd and Cd, independent of x, such that If(x)l < Cd/IXl d whenever Ixl > rd. For example, f ( x ) = 1/(1 + x 2) has order-2 decrease at infinity. A function may have order-d decrease at infinity for more than one d, proved using different constants rd and Cd. The largest d that works is called the order of decrease of f, but f is said to have rapid decrease at infinity if it has order-d decrease at infinity for every integer d > 0. For example, f ( x ) - e -(l°glxl)2 has rapid decrease at infinity. A stronger condition than rapid decrease is exponential decrease at infinity. There must be positive constants ~, r and C, independent of x, such t h a t If(x)l < __X 2 Ce -~1~1 for all Ixl > r. For example, f ( x ) - e has exponential decrease at infinity, whereas e -(l°g 1~1)2 does not. Exponential decrease at infinity implies rapid decrease. We also distinguish order of decrease as x ~ cc from decrease as x ~ -cx~. Infinite
products
The infinite product of a sequence {b(n) : n = 1, 2 , . . . } is defined by oc
N
rI b(n) de_f N---,co lira I I b(n)
n=l
(B.3)
n=l
whenever this limit exists and has a finite, nonzero value.
(Weierstrass Product Test) If the sequence { a ( n ) : n e Z +} is absolutely summable, then the infinite product of {1 + a ( n ) : n c Z +} exists and satisfies
Lemma B.13
I I I1 + a(n)l ~- exp
n=l
la(n)l n=l
.
B.4. CALCULUS METHODS
285
Proof: First note that 0 _< log(1 + [xl) _< ]x I for all real numbers x. Then, writing b(n) - 1 + a(n), observe that Ib(n)l- I1 + a(n)l _< 1 + la(n)l, and N
N
log Ib(n)l <_ E
E n--1
cx~
log(1 + la(n)l) <_ E
n--1
la(n)l < c~.
n=l
This also gives the upper bound on the size of the product. Since {a(n)} is absolutely summable, its elements satisfy la(n)l < 1/2 for all sufficiently large n. It may thus be assumed, extracting finitely many factors if necessary, that a(n) > - 1 / 2 for all n. Notice that log ll + x I > - ( 2 1 o g 2 ) I x l for all x > - 1 / 2 . Thus we may write log Ib(n)l = log I1 + a(n)l > - ( 2 log 2)la(n)l , and observe that
log
Ib( )l
___-(2 log 2) Z la( )l >
n=l
This implies
that
I-InCX~ 1
n=l
[b(n)l > O.
C h a n g e of v a r i a b l e f o r m u l a s Let u = u(t) be a real-valued function on the closed and bounded interval I = [a, b] C R, and suppose that its derivative u' exists and is continuous on I. Put
u(I) dJ { u ( t ) ' t E I} C R. Since u is continuous on I by Lemma B.7, u(I) must be a closed and bounded interval by Corollary B.6. If f = f(x) is continuous on u(I), then (f o u)u' will be continuous on I and will satisfy the following:
u( b)
fJu(a) f (x) dx -
jfa b f (u(t) )u' (t) dt.
(B.4)
This is Theorem 7.36 on page 164 of Apostol's Mathematical Analysis. It is not necessary for u to be an increasing function, so that u(I) - [u(a), u(b)] and u gives a one-to-one correspondence between I and u(I), since the factor u ~ will give negative weight to the right-hand integrand whenever u backtracks. More generally, let u - u(s, t) - (u(s, t), v(s,t)) be a vector-valued function of two real variables, defined on the rectangular region I - {(s, t) E R 2 • a < s < b,c < t < d}, w h e r e - c ~ _< a < b_< ~ a n d - c ~ _ < c < d_< c~ so that I could be unbounded. Let u(I) dej {u(s, t)" (s, t) E I} C R 2 be the possibly unbounded image region. Plane regions have more complicated geometry than intervals, so to generalize the change of variables formula we must make three assumptions on u: CV-I:
We assume that u is one-to-one, namely u(s, t) - u(s', t') ==~ (s, t) - (s', t'). Then points in the region u(I) are in one-to-one correspondence with points in I. Thus we need not worry about backtracking or overlaps.
286
A P P E N D I X B. BASICS, T E C H N I C A L I T I E S , A N D D I G R E S S I O N S
CV-2:
We assume t h a t all four partial derivatives au 0~ Ov and -o~ exist and are O s ~ Ot ~ 0--~ ~ continuous at each point in I. Then we may define the Jacobian matrix u' as follows:
Ut(8 t) de__f This m a t r i x generalizes the derivative for vector-valued functions of several variables. It satisfies a condition similar to the one in T h e o r e m B.8, namely
u(~, t) - u(~o , t o ) + u'(~o , to)
to
+ o ( l ~ - ~ol + I t - tol),
as s ~ so and t ~ to. CV-3:
We assume t h a t Ju(s,t) # 0 for all (s, t) E I, where Ju is the d e t e r m i n a n t det u' of the 2 × 2 m a t r i x u ~. This is called the Jacobian determinant of u, and is a continuous function on I defined by Ju (s t) de__f (~U (8, t) 0V (8 t) -- 0V (8 t) (~U (8, t)
,
~,
~
~,
~
This insures that no part of u(I) is pinched down to a curve or point. T h e o r e m B . 1 4 Suppose that u = u ( s , t ) satisfies conditions CV-1, CV-2, and CV-3 on the open rectangular region I = (a, b) × (c, d) C R 2. Let f = f (x, y) be a function continuous on I and suppose that f l u ( I ) f ( x , y ) d x d y exists. Then
f ( x , y) dxdy -
(I)
f ( u ( s , t), v(s, t))lJu(s , t)l dsdt.
--a
(B.5)
c
Proof: This is a special case of T h e o r e m 15.11 combined with T h e o r e m 15.7c of Apostol's Mathematical Analysis. [] For example, let I = (0, oc) × (0, 27r) C R 2 and consider the change into polar coordinates u(s, t) = s cost, v(s, t) = s sint. Then for u = (u, v) we have u(I) = R 2 \ X +, where X + = { (x, 0) : x > 0} is the positive half of the x-axis in R 2. The function u satisfies conditions CV-1, CV-2, and CV-3, since
u,(st)_(cost ' sin t
-s sint) s cos t ;
[Ju (s, t)] - Is cos 2 t + s sin 2 t] - Is ] - s # 0.
This change of variable provides a clever old way to show t h a t fR e - ' x : dx - 1"
(L)' e -~x2 dx
-
e - ' x 2 e -'y2 dxdy (~3
e -'(x2+y2) dxdy
(X)
_
2
e_~(x~+y2) dxdy -
e - ~ 2 s dsdt
2\X+ -
/s
--0
e - ~ 2 27rsds -
=0 -e -~2
The unsquared integral is +1 because the integrand e - ~
I
s=0
0 =
1.
is strictly positive.
(B.6)
B.4. CALCULUS METHODS
287
Integrability Riemann defined the integral as a limit of finite sums over finer and finer partitions of the interval [a, b]. It always exists for nice integrands and nice intervals: B . 1 5 If f = f(x) is continuous on a closed and bounded interval I = [a, b] C R, then the Riemann interval f : f (x) dx exists.
Theorem
Any complex-valued function f = f(t) can be written as f = ~ f + i~f, where ~ f = ~f(t) and ~ f = .~f(t) are unique real-valued functions called, respectively, the real part and imaginary part of f. Here i satisfies i 2 = - 1 . Then f is continuous if and only if ~ f and ~ f are both continuous. If f is continuous on a closed and bounded interval [a, b], it is Riemann integrable with
/a b
/a b
f (t) dt
de_f
/a b
~ f (t) dt + i
~ f (t) dt.
Also, f is differentiable if and only if .~f and ~ f are both differentiable, with
d f ( t ) d~f d ~ f ( t ) + i d ~ f ( t ) " Roughly speaking, for any property that is preserved by addition, f has the property if and only if both ~ f and .~f have the property. An improper Riemann integral of f is the limit of Riemann integrals as the interval of integration is enlarged to approach some discontinuity of f, or to fill out an unbounded domain. For example, the following is a typical improper Riemann integral: e x dx def lim c~
a--+(x~
e x dx - lim [ex] ]o_ _ lira (1 a
a---~oc
a
-
e -a)
--
1.
a--~c<)
A function f = f(t) is said to be absolutely integrable on an interval [a, b] if f : If(t)ldt exists and is finite. This applies to real or complex functions f. If a = - o c or b = +oc or both, this definition means that a finite limit L exists such that for every e > 0, we can find finite endpoints a0, b0 with a < a0 < b0 < b so that:
Ij{ab' < u(t)' C d' t - L, whenever a < a' < a0 and b0 < b' < b. A function u = u(t) is said to be squareintegrable if u 2 is absolutely integrable. Lebesgue's definition of the integral, which is nicely discussed in Apostol's Math-
ematical Analysis, has the property that f : If(t)l dt exists and is finite if and only if f : f ( t ) d t exists and is finite. In no case does cancellation of positive and negative parts of f affect whether the integral is computable; only the absolute size of f matters. This is not true for Riemann's integral: the function f(t) = 1 if t is rational, f(t) = - 1 if t is irrational, which is not Riemann integrable on [0, 1] because it has too many discontinuities, is nevertheless absolutely Riemann integrable on [0, 1] because If(t)l = 1 for all t so Ifl is continuous.
A P P E N D I X B. BASICS, TECHNICALITIES, A N D DIGRESSIONS
288
Differentiation of integrals Suppose t h a t u = Ux(t) is a function of t, but also depends on a p a r a m e t e r x. Then U(x) dej f : ux(t)dt, where [a, b] is some fixed interval, defines a function U = U(x) at each value of x where Ux is continuous in t on all of [a, b]. This U inherits some of the properties of ux:
Theorem B . 1 6 If, for all x in some open interval I, both Ux(t) and ° u ~ ( t ) are continuous on I x [a, b], then the function U(x) - f : Ux(t) dt exists and is differentiable at all x C I, and the derivative may be expressed as a Riemann integral: U'(x) -
d U(x) -
/abX
Ux(t) dt
The function U~(x) so defined is continuous at each x E I. For example, consider uz(t) - 7l e-xt2 0 < a < b < cc and x ¢ 0 we have:
d /a b e - x t 2 U'(x)-
t
dt
-
Then ° u~(t) -
fab - t e -xt2 dt - ~1 [e-xt2 ]
b
- t e -~t2 , so for any
e-xb2
t--a
But Ux(t) and o-%ux(t) are both continuous at x -
-- e -xa2
2x
0, so the function U ' ( x ) i s
continuous at x - 0 where its value is f : ( - t ) d t - (a2-b2)/2. A little simplification gives the identity limx-~0 ~1 ( e - a X - e - b x ) - b - a.
B.5
Some basic probability theory
A probability space is a nonempty set X, a sufficiently large collection A of subsets A c X called events, and a nonnegative probability function Pr defined at each A c A and satisfying certain niceness conditions. Think of points in X as possible outcomes of an experiment or measurement, with a subset A being a range of outcomes. Then Pr(A) is the fraction of outcomes falling within the range A. One such probability space is the discrete set X = {H, T}, the events 0, {H}, {T}, and X itself, and the function Pr defined by Pr(0) = 0, P r ( { H } ) = P r ( { T } ) = 12 ' and P r ( X ) - 1 This is the familiar "fair coin toss," giving heads H or tails T with equal likelihood. More generally, a discrete probability space is any finite or countable set X. A is sufficiently large in the following sense: • X belongs to A. • If A belongs to A, then so does A c, the complement of A in X. • For each sequence {Ai} of subsets in A, the union UiAi belongs to A. • For each sequence {Ai} of subsets in A, the intersection niAi belongs to A.
B.5. SOME BASIC PROBABILITY THEORY
289
Such a collection of subsets is called a sigma-algebra, because it is closed under (countably infinite) algebra-like combinations such as union and intersection. The two-subset collection , 4 - {X, 0} is the simplest possible sigma-algebra. Pr satisfies conditions derived from intuitive notions of probability: 1. P r ( X ) - 1, that is, X describes all outcomes under consideration. 2. Pr(0) - 0, that is, a non-outcome need not be considered. 3. I f A , B c ~ 4 a n d A c B, then 0 < Pr(A) < P r ( B ) < 1. T h a t is, allowing more outcomes makes an event likelier. 4. Pr(t&Ai) - Y'~-iPr(A) for each sequence {Ai} of disjoint subsets in A. T h a t is, the probabilities of nonoverlapping events simply add up. For example, a set of n > 1 equally likely outcomes is described by the discrete probability space X - {1, 2 , . . . , n}, with .4 being all the 2 n different subsets of X and Pr defined by Pr({1}) - . . . Pr({n}) - 1. From that and the fourth condition on Pr, we compute, for example, that Pr({1, 2 } ) - 2/n. In general, to compute the probability of an event, decompose it into disjoint simple events whose probabilities are known, and then use the additivity of the probability function. An example of a continuum probability space is the unit interval X - [0, 1], with ,4 being the sigma-algebra generated by all the open intervals (a, b), where 0 < a < b < 1. These are often called the Borel subsets of [0, 1]. Pr is computed on the Borel sigma-algebra from conditions 1-4 and its values on intervals: Pr(a, b) def I b _ al" More generally, for the same X and .A, we can specify another probability function by the formula Pr(a, b) de__f
p(x) dx,
(g.7)
where p - p(x) is a nonnegative and integrable probability density function, or pdf, satisfying Pr(0, 1 ) - f l p ( x ) d x - 1. Note that p - 1 gives the first example. The real line R is another continuum probability space R. Here we must use some nonconstant p _> 0 with fR p(x)dx - 1 to define the probability function on Borel subsets. The Gaussian, or normal distribution, is the probability function determined by the following pdf:
1 exp((x-P)2) 2a 2
p ( x ) - V/~----~
,
(B.8)
where # C R is called the mean and a > 0 is called the standard deviation. These can be expressed as moment integrals of p, which are defined further on in Equation B.11. In that notation, 1 # - M1 and a 2 - Var(p) - M 2 - M 2. Thus, if a probability function is known to be Gaussian, then it is completely determined by its first and second moments. 1We abuse notation by writing p instead of the unnamed probability function it determines.
290
A P P E N D I X B. BASICS, T E C H N I C A L I T I E S , A N D D I G R E S S I O N S
The cartesian product of probability spaces can be defined, too. If X 1 and X2 are probability spaces with respective sigma-algebras A2, A2 and probability functions P1, P2, then X = X1 x X2 is another probability space. Its events A are the sigma-algebra generated by all products A1 x A2, where A1 C ¢41 and A2 C A2. Its probability function is computed from its definition on such elementary product sets: Pr(A1 x A2) de_f Prl(A1)Pr2(A2). For example, rolling two fair dice gives a point in the cartesian product space X1 x X2, where X1 = X2 = {1, 2, 3, 4, 5, 6}. Both factors are equipped with the sigma-algebras and probability functions of 6 equally likely outcomes. The event of rolling a total of 3 is a subset of the product space; it decomposes into the disjoint union of elementary product events { 1 } x {2} tO {2} x { 1}, giving a probability Pr({1} x {2} tO {2} x {1})
--
Pr({1} × {2})+Pr({2}
=
P l ( { 1 } ) P 2 ( { 2 } ) + P1({2})P2({1})
=
(6)(6) + (6)(6)
1
1
1
1
× {1}) 1
-- 18"
Various counting principles and algebraic techniques are used to find such a decomposition so that a probability can be computed. For example, the probability that the sum of the dice is an odd number can be computed as
Podd --
E Pr(xl)Pr(x2). Xl + x2 odd
This calculation can be avoided. Observe that an odd sum can be obtained in the same number of ways as an even sum: just swap the odd and even numbers on one of the dice. Thus Perch - Podd, with pcv~n defined in the obvious way. Since 1 Peven -t-Podd - - 1, w e conclude that Podd -~. The product construction works similarly for N > 2 spaces X I , . . . , X N . Repetitions of a measurement can often be modeled by such a product probability space with all factors the same, and then they are called Bernoulli trials, with each measurement described as independent and identically distributed. A random variable is a real-valued function f on a probability space X which is nice enough so that {x c X " f ( x ) > y} belongs to the events collection A, for every real value y. It is thereby possible to compute the probability that f takes values in some interval, because the outcomes leading to that value form a set for which Pr is defined. For example, the sum of two fair dice is a random variable on the product probability space X - { 1 , . . . , 6} x { 1 , . . . , 6}. We may write f ( x l , x 2 ) - - X l -t- x 2 in the coordinates (Xl, x2) of that space. In another example, if X c R, then f ( x ) - x can serve as a random variable. Random vectors are vector-valued function on X nice enough so that each component of f is a random variable. For example, if X is the unit square in R 2, then f ( x l , x 2 ) - (Xl + x2,xl - x2) is a random vector. The expected value of a random variable f is its average on all of X, computed using the probability function. In the discrete case, X can be enumerated and .4
B.5. SOME B A S I C P R O B A B I L I T Y T H E O R Y
291
contains all single-point subsets of X:
E(f)-
E
f(x)Pr({x}).
(B.9)
xEX
In the case X = [0, 1] C R with the Borel sigma-algebra A, we must approximate single-point sets using open subintervals from A. This is similar to integration with Riemann sums: fix a disjoint sequence {Ai} of subsets from .4 such that X = t&Ai, then pick xi E Ai and approximate E ( f ) ~ E i f(xi)Pr(Ai). If f is a continuous function, this will tend to the Riemann integral f l f ( x ) p ( x ) dx as the decomposition of X is refined, namely as maxi Pr(Ai) -+ 0. We may therefore define the expected value of such a random variable on a continuum probability space X to be the integral £ .
E(f) - / f ( x ) p ( x ) dx. .Ix E X
(B.10)
Note the similarities between Equations B.10 and B.9. An idea of Lebesgue can sometimes be used to overcome the technical problem of evaluating the integral: Let R(y) = Pr({x : f ( x ) > y}) be the cumulative distribution function defined by f. Then
E(f) -/+_~
y dR(y),
whenever this integral exists. Note that R decreases from 1 to 0 as y goes from - o o to +oc. The moments of a probability function are the expected values of the basic random variables 1, x, x 2,.. •
E Mk -- E ( x k) --
xkpr({x})'
if X is a discrete probability space;
xCX
fx
(B.11)
xkp(x) dx'
if X is a continuum.
EX
Since both sums and integrals preserve finite sums, we can compute the expected value of any polynomial random variable f ( x ) = ao + alx + . . . q- anx n from these pieces: E ( f ) = aoMo + . . . + anMn. Note that Mo = 1 in all cases. The first moment M1 of a probability function Pr, if it exists, is called its mean. If in addition the second moment M2 exists, then Var(Pr) dej M2 - M12 is called its variance. By adding and subtracting and using the definitions, we can show
M2 - M 2 - E ( x 2) - 2MIE(X) + M21 - E ( x 2 - 2 M i x + M21) - E([x - M112). This is the more familiar definition of variance: Var(Pr) - E ( [ x - E(x)] 2) is the expected value of squared deviation from the mean. This calculation also proves that Var(Pr) k 0, or that M2 k M 2 whenever both moments exist.
292
APPENDIX B. BASICS, TECHNICALITIES, AND DIGRESSIONS
B.6
Some
more
advanced
results
We sketch the proofs of some useful results that are unfortunately beyond the scope of this text. While important technical issues must be left unresolved at our level of analysis, I believe the outlines provided here are useful guides for further study. T h e o r e m B.17 ( P l a n c h e r e l ) Suppose that u = u(x) and v = v(x) belong to L2(R), and have Fourier integral transforms it and ~, respectively. Then (ft, f~l =
(u, v), namely, ft(~) ~(~) d~ ---
--
(X)
u(x) v(x) dx. ~
--
0 0
Proof: For small e > 0, let ¢~ be the function defined by
¢(~) _ ~--e;
¢~(~) ~oJ ¢(~) _ ~-~(~)~.
We use ¢ and ¢~ because we know their Fourier integral transforms:
$ ( x ) - ¢(x);
¢':(x)- l¢(x).
Now, ¢~ is bounded by 1, continuous and rapidly decreasing, hence integrable. Also, for each ~ c R, Ce(~) --+ 1 as c ~ 0. Thus, ¢~w is an integrable function whenever w = w(~) is integrable, and lim
e---+O
fR¢~(~)w(~)d~-/R[~im
¢ ~ ( ~ ) ] w ( ~ ) d ~ - f ~ w ( ¢ ) d~.
On the other hand, if g = g(x, y) is integrable on R e, then lim//rt e---*0
2
g(x, y) l ¢( y - X ) dxdy - /i g(x, x) dx" £
Both of these limits may be evaluated using the Lebesgue Dominated Convergence Theorem (Theorem 10.27 on page 270 in Apostol's Mathematical Analysis). Now let w(~) = ~(~)~(~), apply the first limit identity, expand the two Fourier transforms as integrals, and interchange the order of integration:
(~2,~)) =
lim f
e--+0 j ~ CR
¢~(~)ft(~) ~(~)d~
lim f f f
¢~(~)e-2~iX~u(x)e-2~iy~v(y)d~dxdy
e--+o J J JR3
=
e-~olimff R2 u(x)v(Y) [/RCe(~)e27ri(x-Y)~d~ ] dxdy
=
~01im]~R2 u(x)v(y)-l~ ¢(y --~ x) dxdy -- fir u(x)v(x) dx -
(u, v).
For the last step, we let g(x, y) = u(x)v(y) and used the second limit identity.
[]
B.6.
293
SOME MORE ADVANCED RESULTS
Hilbert spaces A Hilbert space X is an inner product space that supports approximation by being complete: if an infinite sequence {Un} C X settles down as n ~ oc, in the sense that for each e > 0 there is a sufficiently large N such that IlUn - u m II < e for all n, m _> N, then it defines a vector u ~ - limn_.~ un that is also in X. Sequences that settle down this way are called Cauchy sequences. All finite-dimensional Euclidean spaces, whether real or complex, are complete (See Apostol's Mathematical Analysis, Theorem 4.8, page 73) and thus are Hilbert spaces. The space g2(N) is also complete (See Royden's Real Analysis, Problem 12, page 126). However, the inner product space L i p is not complete. Let un be defined by u~(t) - t ~ for n - 1, 2 , . . . , all of which are evidently Lipschitz continuous on [0,1]. Then Ilunll 2 -
~01 (tn) 2 d t -
1
2 n + 1'
2 for any -t-- x/2rn+ll, which is at most x/2N+I n, m > g . Thus { u n ' n 1 , 2 , . . . } is a Cauchy sequence. However, un(1) - 1 for all n, whereas u~(t) --. 0 for all 0 < t < 1, so the limit function u ~ is discontinuous at t - 1 and cannot belong to Lip. Completing an inner product space X to get a Hilbert space means:
SO [[Un- Urnl[ (_ [[Un[[ + [[Um[[- ~ 1
1. Appending to the set X all limits of Cauchy sequences in the original X; 2. Identifying two elements u, v of the augmented X as equal if Ilu -
vii-
o.
It is necessary to extend the inner product to the completed set by using limits and to take care of other technicalities. For example, we must show that limits of Cauchy sequences in the augmented X are already limits of Cauchy sequences in the original X. Also, individual elements of the completed inner product space can be obtained by way of more than one infinite sequence in X, so we must devise a sensible convention for labeling them. These problems arise already for the real line, which is the completion of the rational numbers: for instance, 1 = 0 . 9 9 9 . . . has at least two decimal representations. An inner product space can always be completed to a Hilbert space. The exercises in Royden, pages 146-147, explore the details of this in great generality. Subsets closed under linear combination are considered subspaces of a Hilbert space only if they are complete. Finite-dimensional linear spans are complete and hence are subspaces, but it is also possible to define the (complete) subspace generated by infinitely many vectors of an infinite-dimensional Hilbert spaces. For example, span {vi : i C N} is defined to be the completion of the subspace consisting of all vectors of the form }--~i=0 m aivi, for any m and any scalars ao, a l , . . . , am. Another example is the sequences in t~2 that have zeroes at all prime indices; these form a complete, infinite-dimensional subspace of t~2. Finite-dimensional Hilbert spaces have orthonormal bases by the Gram-Schmidt construction, Theorem 2.7. The generalization of such a basis to an infinite dimen-
294
A P P E N D I X B. B A S I C S , T E C H N I C A L I T I E S , A N D D I G R E S S I O N S
sional Hilbert space X requires some completeness property. So, an infinite subset B = {bn : n c N} C X is called a Hilbert basis if it satisfies the following:
Hilbert Basis A x i o m s Orthogonality: If n # m, then (b~, b,~) = 0; Normalization: For all n, (b~, b~) - 1; Completeness: If (v, b~) = 0 for all n, then v = 0. For example, {e~ : n c N} is an Hilbert basis for e2(N). It is sometimes more convenient to use Z or Z + for the index set. An example from Fourier analysis, studied in Chapter 3, is the orthonormal basis {b~ : n c Z} for L i p and L 2 defined by the complex exponential functions bn (t) de__fe2~int" One way to get subspaces of a Hilbert space is by orthogonal projection:
T h e o r e m B . 1 8 I f X is a Hilbert space and P : X ~ X is an orthogonal projection, then P X is a Hilbert subspace with the same norm and inner product as X . Proof." We must show that P X is complete. But if {xk} is a Cauchy sequence in P X , it is a Cauchy sequence in X so it has a limit limn~o~ xk = x ~ C X. It is only necessary to show that x ~ E P X , which is true if x ~ = P x ~ . But xk = P x k , so [Ixk - P x ~ ] l = IlPxk - Pxo~ll = [IP(xk - x~)ll < Ilxk - x~ll, which means that l i m k ~ xk = P x ~ = xo~. []
Given any orthonormal set of vectors B = {bn} c X, finite or infinite, we may form the orthogonal projection def
PB'X~X;
PBX --
E(b'~'x)
bn"
n
We may then show that the range of PB is exactly span B, the completion of the linear span of the vectors in B.
B.7
Rising cut-off functions
We finish by applying the results in this appendix to the characterization of all rising cutoff functions that may be used for fraying and splicing. Notice that any function satisfying Equation 3.11 must be of the form
r(t)
def
eip(t) sin 0(t),
(B.12)
where p and 0 are real-valued functions satisfying
p(t)
_{2nTr, 2rnTr,
ift<-l, if t > 1;
0 ( t ) - - { 0'~ 7,
ift>lift<-l' ;
o(t) + o(-t)
7r -i
(B 13)
Of course, any real-valued rising cut-off function can have p = 0. In any case, Ir(-t)lIsin[~ - 0 ( t ) ] l - I c o s 0 ( t ) l , so r(t)l 2 + I r ( - t ) l 2 - 1.
B.8.
295
FURTHER READING
Let r r(t) be any differentiable rising cut-off function. Then dl (t)l is a symmetric continuous bump function supported on [-1, 1]. This observation provides a mechanism for parameterizing all rising cut-offs. Start with an integrable bump function ¢ = ¢(t) satisfying the following conditions: -
¢ ( t ) - - 0 i f l t ) > 1;
¢(t)--¢(-t)
for allt;
F
¢(s) d s -
7r -~.
(B.14)
Then obtain O(t) - f t I 0 ( 8 ) d s . But any integrable function ¢ defined on [0, 1] with nonzero integral can be multiplied by some constant and extended by reflection about zero to satisfy Equation B.14. As an application of this construction, we start with a quadratic polynomial and obtain a cubic spline for the angle function: ¢ ( t ) - -37r ~ ( 1 - t)(1 + t);
7r [2 + 3 t - t3]; O(t) - -~
-1 < _ t _< 1.
(B.15)
The example cut-off r0 of Equation 3.12 comes from ¢(t) -- 41[_1,1] and O(t) 71" 71"2 71" ~(1 + t) for t E [-1, 1]. Likewise, taking ¢(t) - -~-cos 5t for t C [-1, 1] yields rl from O ( t ) - -g ~(1 + sin ~ t).
B.8
Further Reading Tom M. Apostol. Calculus, volume I. John Wiley & Sons, New York, second edition, 1967. ISBN 0-471-00005-1. Tom M. Apostol. Calculus, volume II. John Wiley & Sons, New York, second edition, 1969. ISBN 0-471-00007-8. Mark Davis, Michael Everson, Asmus Freytag and John H. Jenkins. Unicode 3.2 Code Charts. Unicode Technical Committee, 2002. Available from URL http ://www. uni code. org.
Gene H. Golub and James M. Ortega. Scientific Computing and Differential Equations. Academic Press, San Diego, 1992. ISBN 0-12-289255-0. Steven G. Krantz. Techniques of Problem Solving. American Mathematical Society, Providence, Rhode Island, 1997. ISBN 0-8218-0619-X. Halsey L. Royden. Real Analysis. Macmillan Publishing Company, 866 Third Avenue, New York, third edition, 1988. ISBN 0-02-404151-3. Allen B. Tucker. Programming Languages. McGraw-Hill, New York, 1986. ISBN 0-07-065416-6. • Mladen Victor Wickerhauser. Adapted Wavelet Analysis from Theory to Software. A K Peters, Ltd., Natick, Massachusetts, 1994. ISBN 1-56881-041-5.
This Page Intentionally Left Blank
Index Cauchy-Schwarz inequality, 37 character, 180 Chebyshev nodes, 113 polynomial, 112 chebyshevpoly (), 114 checksum, 205 code, 181 Huffman, 193 linear, 201 prefix, 182 uniquely decipherable, 181 compact support, 73 complete, 293 completeness, 152 periodic, 176 complexity, 179 composition, 45 conditional probability density, 124 conditionally summable, 283 conditionals, 276 conditioning, 18 conjugacy, 152 containment, 147 continuous, 281 continuum probability space, 289 control characters, 273 conventional indexing, 152 CQF, 151 CRC-32, 218 CSG (Checksum Goals), 207
absolutely integrable, 287 absolutely summable, 283 accuracy, 124 adjoint, 47 matrix, 47 periodic, 160 Aft, affine group, 136 algorithm, 1,275 algorithmic complexity, 179 alphabet, 180 antisymmetry, HA or WA, 169 ASCII, 179, 273 assignment, 276 band-limited function, 120 bandwidth, 120 basis, 28 Schauder, 32 Bessel's inequality, 66 binary tree, 184 binomial coefficient, 76 biorthogonal dual, 40 filters, 169 bit rate, 188 bits(), 9 Borel subsets, 289 canonical Huffman tree, 196 cas, 98 casting out nines, 205 castout9 (), 206 c a s t o u t 11 (), 206 castout255 (), 208 castout257 (), 208 Cauchy sequence, 13, 293
d-ary tree, 185 decimals, 9 decision function, 127 decrease, 147 297
298 decrements, 276 decipherex(), 181 degree, 108 dense, 32 dependency relation, 27 derivative, 281 det (), 62 determinant, 55, 62 DFT, 95 DHT, 98 digits (), 9 dilation, 147 operator, 85 dimension, 28 discrete probability space, 288 discrete wavelet decomposition, 155 dist (Hamming), 203 d i v d i f f (), 111 divided difference, 110 division algorithm, 2 divisor, 3 doubly infinite sequence, 283 DWT, 145 dut (), 160 dynamicdecoding (), 264 dynamicencoding (), 219 E, E +, 197 efficient coding, 188 encoding, 181 entropy, 187 epwconstant (), 115 e p u l i n e a r (), 130 error representation, 18 round-off, 14 truncation, 14 estimator, 127 unbiased, 128 Euclid, 12 Euclid's algorithm, 4 extended, 8 for mod-2 polynomials, 269 mod-2 polynomials, 213 events, 288
INDEX
expected value, 290 factorization, 5 faithful, 137 father function, 148 FFT, 95, 98 fft (), 98 FHT, i00 fht (), i00 filter, 146 filter length, 152 filter transform, 157 periodic, 160 finite algorithm, 275 finite impulse response (FIR), 146 finite-energy signals, 35 float, 15 float.h, 15 floats, 1 floor, 2 focused, 124 for loop, 277 Fourier coefficients, 83 Fourier series, 83 exponential, 86 fray(), 80 fraying, 79 Gaussian, 289 elimination, 57 noise, 126 sinc function, 122 Gaussian function, 93 gcd (), 4 gcdx(), 8 gepp (), 58 gilbertcode (), 268 Givens rotation, 57 graph, 183 greatest common divisor, 3 Haar filter, 152 haarlift (), 166 Haar measure, 140 half-sample symmetry,
168
299
INDEX
Hamming distance, 203 hexadecimal, 9 Hilbert basis, 294 Hilbert-Schmidt norm, 49 Horner's method, 108 horner (), 108 host, 10 hsldht (), 262 hslhaarfilter (), 261 hslidht (), 262 hslihaarfilter (), 261 hslpredict (), 261 hslupdate (), 261 hsp (), 168 Huffman code, 193 ideal value, 123 iFFT, 98 ifft (), 98 ihaarlift (), 167 ildht0 (), 167 ill-conditioned, 19 imprecision, 123 inaccuracy, 124 increase, 147 increments, 276 independence, 152 periodic, 176 infinite decimal expansions, 13 infinite product, 284 infinite sequence, 282 information source, 180 inputs, 275 instructions, 275 integers, 1 negative, 2 positive, 2 integrable absolutely, 287 square, 287 interior vertex, 185 Intermediate Value Theorem, 281 interpolation condition, I17 intmod2polydegree (), 212 intmod2polydivision (), 213
intmod2polygcd (), 269 intmod2polyirreducibe (), 214 intmod2polyproduct (), 211 intmod2polysum (), 210 inverse Fourier transform, 88 ipcqfilter(), 162 ipd~t (), 257 ipdwt0 (), 163
Jacobian, 286 joint probability density, 124 Kolmogorov complexity, 179 Kronecker delta, 38, 149 L 2, 34 g2, 33 Lagrange interpolation, 109 lagrange (), 110 ldht0 (), 167 Lebesgue integral, 287 left invariant integral, 140 left invariant measure, 140 left sided limit, 280 Leibniz' rule, 76 length preserving, 56 letter, 180 lifting, 166 limit, 280, 283 limits.h, i0 linear code, 201 combination, 26 independence, 27 span, 27 transformation, 42 Lip, 34 Lipschitz condition, 34, 282 Inormalize (), 172 loop, 82 for, 277 while, 277 lower triangular, 56 LU decomposition, 59 lupp (), 60
300 Mallat algorithm, 157 mantissa, 13 matrix, 42 coefficients, 44 representation, 136 mean, 291 Mean Value Theorem, 282 measurement density, 124 memory, 275 message, 180 encoding function, 181 instance, 180 meta-characters, 273 Minkowski inequality, 37 mipp(), 59 mod-2 polynomial, 209 mod2polychecksum (), 217 mod2polydegree (), 211 mod2polydivision(), 212 mod2polygcd(), 213 mod2polyint (), 210 mod2polyproduct (), 211 mod2polysum (), 2 i0 moments, 291 mother function, 133 MRA, 147 multipliers, 276 multiresolution analysis, 147 N, natural numbers, 2 Newton form, 110 newtonpoly(), 111 noise, 126 nondegeneracy, 29 norm axioms, 29 normal density, 126 normal distribution, 289 normalization, 151 periodic, 176 normalizers, 276 O, 197 occurrence probability, 180 onormalize (), 261 operator norm, 49
INDEX
orthogonal, 24 basis, 38 complement, 38 CQF, 151 MRA, 148 orthonormal basis, 38 outputs, 275 overflow, 12 parity, 197 Parseval's formula, 67, 84 partial sums, 283 p c q f i l t e r (), 162 pdf, 289 pdwt (), 163 pdwt 0 (), 163 %, remainder operator, 2 periodic, 70 extension, 75 filter transform, 160 periodization, 70 smooth local, 82 permutation matrix, 63 piecewise function, 115 Plancherel's theorem, 292 pointwise convergence, 283 polarization, 26 Poly, 33 polynomial, 108 power spectrum, 85 precision, 123 prediction, 171 prefix code, 182 prime, 5 factorization, 5 mod-2 polynomials, 214 probability density function, 289 probability space, 288 projection, 51 pseudocode, 275 pwconstant (), 115 pwlinear (), 116 pyramid algorithm, 157 Q, rational numbers, 12
301
INDEX
quadrature filter, 146 quantization, 123 quasi-inverse, 6 quaternary, or quadtree, 185 R, real numbers, 13 r l ( ) , 78 random variable, 290 rapid decrease, 284 relatively prime, 5 mod-2 polynomials, 214 remainder operator (%), 2 representation, 137 return, 277 Riemann integral, 287 right invariant integral, 251 right invariant measure, 174 right sided limit, 280 rigid motion, 56 rising cut-off function, 78, 294 rotation, 56 round-off error, 14 sampling theorem, 121 scalars, 26 scale invariance, 117 scaling function, 145, 148 Schauder basis, 32 unconditional, 33 scientific notation, 13 self-orthonormality, 151 periodic, 176 selfadjoint, 48 sequence, 282 side-effect, 277 sign-and-magnitude, 11 signal to noise ratio, 126 sinc function, 92 Gaussian, 122 size preserving, 162 smooth, 76 source, 180 span, 27 spectral density, 120 splice(), 80
splicing, 79 spreading in support, 159 sqrt, 277 square-integrable, 287 square-summable, 283 s s l u ( ) , 61 sublinearity, 29 submultiplicativity, 49 subspace, 27 summable, 283 support, 73 symmetric functions, 117 symmetry, HS or WS, 168 trace, 50 transformation, 42 translation, 56 tree binary, 184 canonical Huffman, 196 d-ary, 185 Huffman, 193 quaternary, 185 truncation error, 14 two-scale relation, 146 twos complement, 11 unconditional basis, 33 underflow, 12 Unicode, 275 uniform convergence, 283 unique factorization, 5 uniquely decipherable code, 181 unitary, 56 representation, 139 transformation, 138 updating, 171 upper triangular, 56 Vandermonde matrix, 95 variance, 291 vector, 26 vertex, 185 Vol (Hamming sphere), 203 wavelet expansion, 157
302 wavelet transform, 140 inverse, 143 weighted depth, 191 well-conditioned, 18 while loop, 277 white noise, 126 whole-sample symmetry, 168 wide characters, 275 ws142dwt (), 173 ws142filter(), 172, 173 ws142idwt (), 173 ws142ifilter(), 172 ws197dwt (), 260 ws197idwt (), 260 ws197ifilter (), 260 wslpredict (), 171 wslupdate (), 171 wsp (), 169 Z, integers, 2 zero-one matrix, 63
INDEX