Docsity

AMSC/CMSC 460 Assignment 2: Linear Algebra and Numerical Computing - Prof. Peter Wolfe, Assignments of Computer Science

Toggle sidebar
bg1
AMSC/CMSC 460 Dr. Wolfe ASSIGNMENT #2 Due June 19, 2009
1. Compute (by hand) the Cholesky factorization of
A=
4 6 10
6 25 19
10 19 62
2. Ex.2.11, p.87, Numerical Computing with MATLAB .
3. Consider the linear system
6x1+ 2x2+x3=−3
2x1+2
3x2−4
3x3= 4
x1+ 2x2−3x3= 2
(a) Verify that its solution is
x1= 1.4x2=−4.2x3=−3.0
(b) Using four digit floating-point decimal arithmetic with rounding, solve the system
by Gaussian elimination without pivoting.
(c) Repeat part (b) using partial pivoting. In performing the arithmetic operations,
remember to round to four significant digits after each operation, just as would
be done on a computer. If you are careful you should see a significant difference.
4. The Hilbert matrix of order n,Hnis defined by
(Hn)i,j =1
i+j−1, i = 1, . . . , n, j = 1,...,n.
Hnis nonsingular. However, as nincreases, the condition number of Hnincreases
rapidly. Hnis a library function in MATLAB, hilb(n). Let n= 10,x= ones(10,1)
and b=H10x. Now use the backslash operator to solve the system Hnx=b,
obtaining x∗. Since we know xexactly, we can compute e=x−x∗, the error,
and r=b−H10x∗, the residual. Compute these quantities and also cond(Hn) (a
MATLAB function). Show that the two basic principles of solving linear systems by
G.E./P.P. in floating point arithmetic hold. How many correct digits does x∗have ?
Repeat with n= 11,12,.... Stop when some component of x∗has no correct digits.
5. Define the matrix Anof order nby
ai,j =
−1, i < j
1, i =j
0, i > j
pf2

Partial preview of the text

Download AMSC/CMSC 460 Assignment 2: Linear Algebra and Numerical Computing - Prof. Peter Wolfe and more Assignments Computer Science in PDF only on Docsity!

AMSC/CMSC 460 Dr. Wolfe ASSIGNMENT #2 Due June 19, 2009

  1. Compute (by hand) the Cholesky factorization of

A =

  1. Ex.2.11, p.87, Numerical Computing with MATLAB.
  2. Consider the linear system

6 x 1 + 2x 2 + x 3 = − 3

2 x 1 +

x 2 −

x 3 = 4

x 1 + 2x 2 − 3 x 3 = 2

(a) Verify that its solution is

x 1 = 1. 4 x 2 = − 4. 2 x 3 = − 3. 0

(b) Using four digit floating-point decimal arithmetic with rounding, solve the system by Gaussian elimination without pivoting. (c) Repeat part (b) using partial pivoting. In performing the arithmetic operations, remember to round to four significant digits after each operation, just as would be done on a computer. If you are careful you should see a significant difference.

  1. The Hilbert matrix of order n, Hn is defined by

(Hn)i,j =

i + j − 1

, i = 1,... , n, j = 1,... , n.

Hn is nonsingular. However, as n increases, the condition number of Hn increases rapidly. Hn is a library function in MATLAB, hilb(n). Let n = 10, x = ones(10, 1) and b = H 10 x. Now use the backslash operator to solve the system Hnx = b, obtaining x∗. Since we know x exactly, we can compute e = x − x∗, the error, and r = b − H 10 x∗, the residual. Compute these quantities and also cond(Hn) (a MATLAB function). Show that the two basic principles of solving linear systems by G.E./P.P. in floating point arithmetic hold. How many correct digits does x∗^ have? Repeat with n = 11, 12 ,.. .. Stop when some component of x∗^ has no correct digits.

  1. Define the matrix An of order n by

ai,j =

− 1 , i < j 1 , i = j 0 , i > j

(a) Show how to generate An in MATLAB with eye, ones and triu. (b) Find the inverse of An explicitly. Hint: Find the inverse of A 6 by using MATLAB. Then use the result to “guess” the inverse of An in general. In parts (c) and (d) use the ∞-norm. (c) Show cond(An) = n 2 n−^1. For what n is this greater than 1/eps? (d) With b = [−n + 2, −n + 3,... , − 1 , 0 , 1]T^ , the solution of Anx = b is x = [1, 1 ,... , 1]T^. Perturb b to bˆ = b + [0,... , 0 , ǫ]T^. Solve for ˆx in Anˆx = ˆb. Compare the relative error in ˆx to the relative error in bˆ. What do you conclude? Hint ˆx = x + A− n 1 (ˆb − b).

  1. Suppose x satisfies Ax = b and x + ∆x satisfies (A + ∆A)(x + ∆x) = b + ∆b. Then we have the condition number inequality: If ρ = ‖A−^1 ‖ · ‖∆A‖ < 1 ‖∆x‖ ‖x‖

cond(A) 1 − ρ

‖∆A‖

‖A‖

‖∆b‖ ‖b‖

Consider the linear system Ax = b where

A =

 (^) , b =

(a) Solve Ax = b using the backslash operator. (b) Use equation (1) to answer the following question: If each entry in A and b might have an error of ±.00005, how reliable is x? Use the ∞-norm. (c) Let ∆A =. 0001 ∗rand(3)−. 00005 ∗ones(3), ∆b =. 0001 ∗rand(3, 1)−. 00005 ∗ones(3, 1). Solve (A + ∆A)(x + ∆x) = b + ∆b to get x + ∆x. Calculate ‖∆x‖/‖x‖. Is this consistent with (b)? What is the relative change in each xi?

(a) Let A be an n × n matrix and x ∈ Rn. How many flops does it take to form the product Ax? (b) Let A and B be n × n matrices. How many flops does it take to form the product AB? (c) In light of the results of (a) and (b), from the standpoint of efficiency, how should one compute Akx for k a positive integer k > 1?

  1. The solution of the boundary value problem

−

d^2 u dx^2

x^2

u = −

x^3

, u(1) = 1, u(2) =

is u(x) = 1/x. We wish to construct finite difference approximations to u(x) as we did in class. (a) Use Moler’s fast diagonal solver tridisolve to find solutions to the system of finite difference equations for n = 9, 19 , 39. (b) Evaluate the accuracy of your solutions by taking the norm of the difference of the solution vector and the vector of exact solutions values at the nodes.