Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12:...

37
July 20, 2013 Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The University of British Columbia {ascher,greif}@cs.ubc.ca Slides for the book A First Course in Numerical Methods (published by SIAM, 2011) http://www.ec-securehost.com/SIAM/CS07.html

Transcript of Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12:...

Page 1: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

July 20, 2013

Chapter 12: Best Approximation

Uri M. Ascher and Chen GreifDepartment of Computer ScienceThe University of British Columbia

{ascher,greif}@cs.ubc.ca

Slides for the bookA First Course in Numerical Methods (published by SIAM, 2011)

http://www.ec-securehost.com/SIAM/CS07.html

Page 2: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Goals

Goals of this chapter

• To develop some elegant, classical theory of best approximation using leastsquares and weighted least squares norms;

• to develop important families of orthogonal polynomials;

• to examine in particular Legendre and Chebyshev polynomials.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 1 / 1

Page 3: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Outline

Outline

• Best least squares approximation

• Orthogonal basis functions

• Weighted least squares

• Chebyshev polynomials

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 2 / 1

Page 4: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Motivation

Approximation, not just interpolation

• As in Chapters 10 and 11, we are given a complicated (or implicit) functionf(x) which may be evaluated anywhere on the interval [a, b], and we look fora simpler approximation v(x) =

∑nj=0 cjϕj(x), where ϕj(x) are known basis

functions with some useful properties.

• Unlike Chapters 10 and 11, we no longer seek to impose v(xi)− f(xi) = 0 atany n + 1 specific interpolation points.

• One reason for shunning interpolation: if there is significant noise in themeasured values of f then measuring the approximation error atm + 1 > n + 1 points may yield more plausible or meaningful results. Thisleads to overdetermined linear systems which are most easily solved usingdiscrete least squares methods; see Section 6.1.

• Here, however, we stick to the continuous, rather than discrete level, and useintegrals rather than vectors. Typically we may seek a function v(x), i.e.,coefficients cj , so as to minimize

∥v − f∥22 =

∫ b

a

(v(x) − f(x))2dx.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 3 / 1

Page 5: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Motivation

Aside: function norms

• For all integrable functions g(x) and f(x) on an interval [a, b], a norm ∥ · ∥ isa scalar function satisfying

• ∥g∥ ≥ 0; ∥g∥ = 0 iff g(x) ≡ 0,• ∥αg∥ = |α|∥g∥ for all scalars α,• ∥f + g∥ ≤ ∥f∥ + ∥g∥.

The set of all functions whose norm is finite forms a function spaceassociated with that particular norm.

• Some popular function norms and corresponding function spaces are:

L2 : ∥g∥2 =

(∫ b

a

g(x)2dx

)1/2

, (least squares),

L1 : ∥g∥1 =∫ b

a

|g(x)|dx,

L∞ : ∥g∥∞ = maxa≤x≤b

|g(x)|, (max).

• We have seen the L∞ norm in action when estimating errors in Chapters 10and 11. Here we concentrate on the L2 norm, occasionally in weighted form.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 4 / 1

Page 6: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Motivation

Aside: function norms

• For all integrable functions g(x) and f(x) on an interval [a, b], a norm ∥ · ∥ isa scalar function satisfying

• ∥g∥ ≥ 0; ∥g∥ = 0 iff g(x) ≡ 0,• ∥αg∥ = |α|∥g∥ for all scalars α,• ∥f + g∥ ≤ ∥f∥ + ∥g∥.

The set of all functions whose norm is finite forms a function spaceassociated with that particular norm.

• Some popular function norms and corresponding function spaces are:

L2 : ∥g∥2 =

(∫ b

a

g(x)2dx

)1/2

, (least squares),

L1 : ∥g∥1 =∫ b

a

|g(x)|dx,

L∞ : ∥g∥∞ = maxa≤x≤b

|g(x)|, (max).

• We have seen the L∞ norm in action when estimating errors in Chapters 10and 11. Here we concentrate on the L2 norm, occasionally in weighted form.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 4 / 1

Page 7: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Motivation

Aside: function norms

• For all integrable functions g(x) and f(x) on an interval [a, b], a norm ∥ · ∥ isa scalar function satisfying

• ∥g∥ ≥ 0; ∥g∥ = 0 iff g(x) ≡ 0,• ∥αg∥ = |α|∥g∥ for all scalars α,• ∥f + g∥ ≤ ∥f∥ + ∥g∥.

The set of all functions whose norm is finite forms a function spaceassociated with that particular norm.

• Some popular function norms and corresponding function spaces are:

L2 : ∥g∥2 =

(∫ b

a

g(x)2dx

)1/2

, (least squares),

L1 : ∥g∥1 =∫ b

a

|g(x)|dx,

L∞ : ∥g∥∞ = maxa≤x≤b

|g(x)|, (max).

• We have seen the L∞ norm in action when estimating errors in Chapters 10and 11. Here we concentrate on the L2 norm, occasionally in weighted form.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 4 / 1

Page 8: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Motivation

Why continuous approximation?

• Discrete least squares (Chapter 6) is certainly efficiently manageable in manysituations and readily applicable. Indeed, in this chapter we don’t directlyconcentrate on efficient programs or algorithms.

• However, sticking to the continuous allows developing a mathematicallyelegant theory.

• Moreover, classical families of orthogonal basis functions are developed whichprove highly useful in Chapters 13, 15, 16 and others.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 5 / 1

Page 9: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Continuous least squares

Outline

• Best least squares approximation

• Orthogonal basis functions

• Weighted least squares

• Chebyshev polynomials

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 6 / 1

Page 10: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Continuous least squares

Best least squares approximation

• We are still approximating a given f(x) on interval [a, b] using

v(x) =n∑

j=0

cjϕj(x),

but we are no longer necessarily interpolating.

• Determine the coefficients cj as those that solve the minimization problem

minc

∥f − v∥2 ≡ minc

∫ b

a

f(x) −n∑

j=0

cjϕj(x)

2

dx.

• Taking first derivative with respect to each ck in turn and equating to 0 gives

∫ b

a

f(x) −n∑

j=0

cjϕj(x)

ϕk(x)dx = 0, k = 0, 1, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 7 / 1

Page 11: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Continuous least squares

Best least squares approximation

• We are still approximating a given f(x) on interval [a, b] using

v(x) =n∑

j=0

cjϕj(x),

but we are no longer necessarily interpolating.

• Determine the coefficients cj as those that solve the minimization problem

minc

∥f − v∥2 ≡ minc

∫ b

a

f(x) −n∑

j=0

cjϕj(x)

2

dx.

• Taking first derivative with respect to each ck in turn and equating to 0 gives

∫ b

a

f(x) −n∑

j=0

cjϕj(x)

ϕk(x)dx = 0, k = 0, 1, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 7 / 1

Page 12: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Continuous least squares

Best least squares approximation cont.

• This yields the following construction algorithm:...1 Calculate

B̃j,k =

Z b

a

ϕj(x)ϕk(x)dx, j, k = 0, 1, . . . , n

b̃j =

Z b

a

f(x)ϕj(x)dx j = 0, 1, . . . , n.

...2 Solve linear (n + 1) × (n + 1) system

B̃c = b̃

for the coefficients c = (c0, c1, . . . , cn)T .

• Example: using a monomial basis ϕj(x) = xj for a polynomialapproximation on [0, 1], obtain

B̃j,k =∫ 1

0

xj+kdx = 1/(j + k + 1), 0 ≤ j, k ≤ n.

Also, b̃j =∫ 1

0f(x)xjdx can be approximated by Chapter 15 techniques.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 8 / 1

Page 13: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Continuous least squares

Best least squares approximation cont.

• This yields the following construction algorithm:...1 Calculate

B̃j,k =

Z b

a

ϕj(x)ϕk(x)dx, j, k = 0, 1, . . . , n

b̃j =

Z b

a

f(x)ϕj(x)dx j = 0, 1, . . . , n.

...2 Solve linear (n + 1) × (n + 1) system

B̃c = b̃

for the coefficients c = (c0, c1, . . . , cn)T .

• Example: using a monomial basis ϕj(x) = xj for a polynomialapproximation on [0, 1], obtain

B̃j,k =∫ 1

0

xj+kdx = 1/(j + k + 1), 0 ≤ j, k ≤ n.

Also, b̃j =∫ 1

0f(x)xjdx can be approximated by Chapter 15 techniques.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 8 / 1

Page 14: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Outline

• Best least squares approximation

• Orthogonal basis functions

• Weighted least squares

• Chebyshev polynomials

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 9 / 1

Page 15: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Orthogonal basis functions

• The simple example using monomials leads to stability problems (badconditioning in B̃).

• Using monomial and other simple-minded bases, must evaluate manyintegrals when n is large.

• Idea: construct basis functions such that B̃ is diagonal!This means∫ b

a

ϕj(x)ϕk(x)dx = 0, j ̸= k.

• Take advantage of the fact that here, unlike interpolation, there are no inputabscissae: can construct families of orthogonal basis functions in advance!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 10 / 1

Page 16: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Orthogonal basis functions

• The simple example using monomials leads to stability problems (badconditioning in B̃).

• Using monomial and other simple-minded bases, must evaluate manyintegrals when n is large.

• Idea: construct basis functions such that B̃ is diagonal!This means∫ b

a

ϕj(x)ϕk(x)dx = 0, j ̸= k.

• Take advantage of the fact that here, unlike interpolation, there are no inputabscissae: can construct families of orthogonal basis functions in advance!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 10 / 1

Page 17: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Orthogonal basis functions

• The simple example using monomials leads to stability problems (badconditioning in B̃).

• Using monomial and other simple-minded bases, must evaluate manyintegrals when n is large.

• Idea: construct basis functions such that B̃ is diagonal!This means∫ b

a

ϕj(x)ϕk(x)dx = 0, j ̸= k.

• Take advantage of the fact that here, unlike interpolation, there are no inputabscissae: can construct families of orthogonal basis functions in advance!

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 10 / 1

Page 18: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Best least squares using orthogonal basis functions

• The construction algorithm becomes simply:...1 For j = 0, 1, . . . , n, set dj = B̃j,j =

R b

aϕ2

j (x)dx in advance, and calculate

b̃j =

Z b

a

f(x)ϕj(x)dx.

...2 The sought coefficients are

cj = b̃j/dj , j = 0, 1, . . . , n.

• Next, restrict to polynomial best approximation and ask, how to construct afamily of orthogonal polynomials?

• ASIDE: Two square-integrable functions g ∈ L2 and h ∈ L2 are orthogonalto each other if their inner product vanishes, i.e., they satisfy∫ b

a

g(x)h(x)dx = 0.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 11 / 1

Page 19: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Best least squares using orthogonal basis functions

• The construction algorithm becomes simply:...1 For j = 0, 1, . . . , n, set dj = B̃j,j =

R b

aϕ2

j (x)dx in advance, and calculate

b̃j =

Z b

a

f(x)ϕj(x)dx.

...2 The sought coefficients are

cj = b̃j/dj , j = 0, 1, . . . , n.

• Next, restrict to polynomial best approximation and ask, how to construct afamily of orthogonal polynomials?

• ASIDE: Two square-integrable functions g ∈ L2 and h ∈ L2 are orthogonalto each other if their inner product vanishes, i.e., they satisfy∫ b

a

g(x)h(x)dx = 0.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 11 / 1

Page 20: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Best least squares using orthogonal basis functions

• The construction algorithm becomes simply:...1 For j = 0, 1, . . . , n, set dj = B̃j,j =

R b

aϕ2

j (x)dx in advance, and calculate

b̃j =

Z b

a

f(x)ϕj(x)dx.

...2 The sought coefficients are

cj = b̃j/dj , j = 0, 1, . . . , n.

• Next, restrict to polynomial best approximation and ask, how to construct afamily of orthogonal polynomials?

• ASIDE: Two square-integrable functions g ∈ L2 and h ∈ L2 are orthogonalto each other if their inner product vanishes, i.e., they satisfy∫ b

a

g(x)h(x)dx = 0.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 11 / 1

Page 21: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Legendre polynomials

Defined on the interval [−1, 1] by

ϕ0(x) = 1,

ϕ1(x) = x,

ϕj+1(x) =2j + 1j + 1

xϕj(x) − j

j + 1ϕj−1(x), j ≥ 1.

So,

ϕ2(x) =12(3x2 − 1),

ϕ3(x) =56x(3x2 − 1) − 2

3x =

12(5x3 − 3x).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 12 / 1

Page 22: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Legendre polynomials

Defined on the interval [−1, 1] by

ϕ0(x) = 1,

ϕ1(x) = x,

ϕj+1(x) =2j + 1j + 1

xϕj(x) − j

j + 1ϕj−1(x), j ≥ 1.

So,

ϕ2(x) =12(3x2 − 1),

ϕ3(x) =56x(3x2 − 1) − 2

3x =

12(5x3 − 3x).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 12 / 1

Page 23: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Legendre polynomials: properties

• Orthogonality:∫ 1

−1

ϕj(x)ϕk(x)dx =

{0 j ̸= k

22j+1 j = k.

• Calibration: |ϕj(x)| ≤ 1, −1 ≤ x ≤ 1, and ϕj(1) = 1.

• Oscillation: ϕj(x) has degree j (not less). All its j zeros are simple and lieinside the interval (−1, 1). Hence the polynomial oscillates j times in thisinterval.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 13 / 1

Page 24: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Legendre polynomials: the picture

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

x

φ j

You can determine which curve corresponds to which ϕj by the number ofoscillations.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 14 / 1

Page 25: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Example

• Find polynomial best approximations for f(x) = cos(2πx) over [0, 1] using northogonal polynomials.

• Using Legendre polynomials (note interval change from [−1, 1] to [0, 1]),b̃j =

∫ 1

0cos(2πt)ϕj(2t − 1)dt, and cj = (2j + 1)b̃j .

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1

−0.5

0

0.5

1

1.5

2

x

p n

exactn=0 or 1n=2 or 3n=4

Here f is in green. Obtain the same approximation for n = 2l and n = 2l + 1due to symmetry of f . Note improvement in error as l increases.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 15 / 1

Page 26: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Example

• Find polynomial best approximations for f(x) = cos(2πx) over [0, 1] using northogonal polynomials.

• Using Legendre polynomials (note interval change from [−1, 1] to [0, 1]),b̃j =

∫ 1

0cos(2πt)ϕj(2t − 1)dt, and cj = (2j + 1)b̃j .

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1

−0.5

0

0.5

1

1.5

2

x

p n

exactn=0 or 1n=2 or 3n=4

Here f is in green. Obtain the same approximation for n = 2l and n = 2l + 1due to symmetry of f . Note improvement in error as l increases.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 15 / 1

Page 27: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal polynomials

Example

• Find polynomial best approximations for f(x) = cos(2πx) over [0, 1] using northogonal polynomials.

• Using Legendre polynomials (note interval change from [−1, 1] to [0, 1]),b̃j =

∫ 1

0cos(2πt)ϕj(2t − 1)dt, and cj = (2j + 1)b̃j .

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1

−0.5

0

0.5

1

1.5

2

x

p n

exactn=0 or 1n=2 or 3n=4

Here f is in green. Obtain the same approximation for n = 2l and n = 2l + 1due to symmetry of f . Note improvement in error as l increases.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 15 / 1

Page 28: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal trigonometric polynomials

Trigonometric polynomials

• Not all interesting orthogonal basis functions are polynomials.

• Of particular interest are the periodic basis functions

ϕ0(x) =1√2π

, ϕ2l−1(x) =1√π

sin(lx), ϕ2l(x) =1√π

cos(lx) l = 1, 2, . . . n/2.

• These are orthonormal on [−π, π]:∫ π

−π

ϕi(x)ϕj(x)dx =

{0, i ̸= j

1, i = j.

• Lead to the famous Fourier transform (Chapter 13).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 16 / 1

Page 29: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Orthogonal trigonometric polynomials

Trigonometric polynomials

• Not all interesting orthogonal basis functions are polynomials.

• Of particular interest are the periodic basis functions

ϕ0(x) =1√2π

, ϕ2l−1(x) =1√π

sin(lx), ϕ2l(x) =1√π

cos(lx) l = 1, 2, . . . n/2.

• These are orthonormal on [−π, π]:∫ π

−π

ϕi(x)ϕj(x)dx =

{0, i ̸= j

1, i = j.

• Lead to the famous Fourier transform (Chapter 13).

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 16 / 1

Page 30: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Weighted least squares

Outline

• Best least squares approximation

• Orthogonal basis functions

• Weighted least squares

• Chebyshev polynomials

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 17 / 1

Page 31: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Weighted least squares

Weighted least squares

• An important generalization of best least squares approximation: with aweight function w(x) that is never negative, has bounded L2 norm, and mayequal 0 only at isolated points, seek coefficients cj for v(x) =

∑nj=0 cjϕj(x)

so as to minimize∫ b

a

w(x)(v(x) − f(x))2dx.

• The orthogonality condition correspondingly generalizes to∫ b

a

w(x)ϕj(x)ϕk(x)dx = 0, j ̸= k.

• If this holds then the best approximation solution is given by cj = b̃j/dj ,

where dj =∫ b

aw(x)ϕ2

j (x)dx > 0 and

b̃j =∫ b

a

w(x)f(x)ϕj(x)dx, j = 0, 1, . . . , n.

• Important families of orthogonal polynomials may be obtained for goodchoices of the weight function.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 18 / 1

Page 32: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Weighted least squares

Weighted least squares

• An important generalization of best least squares approximation: with aweight function w(x) that is never negative, has bounded L2 norm, and mayequal 0 only at isolated points, seek coefficients cj for v(x) =

∑nj=0 cjϕj(x)

so as to minimize∫ b

a

w(x)(v(x) − f(x))2dx.

• The orthogonality condition correspondingly generalizes to∫ b

a

w(x)ϕj(x)ϕk(x)dx = 0, j ̸= k.

• If this holds then the best approximation solution is given by cj = b̃j/dj ,

where dj =∫ b

aw(x)ϕ2

j (x)dx > 0 and

b̃j =∫ b

a

w(x)f(x)ϕj(x)dx, j = 0, 1, . . . , n.

• Important families of orthogonal polynomials may be obtained for goodchoices of the weight function.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 18 / 1

Page 33: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Weighted least squares

Gram-Schmidt process for constructing orthogonalpolynomials

• Given an interval [a, b] and a weight function w(x), this algorithm producesan orthogonal polynomial family via a short three-term recurrence!

• Set

ϕ0(x) = 1,

ϕ1(x) = x − β1,

ϕj(x) = (x − βj)ϕj−1(x) − γjϕj−2(x), j ≥ 2,

where

βj =

∫ b

axw(x)[ϕj−1(x)]2dx∫ b

aw(x)[ϕj−1(x)]2dx

, j ≥ 1,

γj =

∫ b

axw(x)ϕj−1(x)ϕj−2(x)dx∫ b

aw(x)[ϕj−2(x)]2dx

j ≥ 2.

• Intimately connected also to the derivation of Krylov subspace iterativemethods for symmetric linear systems (CG, MINRES); see Section 7.5.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 19 / 1

Page 34: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Chebyshev polynomials

Outline

• Best least squares approximation

• Orthogonal basis functions

• Weighted least squares

• Chebyshev polynomials

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 20 / 1

Page 35: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Chebyshev polynomials

Chebyshev polynomials

• This is a family of orthogonal polynomials on [−1, 1] with respect to theweight function

w(x) =1√

1 − x2.

• Define

ϕj(x) = Tj(x) = cos(j arccos x) = cos(jθ),

where x = cos(θ).• So, these polynomials are naturally defined in terms of an angle, θ. Clearly,

the larger j the more oscillatory Tj .

• Easy to verify orthogonality:∫ 1

−1

w(x)Tj(x)Tk(x)dx =∫ 1

−1

Tj(x)Tk(x)√1 − x2

dx

=∫ π

0

cos(jθ) cos(kθ)dθ =

{0 j ̸= kπ2 j = k > 0

.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 21 / 1

Page 36: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Chebyshev polynomials

Chebyshev polynomials: derivation and properties

• These polynomials obey the simple 3-term recursion

T0(x) = 1,

T1(x) = x,

Tj+1(x) = 2xTj(x) − Tj−1(x), j ≥ 1,

and obviously satisfy

|Tj(x)| ≤ 1, ∀x.

• The roots (zeros) of Tn are the Chebyshev points

xk = cos(

2k − 12n

π

), k = 1, . . . , n.

See Section 10.6 for their magic properties.

• The also-important interleaving extremal points (where Tn(x) = ±1) are

ξk = cos(

k

), k = 0, 1, . . . , n.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 22 / 1

Page 37: Chapter 12: Best Approximationascher/ag_2012/ag_slides/chap12.pdf · 2013. 9. 13. · Chapter 12: Best Approximation Uri M. Ascher and Chen Greif Department of Computer Science The

Best Approximation Chebyshev polynomials

Chebyshev polynomials: the picture

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

x

Tj

T4

T6

T5

You can determine which curve corresponds to which ϕj = Tj by the number ofoscillations. Note the perfect calibration.

Uri Ascher & Chen Greif (UBC Computer Science) A First Course in Numerical Methods July 20, 2013 23 / 1