Docsity

Homework 1 with Solutions - Numerical Computing - Assignments | MATH 4800, Assignments of Mathematics

Toggle sidebar
bg1
Rensselaer Polytechnic Institute
Homework # 1
MATH 48000 Numerical Computing
Luigi Vanfretti
January 29, 2007
1. Review question 2.57: What is the conditioning number of the following matrix using the
1-norm?
A=
400
0−6 0
002
Solution: The inverse of Ais given by:
A=
1
40 0
0−1
60
0 0 1
2
The norm of Aand A−1:
||A|| = 6 ¯¯¯¯A−1¯¯¯¯=1
2
And the condition number is given by:
cond (A) = ||A|| · ¯¯¯¯¯¯A−1¯¯¯¯¯¯= 6 ×1
2= 3
2. Classify the following matrices as well-conditioned or ill-conditioned.
Solution:
(a) Aa="1010 0
0 10−10 #, the inverse is given by A−1
a="10−10 0
0 1010 #.
The norms of Aaand A−1
aare:
||Aa|| = 1010 ¯¯¯¯A−1
a¯¯¯¯= 1010
And the condition number is given by:
cond (Aa) = ||Aa|| · ¯¯¯¯¯¯A−1
a¯¯¯¯¯¯= 1020
Because cond (Aa)>> 1the matrix is close to singularity, and therefore, Aais
ill-conditioned.
1
pf3
pf4
pf5

Partial preview of the text

Download Homework 1 with Solutions - Numerical Computing - Assignments | MATH 4800 and more Assignments Mathematics in PDF only on Docsity!

Rensselaer Polytechnic Institute

Homework # 1

MATH 48000 Numerical Computing

Luigi Vanfretti

January 29, 2007

  1. Review question 2.57: What is the conditioning number of the following matrix using the 1-norm?

A =

 

 

Solution: The inverse of A is given by:

A =

 

1 4 0 0 0 − 16 0 (^0 0 )

 

The norm of A and A−^1 : ||A|| = 6

∣∣∣∣ A−^1

∣∣∣∣ = (^12) And the condition number is given by:

cond (A) = ||A|| ·

∣∣ ∣

∣∣ ∣A−^1

∣∣ ∣

∣∣ ∣ = 6 ×

  1. Classify the following matrices as well-conditioned or ill-conditioned. Solution:

(a) Aa =

[ 1010 0 0 10 −^10

] , the inverse is given by A−a 1 =

[ 10 −^10 0 1010

] .

The norms of Aa and A−a 1 are: ||Aa|| = 10^10

∣∣∣∣ A−a^1

∣∣∣∣ = 10^10 And the condition number is given by:

cond (Aa) = ||Aa|| ·

∣∣ ∣

∣∣ ∣A−a^1

∣∣ ∣

∣∣ ∣ = 10^20

Because cond (Aa) >> 1 the matrix is close to singularity, and therefore, Aa is ill-conditioned.

(b) Ab =

[ 1010 0 0 1010

] , the inverse is given by A−b 1 =

[ 10 −^10 0 10 −^10

] .

The norms of Ab and A−b 1 are:

||Ab|| = 10^10

∣∣ ∣

∣∣ ∣A−b^1

∣∣ ∣

∣∣ ∣ = 10−^10 And the condition number is given by: cond (Ab) = ||Ab|| ·

∣∣ ∣

∣∣ ∣A−b^1

∣∣ ∣

∣∣ ∣ = 1

Because cond (Ab) = 1 the matrix is far from singularity, and therefore, Ab is well- conditioned. (c) Ac =

[ 10 −^10 0 10 −^10

] , the inverse is given by A−c 1 =

[ 1010 0 0 1010

] .

The norms of Ac and A−c 1 are: ||Ac|| = 10−^10

∣∣ ∣

∣∣ ∣A−b^1

∣∣ ∣

∣∣ ∣ = 10^10 And the condition number is given by: cond (Ac) = ||Ac|| ·

∣∣ ∣

∣∣ ∣A−c^1

∣∣ ∣

∣∣ ∣ = 1

Because cond (Ac) = 1 the matrix is far from singularity, and therefore, Ac is well- conditioned. (d) Ad =

[ 1 2 2 4

] , because |Ad| = 0 → A−d 1 does not exist, the condition number is inf and therefore the matrix is ill-conditioned.

  1. MATLAB problem: Solution:

Part 1: mat files listing

The following m-file constructs a Hilbert matrix, computes B = A^2 and computes the condition number for matrices A and B using the infinity norm:

0001 %% MATH 4800 - HOMEWORK 1 0002 % This m-file performs the required steps in problem 3, is latter 0003 % changed into a function for multiple evaluation. 0004 % ------------------------------------------------------------------- 0005 n = input(’Enter the dimension "n" of the Hilbert matrix: ’) 0006 % Construct the Hilbert Matrix A 0007 A = []; 0008 for i = 1:n 0009 for j = 1:n 0010 A(i,j) = 1/(i+j-1); 0011 end 0012 end 0013 % Obtain Aˆ 0014 B = Aˆ 0015 % Obtain the condition numbers using the norm function 0016 Co_A = norm(A,inf)norm(inv(A),inf) 0017 Co_B = norm(B,inf)norm(inv(B),inf)

0028 dppA = [dppA dpA]; dppB = [dppB dpB]; 0029 end 0030 %% Display Results 0031 %% Linear Plot 0032 figure(2); set(gcf,’color’,’white’); 0033 plot(nn,Co_A,’b-’,nn,Co_B,’r--’,’LineWidth’,1.5) 0034 legend(’cond(A)’,’cond(B)’,’Location’,’NorthWest’) 0035 xlabel(’n (Matrix Dimension)’); ylabel(’Conditioning Number’) 0036 title(’Conditioning vs Matrix Dimension - n = [0 15]’); grid 0037 %% Semilogarithmic Plot 0038 figure(3); set(gcf,’color’,’white’); 0039 semilogy(nn,Co_A,’b-’,nn,Co_B,’r--’,’LineWidth’,1.5) 0040 legend(’cond(A)’,’cond(B)’,’Location’,’NorthWest’) 0041 xlabel(’n (Matrix Dimension)’); ylabel(’Conditioning Number’) 0042 title({’Conditioning vs Matrix Dimension - n = [0 15]’,... 0043 ’Semilogarithmic Plot’}); grid 0044 %% Table 0045 disp(’ N cond(A) detdet_A cond(B) detdet_B’) 0046 disp(’-----------------------------------------------------------------’) 0047 disp([nn’,Co_A’,dppA’,Co_B’,dppB’])

Part 2: Results for n = 2 and n = 2 × { letters of my full name } = 2 × 13 = 26

  • Results for n = 2

A matix: 1 0. 0.5 0. B matix: 1.25 0. 0.66667 0. Condition number of the A matix: Condition number of the B matix: det(A)det(A^(-1))= 1 det(B)det(B^(-1))= 1

The results show that the condition number of A is 27 and of B is 529. We observe that cond (A) < cond (B) and that cond (A) is relatively closer to 1 than cond (B). This indicates that cond (A) is farthest from singularity and cond (B) is closest. Therefore A is better conditioned than B. Additionally, the results show that |A| ·

∣∣ A−^1

∣∣ and |B| ·

∣∣ B−^1

∣∣ are equal to 1, this implies that the inverse of the matrices has been calculated exactly. Thus, the condition numbers which depend on the inverse of the matrices are exact.

  • Results for n = 2 × { letters of my full name } = 2 × 13 = 26

Condition number of the A matix: 8318594937975337000 Condition number of the B matix: 12042112043699638000

The results show that the condition number of A and B are very large numbers. This implies that both A and B are ill-conditioned.

Part 3: Results for n = [1 − 20]. Questions: What do you observe, and can you explain the trend? Does your program fail for a range of n? What is that range?

Figure 1: cond(A) and cond(B) vs n for n = [1 − 20]

(^00 5 10 15 )

1

2

3

4

5

6

7

8 x 10

19

n (Matrix Dimension)

Conditioning Number

Conditioning vs Matrix Dimension − n = [0 15] cond(A) cond(B)

Figure 2: Semilogarithmic plot of cond(A) and cond(B) vs n for n = [1 − 20]

(^100 5 10 15 ) 0

105

1010

1015

1020

n (Matrix Dimension)

Conditioning Number

Conditioning vs Matrix Dimension − n = [0 15] Semilogarithmic Plot cond(A) cond(B)

  • Does your program fail for a range of n? What is that range? Yes, the algorithm fails in the following range:

n ≥ 6 for cond (B) n ≥ 11 for cond (A)

  1. What is the relationship of the condition number of a matrix A to the condition number of A^2? Solution: The condition number of A is given by:

cond (A) = ||A|| ·

∣∣ ∣

∣∣ ∣A−^1

∣∣ ∣

∣∣ ∣

The condition number of A^2 is:

cond

( A^2

)

∣∣ ∣

∣∣ ∣A^2

∣∣ ∣

∣∣ ∣ ·

∣∣ ∣

∣∣ ∣A−^2

∣∣ ∣

∣∣ ∣

The following property of matrix norms is recalled:

||M · N|| ≤ ||M|| · ||N||

By using the property above, it follows that:

cond

( A^2

) ≤ ||A||^2 ·

∣∣ ∣

∣∣ ∣A−^1

∣∣ ∣

∣∣ ∣

2

And therefore, the relationship between cond (A) and cond

( A^2

) can be expressed as:

cond

( A^2

) ≤ (cond (A))^2