Exercises 6.3 - 7.3

14 minute read

Chapter 6. Linear Transformations

6.3 Kernel and Range

Exercise 6.4. (Invertible Matrix as a Bijective Linear Transformation)

Consider the matrix

\[A = \left[\begin{array}{rrrr} 3& \hspace{1mm} -5& \hspace{1mm} -2&\hspace{3mm} 2\\ -4 & 7 & 4 & 4 \\ 4 & -9 & -3 & 7 \\ 2 & -6 & -3 & 2 \end{array} \right].\]

Referring to the Theorem 6.3.15 in Section 6.3, show that \(T_{A} : \mathbb{R}^{4} \rightarrow \mathbb{R}^{4}\) is onto in at least four different ways. You may use several related MATLAB commands.

Solution.

A = [3 -5 -2 2; -4 7 4 4; 4 -9 -3 7; 2 -6 -3 2];
format short;

% By (a) in Theorem 6.3.15, use the command rref of A.
rref(A)

% Since the reduced row echelon form of A is the identity matrix,
% the linear transformation T is onto.

% By (d) in Theorem 6.3.15, use the command null of A.

% Find a basis for the null space of A.
null(A, 'r') 

% Since the null space contains only the zero vector,
% the linear transformation T is onto.

% By (g) in Theorem 6.3.15, use the command rank of A.

% Find the number of linearly independent columns of A.
rank(A) 

% Since the column vectors of A are linearly independent,
% the linear transformation T is onto.

% By (i) in Theorem 6.3.15, use the command det of A.

% Find the determinant of A.
det(A) 

% Since det(A) is nonzero,
% the linear transformation T is onto.

% By (j) in Theorem 6.3.15, use the command eig of A.

% Find the eigenvalues A.
eig(A) 

% Since 0 is not an eigenvalue of A,
% the linear transformation T is onto.

6.4 Composition and Invertibility of Linear Transformations

Exercise 6.5. (Compositions of Linear Transformations)

Consider successive rotations of \(\mathbb{R}^{3}\) by \(30\,^{\circ}\) about the \(z\)-axis, then by \(60\,^{\circ}\) about the \(x\)-axis, and then by \(45\,^{\circ}\) about the \(y\)-axis. If it is desired to execute the three rotations by a single rotation about an appropriate axis, what axis and angle should be used?

Solution.

% Angle as a degree.
ang1=30; ang2=60; ang3=45; 

% Convert angles from degrees to radians.
theta1=((ang1)*(pi/180)); 
theta2=((ang2)*(pi/180));
theta3=((ang3)*(pi/180)); 

format short;

% Rotation about z-axis with the angle 30.
Rz = [cos(theta1) -sin(theta1) 0; sin(theta1) cos(theta1) 0; 0 0 1];
% Rotation about x-axis with the angle 60.
Rx = [1 0 0; 0 cos(theta2) -sin(theta2); 0 sin(theta2) cos(theta2)];
% Rotation about y-axis with the angle 45.
Ry = [cos(theta3) 0 sin(theta3); 0 1 0; -sin(theta3) 0 cos(theta3)];

% Composition of the three rotation matrices R = Ry*Rx*Rz.
R = Ry*Rx*Rz; 

% Find the axis of rotation of R,
% by finding the eigenvector of R corresponding to the eigenvalue lambda=1.

% Find a nonzero vector satisfying Rx = x.
x = null(eye(3) - R); 

% Find the angle of rotation of R.
% Note that w=(-x2,x1,0) is orthogonal to the axis of rotation x=(x1,x2,x3).
w = [-x(2) x(1) 0]';
theta = acos((dot(w, R*w))/((norm(w)*norm(R*w))));

% Convert the angle from radians to degrees.
ang = ((theta)*(180/pi));

disp('The angle of rotation in degrees is'); disp(ang);
disp('The axis of rotation is'); disp(x');

MATLAB results.

The angle of rotation in degrees is
   69.3559

The axis of rotation is
   -0.9350   -0.3525   -0.0391

Chapter 7. Dimension and Structure

7.1 Basis and Dimension

Exercise 7.1. (Linear Combination and Independence)

Are any of the vectors in the set

\[S = \{ (2,6,3,4,2), \hspace{1.5mm}(3,1,5,8,3), \hspace{1.5mm}(5,1,2,6,7), \hspace{1.5mm}(8,4,3,2,6), \hspace{1.5mm}(5,5,6,3,4) \}\]

linear combinations of predecessors? Justify your answer.

Solution. One strategy is to form a matrix \(V\) of the column vectors \(\mathbf{v}_{k}\) mentioned above and decide whether the system \(V \mathbf{x} = \mathbf{0}\) has nontrivial solutions. If so, then at least one column is a linear combination of previous ones. Otherwise, the columns are linearly independent.

v1 = [2 6 3 4 2]'; v2 = [3 1 5 8 3]'; v3 = [5 1 2 6 7]';
v4 = [8 4 3 2 6]'; v5 = [5 5 6 3 4]';

% Construct V of the column vectors v1,v2,v3,v4 and v5.
V = [v1 v2 v3 v4 v5]; 

format short;

% Find the reduced row echelon form of V.
rref_V = rref(V); 

disp('The reduced row echelon form of A is'); disp(rref_V);

MATLAB results.

The reduced row echelon form of A is
     1     0     0     0     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     1     0
     0     0     0     0     1

Since the reduced row echelon form of \(V\) has \(5\) pivots, the columns of \(V\) are linearly independent. Hence, no column of \(V\) can be a linear combination of any other columns.

7.2 Properties of Bases

Exercise 7.2.

In this problem, we make a function file CheckBasis.m to check that the vectors \(\mathbf{v}_{1}\), \(\mathbf{v}_{2}\), \(\mathbf{v}_{3}\) and \(\mathbf{v}_{4}\) form a basis of \(\mathbb{R}^4\) using the equivalent statements (a), (g), (h), and (o) of Theorem 7.2.7 in the textbook.

  1. Complete the shadow part (/////) of the m-file given below referring to the comments and the execution results.

    %--- your function file ---%
    function [Result]=CheckBasis(v1, v2, v3, v4, case_num)
        %  if case_num=1, check the statement (a),
        %  if case_num=2, check the statement (g),
        %  if case_num=3, check the statement (h).
    
        % Construct the matrix V.
        ////////////////////////
    
        % Use the switch statement to check 
        % whether one of the statements (a), (g), and (h) holds.
        switch case_num
        case 1  
            fprintf('* You enter %d: statement (a) *\n', case_num);
            ////////////////////////
            if ////////////////////////
            disp('Given vectors form a basis of 4 dimensional space.');
            else
            disp('Given vectors do not form a basis of 4 dimensional space.');
            end
        case 2
            fprintf('* You enter %d: statement (g) *\n', case_num);
            Result=det(V);
            if Result~=0
            disp('Given vectors form a basis of 4 dimensional space.');
            else
            disp('Given vectors do not form a basis of 4 dimensional space.');
            end
        ///////////////////////////  % check statement (h)
            ////////////////////////
            ////////////////////////
            ////////////////////////
            ////////////////////////
            ////////////////////////
            ////////////////////////
            ////////////////////////
        end
    end
    

    The execution results will be as follows in the Command Window:

    >> % Let vectors v1, v2 ,v3 ,v4, v5 be:
    v1=[1 0 0 0]'; v2=[0 2 0 0]'; v3=[0 0 4 5]'; v4=[0 0 0 -1]'; v5=[0 0 0 1]';
    >> C = CheckBasis(v1, v2, v3, v4, 3)
    * You entered 3: statement (h) *
      Given vectors form a basis of 4 dimensional space
    
    C =
    
        -8
    
    >> CheckBasis(v1, v2, v4, v5, 1);
    * You entered 1: statement (a) *
      Given vectors do not form a basis of 4 dimensional space.
    >> determinant=CheckBasis(v1, v2, v3, v5, 2)
    * You entered 2: statement (g) *
      Given vectors form a basis of 4 dimensional space.
    
    determinant =
    
        8
    
  2. Using CheckBasis.m from 1, check whether

    1. \(\mathbf{v}_{1}=(-1, 0, 1, 0)^{T}\), \(\mathbf{v}_{2}=(2, 3, -2, 6)^{T}\), \(\mathbf{v}_{3}=(0, -1, 2, 0)^{T}\) and \(\mathbf{v}_{4}=(0, 0, 1, 5)^{T}\) form a basis of \(\mathbb{R}^4\).

    2. \(\mathbf{v}_{1}=(a, b, c, d)^{T}\), \(\mathbf{v}_{2}=(-b, a, d, -c)^{T}\), \(\mathbf{v}_{3}=(-c, -d, a, b)^{T}\) and \(\mathbf{v}_{4}=(-d, c, -b, a)^{T}\) form a basis of \(\mathbb{R}^4\).
      (You may need to use the Symbolic toolbox of MATLAB)

Solution.

  1. CheckBasis.m
     % ----- your function file ----- %`\
     function [Result]=CheckBasis(v1, v2, v3, v4, case_num)
     %  if case_num=1, check the statement (a),
     %  if case_num=2, check the statement (g),
     %  if case_num=3, check the statement (h).
    
     % Construct the matrix V.
     V=[v1 v2 v3 v4];
    
     switch case_num
         case 1
             fprintf('* You entered %d: statement (a) *\n', case_num);
             Result=rref(V);
             if det(Result)~=0
                 disp('  Given vectors f orm a basis of 4 dimensional space.');
             else
                 disp('Given vectors do not form a basis of 4 dimensional space.');
             end
         case 2
             fprintf('* You entered %d: statement (g) *\n', case_num);
             Result=det(V);
             if Result~=0
                 disp('  Given vectors form a basis of 4 dimensional space.');
             else
                 disp('  Given vectors do not form a basis of 4 dimensional space.');
             end
         case 3
             fprintf('* You entered %d: statement (h) *\n', case_num);
             [Q, D]=eig(V);  % D: the eigenvalue matrix of V such that VQ = QD.
             Result=prod(diag(D));
             if Result~=0
                 disp('  Given vectors form a basis of 4 dimensional space');
             else
                 disp('  Given vectors do not form a basis of 4 dimensional space.');
             end
     end
     end
    
  2. 2-1.

     >> v1=[-1 0 1 0]'; v2=[2 3 -2 6]';  v3=[0 -1 2 0]'; v4 = [0 0 1 5]';
     CheckBasis(v1, v2, v3, v4, 1);
     CheckBasis(v1, v2, v3, v4, 2);
     CheckBasis(v1, v2, v3, v4, 3);
    

    MATLAB results.

     * You entered 1: statement (a) *
       Given vectors f orm a basis of 4 dimensional space.
     * You entered 2: statement (g) *
       Given vectors form a basis of 4 dimensional space.
     * You entered 3: statement (h) *
       Given vectors form a basis of 4 dimensional space
    

    2-2.

     >> syms a b c d;
     >> v1=[a;b;c;d]; v2=[-b;a;d;-c]; v3=[-c;-d;a;b]; v4 = [-d;c;-b;a];
     >> CheckBasis(v1, v2, v3, v4, 1);
     >> CheckBasis(v1, v2, v3, v4, 2);
    

    MATLAB results.

     * You enter 1: statement (a) *
       Given vectors form a basis of 4 dimensional space.
     * You enter 2: statement (g) *
       Given vectors form a basis of 4 dimensional space.
    

7.3 The Fundamental Spaces of a Matrix

Exercise 7.3. (Need the Symbolic toolbox)

In this problem, we make a function file getFSinfo.m to get the dimension and basis of the fundamental spaces of a given matrix. For example, we execute the followings:

>> A=[1 0 0 0 2; -2 1 -3 -2 -4; 0 5 -14 -9 0; 2 10 -28 -18 4];
>> getFSinfo(A);

Then, the Command Window displays the results as follows:

Given matrix is:
        1     0     0     0     2
    -2     1    -3    -2    -4
        0     5   -14    -9     0
        2    10   -28   -18     4

== Dimension of the fundamental spaces of a given matrix ==
dim(row(A))=dim(col(A)): 3,      dim(null(A)): 2,    dim(null(A_trans)): 1

== Basis of the fundamental spaces of a given matrix (in row vectors) ==
    row(A)
        1     0     0     0     2
        0     1     0     1     0
        0     0     1     1     0

    col(A)
        1     0     0     2
        0     1     0     0
        0     0     1     2

    null(A)
        0    -1    -1     1     0
    -2     0     0     0     1

    null(A_trans)
    -2     0    -2     1

*****************************************************
  1. Complete the missing parts of the m-file getFSinfo given as follows:

    %--- function file 'getFSinfo.m' ---%
    function [info]=getFSinfo(A)
        % row(A): basis and dimension
        /////// missing part ///////
    
        % col(A): basis and dimension
        /////// missing part ///////
    
        % null(A): basis and dimension
        /////// missing part ///////
    
        % null(A'): basis and dimension
        /////// missing part ///////
    
        disp('Given matrix is:'); disp(A);
        fprintf('== Dimension of the fundamental spaces of given matrix == \n');
        fprintf('dim(row(A))=dim(col(A)): %d,', rank_A);
        fprintf('\t dim(null(A)): %d,\t dim(null(A_trans)): %d \n\n', nullity, nullity_T);
        fprintf('== Basis of the fundamental spaces of given matrix (in row vectors) == \n');
        disp(' row(A)'); disp(double(rowA_basis));
        disp(' col(A)'); disp(double(colA_basis));
        disp(' null(A)'); disp(nullA_basis);
        disp(' null(A_trans)'); disp(nullAtrans_basis);
        fprintf('\n*****************************************************\n');
    end
    

    You may use the MATLAB commands rank, colspace, rref, null and so on.

  2. Using your function file getFSinfo.m, find the dimension and basis of the fundamental spaces of

    \(A = \begin{bmatrix} 3 & 2 & 1 & 3 & 5 \\ 6 & 4 & 3 & 5 & 7 \\ 9 & 6 & 5 & 7 & 9\\ 3 & 2 & 0 & 4 & 8 \end{bmatrix}, B = \begin{bmatrix} 3 & -1 & 3 & 2 & 5\\ 5 & -3 & 2 & 3 & 4\\ 1 & -3 & -5 & 0 & -7\\ 7 & -5 & 1 & 4 & 1 \end{bmatrix}, C = \begin{bmatrix} 1 & 3 & 2 & 1\\ -2 & -6 & 0 & -6\\ 3 & 9 & 1 & 8\\ -1 & -3 & -3 & -6\\ 1 & 3 & 2 & 1\\ 4 & 12 & 1 & 11 \end{bmatrix}\).

Solutions.

  1. getFSinfo.m
     % ----- function file 'getFSinfo.m' ----- %`
     function info = getFSinfo(A)
    
     [m,n]=size(A);        	% size of matrix A
    
     % row(A): basis and dimension
     rank_A = rank(A);         % rank of A
     rowA = colspace(sym(A')); % way1: MATLAB command colspace
     % rowA2=rref(A);  % way2: reduced row echelon form
     rowA_basis=rowA(:, 1:rank_A)';  % basis of row(A)
    
     % col(A): basis and dimension
     colA=colspace(sym(A));
     colA_basis=colA(:, 1:rank_A)';  % basis of col(A)
    
     % null(A): basis and dimension
     nullA=null(A, 'r');
     nullity=n-rank_A;   % way1. Dimension theorem
     nullA_basis=nullA(:, 1:nullity)';
     %     nullity=size(nullA,2);  % way2. return the corresponding value
    
     % null(A'): basis and dimension
     nullAtrans=null(A', 'r');
    
     % nullAtrans(:, 1:size(nullAtrans,2))'; basis of null(A')
     nullity_T=m-rank_A;    % way1. using the relation
     nullAtrans_basis=nullAtrans(:,1:nullity_T)';
     %     nullity=size(nullAtrans,2);   % way2. return the corresponding value
    
     % fprintf('****************************************************************\n');
     disp('Given matrix is:'); disp(A);
     fprintf('== Dimension of the fundamental spaces of given matrix == \n');
     fprintf('dim(row(A))=dim(col(A)): %d,', rank_A);
     fprintf('\t dim(null(A)): %d,\t dim(null(A_trans)): %d \n\n', nullity, nullity_T);
     fprintf('== Basis of the fundamental spaces of given matrix (in row vectors) == \n');
     disp(' row(A)'); disp(double(rowA_basis));
     disp(' col(A)'); disp(double(colA_basis));
     disp(' null(A)'); disp(nullA_basis);
     disp(' null(A_trans)'); disp(nullAtrans_basis);
     fprintf('\n****************************************************************\n');
     end
    
  2. *Commands.

     A=[3 2 1 3 5; 6 4 3 5 7; 9 6 5 7 9; 3 2 0 4 8];
     B=[3 -1 3 2 5; 5 -3 2 3 4; 1 -3 -5 0 -7; 7 -5 1 4 1];
     C=[1 3 2 1; -2 -6 0 -6 ;3 9 1 8; -1 -3 -3 -6; 1 3 2 1; 4 12 1 11];
     getFSinfo(A);
     getFSinfo(B);
     getFSinfo(C);
    

    MATLAB results.

     Given matrix is:
             3     2     1     3     5
             6     4     3     5     7
             9     6     5     7     9
             3     2     0     4     8
     == Dimension of the fundamental spaces of given matrix ==
     dim(row(A))=dim(col(A)): 2,  dim(null(A)): 3,    dim(null(A_trans)): 2
     == Basis of the fundamental spaces of given matrix (in row vectors) ==
         row(A)
         1.0000    0.6667         0    1.3333    2.6667
                 0         0    1.0000   -1.0000   -3.0000
         col(A)
             1     0    -1     3
             0     1     2    -1
         null(A)
         -0.6667    1.0000         0         0         0
         -1.3333         0    1.0000    1.0000         0
         -2.6667         0    3.0000         0    1.0000
         null(A_trans)
             1    -2     1     0
         -3     1     0     1
     *****************************************************
    
     Given matrix is:
             3    -1     3     2     5
             5    -3     2     3     4
             1    -3    -5     0    -7
             7    -5     1     4     1
     == Dimension of the fundamental spaces of given matrix ==
     dim(row(A))=dim(col(A)): 3,  dim(null(A)): 2,    dim(null(A_trans)): 1
     == Basis of the fundamental spaces of given matrix (in row vectors) ==
         row(A)
         1.0000         0    1.7500    0.7500         0
                 0    1.0000    2.2500    0.2500         0
                 0         0         0         0    1.0000
         col(A)
             1     0    -3     0
             0     1     2     0
             0     0     0     1
         null(A)
         -1.7500   -2.2500    1.0000         0         0
         -0.7500   -0.2500         0    1.0000         0
         null(A_trans)
             3    -2     1     0
     *****************************************************
    
     Given matrix is:
             1     3     2     1
         -2    -6     0    -6
             3     9     1     8
         -1    -3    -3    -6
             1     3     2     1
             4    12     1    11
     == Dimension of the fundamental spaces of given matrix ==
     dim(row(A))=dim(col(A)): 3,  dim(null(A)): 1,    dim(null(A_trans)): 3
     == Basis of the fundamental spaces of given matrix (in row vectors) ==
         row(A)
             1     3     0     0
             0     0     1     0
             0     0     0     1
         col(A)
         1.0000         0    0.5000         0    1.0000    0.5000
                 0    1.0000   -1.2500         0         0   -1.7500
                 0         0         0    1.0000         0         0
         null(A)
         -3     1     0     0
         null(A_trans)
         -0.5000    1.2500    1.0000         0         0         0
         -1.0000         0         0         0    1.0000         0
         -0.5000    1.7500         0         0         0    1.0000
     *****************************************************
    

Exercise 7.4. (Bases for the Fundamental Spaces, Need the Symbolic toolbox)

  1. Use the MATLAB commands sym and colspace to find a basis for the column space of the matrix

    \[A = \left[\begin{array}{rrrr} 2& \hspace{2mm} -1& \hspace{5mm} 3&\hspace{4mm} 5\\ 4 & -3 & 1 & 3 \\ 3 & -2 & 3 & 4 \\ 4 & -1 & 15 & 17 \\ 7 & -6 & -7 & 0 \end{array} \right].\]
  2. Use the same MATLAB commands in 1 to find a basis for the row space of \(A\).

  3. Confirm that the basis obtained in 2 is consistent with the basis obtained from the reduced row echelon form of \(A\).

  4. Tell what happens if you use the MATLAB command orth?

Solutions.

  1. % Set a matrix A whose entries are symbolic objects.
    A = sym([2 -1 3 5; 4 -3 1 3; 3 -2 3 4; 4 -1 15 17; 7 -6 -7 0]);
    
    % Find a basis for the column space of A.
    col_basis = colspace(A);
    
    disp('A basis for the column space of A is');
    disp(col_basis(:,1)'); disp(col_basis(:,2)'); disp(col_basis(:,3)');
    

    MATLAB results.

    A basis for the column space of A is
    [ 1, 0, 0, 2, 1]
    
    [ 0, 1, 0, -3, 5]
    
    [ 0, 0, 1, 4, -5]
    
  2. % Set a matrix A_transpose whose entries are symbolic objects.
    A_transpose = sym([2 -1 3 5; 4 -3 1 3; 3 -2 3 4; 4 -1 15 17; 7 -6 -7 0]');
    
    % Finding a basis for the row space of A is equivalent to
    % finding a basis for the column space of A_transpose.
    rowbasis = colspace(A_transpose);
    
    disp('A basis for the row space of A is');
    disp(rowbasis(:,1)'); disp(rowbasis(:,2)'); disp(rowbasis(:,3)');
    

    MATLAB results.

    A basis for the row space of A is
    [ 1, 0, 0, 6]
    
    [ 0, 1, 0, 7]
    
    [ 0, 0, 1, 0]
    
  3. % Set a matrix A.
    A = [2 -1 3 5; 4 -3 1 3; 3 -2 3 4; 4 -1 15 17; 7 -6 -7 0];
    
    % Find the reduced row echelon form of A.
    rref_A = rref(A); 
    
    % The nonzero rows of the reduced row echelon form of A
    % form a basis for the row space of A.
    
    disp('A basis for the row space of A is');
    disp(rref_A(1,:)); disp(rref_A(2,:)); disp(rref_A(3,:));
    

    MATLAB results.

    A basis for the row space of A is
        1     0     0     6
    
        0     1     0     7
    
        0     0     1     0
    
  4. % Set A.
    A = [2 -1 3 5; 4 -3 1 3; 3 -2 3 4; 4 -1 15 17; 7 -6 -7 0]; 
    
    % The command orth gives an orthonormal basis for the column space of A.
    B = orth(A);
    
    disp('An orthonormal basis for the column space of A is');
    disp('q1='); disp(B(:,1)');
    disp('q2='); disp(B(:,2)');
    disp('q3='); disp(B(:,3)');
    

    MATLAB results.

    An orthonormal basis for the column space of A is
    q1=
        -0.2427   -0.1508   -0.2229   -0.9246    0.1177
    
    q2=
        -0.1189   -0.3624   -0.2060    0.0253   -0.9008
    
    q3=
        0.3760   -0.6016   -0.5930    0.1848    0.3331
    

Leave a comment