CS4MN3 Final 2006
Page
1
Name Student Number Instructor: S. Qiao COMP COMP SCI 4MN3
Day Class Duration of examination: two hours McMaster University Final Examination
April 2006
This examination paper includes 5 pages and 7 questions. You are responsible for ensuring that that your your copy copy of the paper is com comple plete. te. Bring Bring any any discre discrepan pancy cy to the attent attention ion of your your invigilator. SPECIA SPECIAL L INSTR INSTRUCT UCTION IONS: S: This paper paper must must be return returned ed with your your answe answers. rs. Use of McMaster standard (Casio-FX991) calculator only is allowed. 1. (2 marks) What is the 2-norm condition number of the following matrix with respect to solving linear equations? 4 0 0 0 −6 0 0 0 2
cond2 (A) = 6/2 = 3.
2. (3 marks) marks) Give Given n an n-by-n -by-n nonsingular matrix A and a second n-by-n -by-n matrix B , what is an 1 efficient way to compute A B ? −
Let B = [b1 b2 · · · bn ]. PA = L*U; for i=1...n solv solve e L*y L*y = P*bi; P*bi; solv solve e U*ci U*ci = y; end
% LU decomposition % for each column bi of B % solv solve e tria triang ngul ular ar sys syste tems ms
1B.
−
Then C = [c1 c2 · · · cn ] = A
next page ...
CS4MN3 Final 2006
Page
2
3. (4 marks) If A is an ill-conditioned matrix, and its LU decomposition is computed by Gaussian elimination with partial pivoting, how is the ill-conditioning of A reflected in L and U ? Why? (Hint: Estimate an upper bound for the condition number of L.) Since partial pivoting, the multipliers, the entries in L, |mij | ≤ 1. Thus, 1
−
L1 ≤ n and L
1 ≤ n.
Consequently, cond1 (L) ≤ n2 . The ill-conditioning of A is mostly reflected in U .
4. (3 marks) How would you solve a partitioned linear system of the form:
L1 0 B L2
x y
=
b c
,
where L1 and L2 are nonsingular lower triangular matrices, and the solution and right-hand-side vectors are partitioned accordingly? Show the specific steps you would perform in terms of the given submatrices and vectors. solve L1*x = b; solve L2*y = c - B*x
next page ...
CS4MN3 Final 2006
Page
3
5. (5 marks) Carry out one iteration of Newton’s method applied to the system of nonlinear equations x21 − x22 = 0 2x1 x2 = 1,
with starting point x0 = [0 1]T . The Jacobian is J (x) and J (x0 ) =
0 −2 2 0
Thus x1 = x0 − J 1 (x0 ) f (x0 ) = −
2x1 −2x2 2x2 2x1
J 1 (x0 ) = −
0 1
−
0 1/2 −1/2 0
0 1/2 −1/2 0
−1 −1
=
1/2 1/2
next page ...
CS4MN3 Final 2006
Page
4
6. (8 marks) Consider the initial value problem for the ODE y = −y 2 with the initial condition y(0) = 1. Use the backward Euler method with step size h = 0.1 starting from y0 = y(0) = 1 at t0 = 0 to compute the approximate value y1 of the solution at time t1 = 0.1. Since the backward Euler method is implicit, and the ODE is nonlinear, you need to solve a nonlinear algebraic equation for y1 . ′
(a) Write that nonlinear algebraic equation for y1 . (b) Write the Newton iteration for solving the nonlinear algebraic equation. (c) Obtain a starting guess for the Newton iteration by using one step of Euler method for the ODE. (Predictor) (d) Compute y1 by applying one iteration of Newton’s method for the nonlinear algebraic equation. (Corrector) Answer: The exact solution is y = 1/(t + 1) and y(0.1) = 0.909. (a) Backward Euler method y1 = y0 + hf 1 = 1 + 0.1(−y12 ). The nonlinear algebraic equation for y1 : 0.1y12 + y1 − 1 = 0. (b) Newton iteration y+ = yc −
f c f c ′
where f (y) = 0.1y2 + y − 1.
(c) One step of Euler method (0)
y1 = y0 + hf 0 = 1 + 0.1(−12 ) = 0.9. (d) One iteration of Newton’s method y1 =
(0) y1
(0) (0)
−
(0)
0.1y1 y1 + y1 − 1 (0)
0.2y1 + 1
= 0.9 −
0.081 + 0.9 − 1 = 0.9161. 0.18 + 1
next page ...
CS4MN3 Final 2006
Page
5
7. (8 marks) Given four points (xi , yi ), i = 1, 2, 3, 4, Find the linear least squares approximation of the data set. Specifically, formulate the problem as Ax ≈ b. (a) What is the coefficient matrix A? What is the right side vector b? (b) How would you solve this problem using the QR decomposition of A? (c) Suppose that you find A is ill-conditioned, how would you solve this problem using the SVD of A? (a) A=
(b)
x1 x2 x3 x4
1 1 1 1
A = Q
,
b=
A = U ΣV T
.
R 0
Rx = b1 , (c)
y1 y2 y3 y4
b1 b2
b = QT b =
solve for x
and b = U T b.
Set small σi to zero. Suppose σk > σk+1 = · · · = σn = 0, then
zi = bi /σi , and the solution x = V z.
for i = 1, ..., k ,
END!
zk+1 = · · · zn = 0,