Docsity

Least Squares Approximation and QR Decomposition, Exams of Mathematics

Toggle sidebar
bg1
Final Review Problems
Igor Yanovsky (Math 151B TA)
These sample review problems do not necessarily represent the content, length, or depth
of the material you will be tested on.
Among other things, it is also a good idea to go over the homework sets.
1 Fourier Series
Problem: Find the general continuous least squares trigonometric polynomial Sn(x) for
f(x) = (0,if −π < x ≤0,
1,if 0 < x < π.
Solution: The continuous least squares approximation Sn(x) is in the form
Sn(x) = a0
2+
n
X
k=1
(akcos kx +bksin kx),
where, for k= 1,2, . . .,
a0=1
πZπ
−π
f(x)dx,
=1
πZ0
−π
0dx +1
πZπ
0
1dx = 1,X
ak=1
πZπ
−π
f(x) cos kx dx,
=1
πZ0
−π
0·cos kx dx +1
πZπ
0
1·cos kx dx,
=1
π
sin kx
k¯¯¯
x=π
x=0 = 0,X
bk=1
πZπ
−π
f(x) sin kx dx
=1
πZ0
−π
0·sin kx dx +1
πZπ
0
1·sin kx dx,
=−1
π
cos kx
k¯¯¯
x=π
x=0 =−1
πµ(−1)k−1
k=1
πµ1−(−1)k
k.X
Thus,
Sn(x) = 1
2+1
π
n
X
k=1 µ1−(−1)k
ksin kx. X
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Least Squares Approximation and QR Decomposition and more Exams Mathematics in PDF only on Docsity!

Final Review Problems

Igor Yanovsky (Math 151B TA)

These sample review problems do not necessarily represent the content, length, or depth

of the material you will be tested on.

Among other things, it is also a good idea to go over the homework sets.

1 Fourier Series

Problem: Find the general continuous least squares trigonometric polynomial Sn(x) for

f (x) =

0 , if − π < x ≤ 0 ,

1 , if 0 < x < π.

Solution: The continuous least squares approximation Sn(x) is in the form

Sn(x) =

a 0

∑^ n

k=

(ak cos kx + bk sin kx),

where, for k = 1, 2 ,.. .,

a 0 =

π

π

−π

f (x) dx,

π

−π

0 dx +

π

∫ (^) π

0

1 dx = 1, X

ak =

π

∫ (^) π

−π

f (x) cos kx dx,

π

0

−π

0 · cos kx dx +

π

π

0

1 · cos kx dx,

π

sin kx

k

x=π

x=

= 0, X

bk =

π

∫ (^) π

−π

f (x) sin kx dx

π

−π

0 · sin kx dx +

π

∫ (^) π

0

1 · sin kx dx,

π

cos kx

k

x=π

x=

π

k − 1

k

π

k

k

. X

Thus,

Sn(x) =

π

∑^ n

k=

k

k

sin kx. X

2 QR decomposition and Least Squares

The QR decomposition (also called the QR factorization) of a matrix is a decomposition

of the matrix into an orthogonal matrix and a triangular matrix. A QR decomposition of

a real square matrix A is a decomposition of A as

A = QR,

where Q is an orthogonal matrix (i.e. Q

T Q = I) and R is an upper triangular matrix. If

A is nonsingular, then this factorization is unique.

There are several methods for actually computing the QR decomposition. One of such

method is the Gram-Schmidt process.

2.1 Gram-Schmidt process

Consider the GramSchmidt procedure, with the vectors to be considered in the process as

columns of the 3x3 matrix A. That is,

A =

[

a 1

∣ (^) a 2

∣ (^) a n

]

Then,

q ˜ 1 = a 1 , q 1 =

˜q 1

||˜q 1 || 2

q ˜ 2 = a 2 − (q

T 1 a^2 )q^1 ,^ q^2 =^

q˜ 2

||˜q 2 || 2

q ˜ 3 = a 3 − (q

T 1 a^3 )q^1 −^ (q

T 2 a^3 )q^2 ,^ q^3 =^

˜q 3

||˜q 3 || 2

2.2 QR Factorization

The resulting QR factorization is

A =

[

a 1

∣ (^) a 2

∣ (^) a 3

]

[

q 1

∣ (^) q 2

∣ (^) q 3

]

||˜q 1 || 2 q

T 1 a^2 q

T 1 a^3

0 ||˜q 2 || 2 q

T 2 a^3

0 0 ||˜q 3 || 2

 = QR.

2.3 Example

Consider the matrix

A =

with the vectors a 1 = (1, 1 , 0)

T , a 2 = (1, 0 , 1)

T , a 3 = (0, 1 , 1)

T .

Note that all the vectors considered above and below are column vectors. From now on,

I will drop

T notation for simplicity, but we have to remember that all the vectors are

column vectors.

3 Vector and Matrix Norms

The L∞ and L 2 norms for the vector x = (x 1 , x 2 ,... , xn)

T are defined by

||x||∞ = max 1 ≤i≤n

|xi|,

||x|| 2 =

{ (^) n ∑

i=

x

2 i

2 .

For matrices, the definitions of || · ||∞, || · ||F , and || · || 2 norms are:

||A||∞ = max 1 ≤i≤n

∑n

j=

|aij |,

||A||F =

( (^) n ∑

i=

∑^ n

j=

|aij |

2

2 ,

||A|| 2 = max ||x|| 2 =

||Ax|| 2.

Note, that Ax is a vector:

Ax =

n

∑j=1^ a^1 j^ xj n j=1 a^2 j^ xj . . . ∑n

j=1 anj^ xj

Thus, we have

||Ax|| 2 =

( (^) n ∑

i=

( (^) ∑n

j=

aij xj

) 2 )^12

4 Iterative methods for the solution of linear systems of

equations.

4.1 Jacobi Method

A general n × n linear system can be written as Ax = b, where

A =

a 11 a 12 · · · a 1 n

a 21 a 22 · · · a 2 n

. . .

an 1 an 2 · · · ann

Jacobi method is written in the form x

(k) = T x

(k− 1 )

  • c by splitting A. Let D be the

diagonal matrix whose diagonal entries are those of A, −L be the strictly lower-triangular

part of A, and −U be the strictly upper-triangular part of A. Hence,

A =

a 11 0 · · · 0

0 a 22

0 · · · 0 ann

−a 21

−an 1 · · · −an,n− 1 0

0 −a 12 · · · −a 1 n

. . .

. (^) −an− 1 ,n

0 · · · · · · 0

= D − L − U.

The equation Ax = b, or

(D − L − U )x = b, (1)

is then transformed into

Dx = (L + U )x + b,

and, if D

− 1 exists,

x = D

− 1 (L + U )x + D

− 1 b.

This results in the matrix form of the Jacobi iterative technique:

x

(k) = D

− 1 (L + U )x

(k−1)

  • D

− 1 b.

Introducing Tj = D

− 1 (L + U ) and cj = D

− 1 b (here, “j” stands for “Jacobi”), the Jacobi

method has the form

x

(k) = Tj x

(k−1)

  • cj.

4.2 Gauss-Seidel Method

Equation (1) can be written as

(D − L)x = U x + b,

which gives the Gauss-Seidel method:

(D − L)x

(k) = U x

(k−1)

  • b

or

x

(k) = (D − L)

− 1 U x

(k−1)

  • (D − L)

− 1 b.

Introducing Tg = (D − L)

− 1 U and cg = (D − L)

− 1 b (here, “g” stands for “Gauss-Seidel”),

the Gauss-Seidel method has the form

x

(k) = Tgx

(k−1)

  • cg.

Please see relevant homework problems for examples.

5 Consistency, Stability and Convergence of Numerical Meth-

ods

A one-step difference equation method with local truncation error τi(h) at the ith step is

said to be consistent if

lim h→ 0

max 1 ≤i≤N

|τi(h)| = 0. (3)

A one-step difference equation method is said to be convergent if

lim h→ 0

max 1 ≤i≤N

|wi − y(ti)| = 0, (4)

where yi is the exact solution and wi is the approximation obtained from the difference

method. Recall that for Euler’s method, we have

max 1 ≤i≤N

|wi − y(ti)| ≤

M h

2 L

|e

L(b−a) − 1 |, (5)

and, therefore, Euler’s method is convergent with the linear (first order) rate of conver-

gence of O(h).

A method is stable if its results depend continuously on the initial data.

5.1 Stability of Multistep Methods

Problem: To approximate the initial value problem

y

′ = f (t, y) (6)

for t > 0, consider a multistep method

wi+1 = 2wi− 1 − wi + h

[

f (ti, wi) +

f (ti− 1 , wi− 1 )

]

Is this method stable?

Solution: For a multistep method to be stable, it has to satisfy the root condition. A

multistep method is said to satisfy the root condition if all roots λi of the characteristic

polynomial P (λ) (for a general form of P (λ) see equation (5.57) in the book) are such

that |λi| ≤ 1, and if |λi| = 1, then λi is simple.

The characteristic polynomial of the following multistep method

wi+1 + wi − 2 wi− 1 = h

[

f (ti, wi) +

f (ti− 1 , wi− 1 )

]

is

P (λ) = −2 + λ + λ

2 ,

which has roots

λ 1 = 1, λ 2 = − 2.

Thus this multistep method does not satisfy the root condition, and therefore is unstable.

X

Note that a quick way of writing a characteristic polynomial is to associate the coefficient

a 0 to the leftmost grid point in the method’s stencil. In the example above, the leftmost

grid point has an index i − 1, and therefore, a 0 = −2, a 1 = 1, a 2 = 1.

5.3 Regions of Absolute Stability

Problem: Show that the Backward Euler (or Implicit Euler) method

wi+1 = wi + hf (ti+1, wi+1)

is A-stable.

Solution: The region R of absolute stability is R = {hλ ∈ C | |Q(hλ)| < 1 }, where

wi+1 = Q(hλ)wi. A numerical method is said to be A-stable if its region of stability R

contains the entire left half-plane.

In other words, in order to show that the method is A-stable, we need to show that

when it is applied to the scalar test equation y

′ = λy = f , whose solutions tend to zero

for λ < 0, all the solutions of the method also tend to zero for a fixed h > 0 as i → ∞.

For the Backward Euler method, we have

wi+1 = wi + hλwi+1,

wi+1 − hλwi+1 = wi,

wi+1(1 − hλ) = wi,

wi+1 =

1 − hλ

wi,

wi+1 =

1 − hλ

)n+

w 0.

Thus,

Q(hλ) =

1 − hλ

Note that for Re(hλ) < 0, |Q(hλ)| < 1. Therefore, the region of absolute stability R for

the Backward Euler method contains the entire left half-plane, and hence, the method is

A-stable.

Note that the region of absolute stability contains the interval (2, +∞).

6 Boundary Value Problems

Given the second-order boundary-value problem

y

′′ (x) = p(x)y

′ (x) + q(x)y(x) + r(x),

a ≤ x ≤ b,

y(a) = α, y(b) = β,

the differential equation to be approximated at the interior points xi is

y

′′ (xi) = p(xi)y

′ (xi) + q(xi)y(xi) + r(xi). (8)

It might be helpful to know how to derive the following approximations to the first and

second derivatives of y(xi) (pages 656-657 in the book). Expanding y(xi+1) and y(xi− 1 ) in

Taylor polynomials about xi, and doing some arithmetic manipulations (as in the book),

we obtain the following formulas:

y

′′ (xi) =

h^2

[

y(xi+1) − 2 y(xi) + y(xi− 1 )

]

h

2

y

′′′′ (ξi),

y

′ (xi) =

2 h

[

y(xi+1) − y(xi− 1 )

]

h^2

y

′′′ (ηi).

The approximation to (8) is therefore:

( −wi+1 + 2wi − wi− 1

h^2

  • p(xi)

wi+1 − wi− 1

2 h

  • q(xi)wi = −r(xi). (9)

Problem: Write the discretization of the following boundary value problem

y

′′ = −

x

y

′

x^2

y −

x^2

log x,

1 ≤ x ≤ 2 ,

y(1) = −

, y(2) = log 2,

in matrix-vector notation Aw = b.

Solution: At the interior points xi, for i = 1, 2 ,... , N , the differential equation to be

approximated is

y

′′ (xi) = −

xi

y

′ (xi) +

x

2 i

y(xi) −

x

2 i

log xi. (10)

Since

y

′′ (xi) =

y(xi+1) − 2 y(xi) + y(xi− 1 )

h^2

h

2

y

(4) (ξi),

y

′ (xi) =

y(xi+1) − y(xi− 1 )

2 h

h

2

y

′′′ (ηi),

we can write the numerical approximation to (10) as

wi+1 − 2 wi + wi− 1

h^2

xi

wi+1 − wi− 1

2 h

x

2 i

wi = −

x

2 i

log xi. (11)

Multiplying both sides of (11) by −h

2 gives

−(wi+1 − 2 wi + wi− 1 ) −

2 h

xi

(wi+1 − wi− 1 ) +

2 h

2

x

2 i

wi =

2 h

2

x

2 i

log xi.