You are on page 1of 4

MATH 2346C - Computational Linear Algebra Tutorial

Tutorial
1. Consider the linear system
Ax = b, (1)

where
   
4.81 −5.92 1.11 0.0
A =  0.007 61.2 0.093  and b =  61.3  .
   

81.4 1.12 1.18 83.7

Use Gaussian elimination with partial pivoting to solve (1), rounding to three
significant digits after each intermediate calculation.

2. Consider the linear system


Ax = b, (2)

where
   
9.18 −6.27 1.22 16.67
A =  71.4 2.02 0.18  and b= 69.56  .
   

0.009 71.8 0.042 −71.749

Use Gaussian elimination with partial pivoting to solve (2), rounding to three
significant digits after each intermediate calculation.

3. Trace the MATLAB function given below and state what it actually does? Use
 
−1 −2 1
A =  −2 −1 2  .
 

−3 6 7

function [P, Q] = progtest(A)


n = size(A,1);
P = eye(n); Q = zeros(n,n);
for i = 1 : n
Q(i,i) = A(i,i)-P(i,1:i-1)*Q(1:i-1,i);
for j = i+1 : n

Page 1 of 4
MATH 2346C - Computational Linear Algebra Tutorial

Q(i,j) = A(i,j)-P(i,1:i-1)*Q(1:i-1,j);
P(j,i) = (A(j,i)-P(j,1:i-1)*Q(1:i-1,i))/Q(i,i);
end
end

4. Consider the following MATLAB function:

function A=genmat(a)
n=length(a);
for i=1:n
for j=1:n
A(i,j)=a(rem(n-i+j,n)+1);
% rem is a built-in MATLAB function.
% rem(X,Y) returns the remainder after division
% of X by Y.
end
end
 
(a) Apply the function to the vector x = 4 2 6 8 .
(b) What is the nature of the output generated by the function?

5. Consider the following algorithm applied to A ∈ Rn×n :

ℓ=1
while (A(ℓ, ℓ) 6= 0) & (ℓ ≤ n − 1)
δ(ℓ + 1 : n) = A(ℓ + 1 : n, ℓ)/A(ℓ, ℓ)
A(ℓ + 1 : n, :) = A(ℓ + 1 : n, :) − δ(ℓ + 1 : n)A(ℓ, :)
ℓ=ℓ+1
end

Page 2 of 4
MATH 2346C - Computational Linear Algebra Tutorial

(i) Apply the algorithm to the matrix


 
6 5 4 0
 12 15 10 1 
.
 

 6 20 13 10 
24 30 35 39

(ii) What does the algorithm compute?

6. (i) Prove that for x ∈ Rn ,



kxk∞ ≤ kxk2 ≤ nkxk∞ .

(ii) Hence, prove that for A ∈ Rn×n ,

1 √
√ kAk∞ ≤ kAk2 ≤ nkAk∞ .
n

7. Determine the Cholesky factor of the matrix


 
4 −2 14 −6
 −2 10 5 −3 
.
 

 14 5 66 −30 
−6 −3 −30 39

8. Let X, Y ∈ Rn×2 .

(a) Give an efficient algorithm to compute XY T XY T .


(b) Compute the number of multiplications needed by the algorithm.

9. Use the column-oriented version of the forward substitution algorithm to solve


    
4 0 0 0 x1 4
 3 1 0 0  x2   2 
= .
    
 
 2 5 3 0  x3   3 
1 2 1 2 x4 3

Page 3 of 4
MATH 2346C - Computational Linear Algebra Tutorial

10. (a) Find the ∞-norm and 2-norm of x = [−2, 5 − 12i, 0, 5i]T .
(b) Find the 1−norm of the Hilbert matrix of order 4.

11. The linear system


Ax = f, (3)

where  
b1 c1
a2 b2 c2
 


A= . .. . .. . ..

,
 
an−1 bn−1 cn−1 
 

an bn
and x, f ∈ Rn , can be solved by decomposing the coefficient matrix A in the
form
A = LU,

where
   
q1 1 r1
p2 q2  2 r2
   
 

L= .. ..  
and U =  .. .. 
.
 . . 
  . . 
pn−1 qn−1 n − 1 rn−1 
   
  
pn qn n

After A has been factored, we can solve for x by using a two-step process. First
we let z = Ux and solve the system Lz = f for z. Once z is known, we solve
Ux = z for x.

Write a MATLAB/Octave function called mylu to solve (3) using the decomposi-
tion method described above. The user must input the three non-zero diagonals
of A and the the right-hand-side vector f. The output of mylu is the solution
vector x.

Page 4 of 4

You might also like