Exercises 4.3 - 4.4

3 minute read

Chapter 4. Determinants

4.3 Cramer’s Rule; Formula for \(A^{-1}\); Applications

No MATLAB problems in this section.

4.4 A First Look at Eigenvalues and Eigenvectors

Exercise 4.8. (Eigenvalues and Eigenvectors)

Use the MATLAB command eig to find the eigenvalues and the associated of the matrix \(A\), where

\[A = \begin{bmatrix} 2 & -3 & 1 & 0\\ 1 & 1 & 2 & 2\\ 3 & 0 & -1 & 4 \\ 1 & 6 & 5 & 6 \end{bmatrix}\]

Display the results with long digits.


Solution.

% Construct the matrix A.
A=[2 -3 1 0; 1 1 2 2; 3 0 -1 4; 1 6 5 6];

% Find the eigenvalues and eigenvectors of A by using eig.
% This command gives AQ = QD.
[Q, D] = eig(A); 
lambda1 = D(1,1); lambda2 = D(2,2); 
lambda3 = D(3,3); lambda4 = D(4,4); 

% Extract each column vector as an eigenvector of A.
x1 = Q(:,1); x2 = Q(:,2); x3 = Q(:,3); x4 = Q(:,4);

% Display the result with long digits.
format long; 
disp('lambda1 is'); disp(lambda1);
disp('The eigenvector corresponding to lambda1 is'); disp(x1');
disp('lambda2 is'); disp(lambda2);
disp('The eigenvector corresponding to lambda2 is'); disp(x2');
disp('lambda3 is'); disp(lambda3);
disp('The eigenvector corresponding to lambda3 is'); disp(x3');
disp('lambda4 is'); disp(lambda4);
disp('The eigenvector corresponding to lambda4 is'); disp(x4');

MATLAB results.

lambda1 is
   9.561855032395815

The eigenvector corresponding to lambda1 is
  -0.067716707308096   0.278176502030498   0.322465582156500   0.902246213399589

lambda2 is
  -3.364648937746372

The eigenvector corresponding to lambda2 is
   0.275562522991092   0.197508356444458  -0.885771126913498   0.316962546342283

lambda3 is
   1.802793905350561

The eigenvector corresponding to lambda3 is
   0.833621905475750   0.103812731179200   0.147042873144504  -0.522183711938149

lambda4 is
     3.246988806430532e-16

The eigenvector corresponding to lambda4 is
  -0.705886578756790  -0.456750139195570   0.041522739926870   0.539795619049310

Remark. In fact, if we compute \(\lambda_{4}\) by hand, we can obtain that \(\lambda_{4}=0\). However, from the result, we see that the resulting value of \(\lambda_{4}\) seems to be nonzero even though it is small enough. This is due to roundoff errors in arithmetic operations. Please refer to the help command of eps, then you can see that \(eps = 2.220446049250313e-016\) is floating-point relative accuracy, which means that eps value is the allowable tolerance when we do numerical computations with rounding floating-point number off. (\(i.e.\), \(eps\) is an upper bound on the relative error due to rounding in floating point arithmetic.) Therefore, we can regard the resulting value of \(\lambda_{4}\) as zero.

Exercise 4.9. (Eigenvalues and Eigenvectors)

Define an \(n\)th-order checkboard matrix \(C_{n}\) to be a matrix that has a 1 in the upper left corner and alternates between 1 and 0 along rows and columns (see the figure below). Find the eigenvalues of \(C_{1}, C_{2}, \cdots\) to make a conjecture about the eigenvalues of \(C_{n}\). What can you say about the eigenvalues of \(C_{n}\)?

image


Solution.

format short;
n=10;   % Set the size of the large check board

% Construct your checkboard
CheckBoard=zeros(n);    
CheckBoard(1:2:n, 1:2:n)=1;
CheckBoard(2:2:n, 2:2:n)=1;
for i=1:n
       Cn=CheckBoard(1:i, 1:i);
       [Qn, Dn]=eig(Cn);    % Eigenvectors and eigenvalues
       fprintf('The size of the checkboard is %d \n',i);
       disp(diag(Dn)');
end

MATLAB results.

The size of the checkboard is 1 
     1

The size of the checkboard is 2 
     1     1

The size of the checkboard is 3 
     0     1     2

The size of the checkboard is 4 
     0     0     2     2

The size of the checkboard is 5 
   -0.0000   -0.0000    0.0000    2.0000    3.0000

The size of the checkboard is 6 
   -0.0000   -0.0000   -0.0000   -0.0000    3.0000    3.0000

The size of the checkboard is 7 
   -0.0000   -0.0000   -0.0000    0.0000    0.0000    3.0000    4.0000

The size of the checkboard is 8 
   -0.0000   -0.0000   -0.0000    0.0000    0.0000    0.0000    4.0000    4.0000

The size of the checkboard is 9 
   -0.0000   -0.0000   -0.0000   -0.0000         0    0.0000    0.0000    4.0000    5.0000

The size of the checkboard is 10 
   -0.0000   -0.0000         0    0.0000    0.0000    0.0000    0.0000    0.0000    5.0000    5.0000

We may conclude that the eigenvalues of \(C_{n}\) are given as follows:

\[\begin{cases} 1 & \text{if } n=1,\\ k,\, k,\, \underbrace{0,\,0,\,\cdots,\,0}_{(n-2)} & \text{if } n=2k,\\ k,\,k+1,\,\underbrace{0,\,0,\,\cdots,\,0}_{(n-2)} & \text{if } n=2k+1, \end{cases}\]

where \(k\) is a positive integer.

Leave a comment