Exercises 3.2 - 3.4
Chapter 3. Systems of Linear Equations
3.2 Inverses; Algebraic Properties of Matrices
Exercise 3.1.
In this problem, we compute \(A^{5} - 3A^{3} + 7A - 4I\) for the matrix \(A\), where
\[A = \begin{bmatrix} 1 & 2 & -3 & 0\\ 1 & 1 & -2 & 1\\ 2 & 1 & 3 & 4\\ -3 & 2 & 2 & -8 \end{bmatrix}.\]-
Using the syntax
A^k
which produces the \(k\)-th power of a square matrix and the commandeye
for the identity matrix, compute the above matrix polynomial. -
Using the command
polyvalm
, compute the above matrix polynomial. -
Tell what happens if you type the syntax
A.^k
.
Solution.
% Construct the matrix A.
A = [1 2 -3 0; 1 1 -2 1; 2 1 3 4; -3 2 2 -8];
% (a)
result_a = A^5 + (-3)*A^3 + 7*A + (-4)*eye(4);
% Display the matrix polynomial.
disp('The result of the matrix polynomial is');
disp(result_a)
% (b)
% Coefficient of the matrix polynomial.
coeff_poly = [1 0 -3 0 7 -4];
% Evaluate the matrix polynomial of coefficient
% with coeff_poly vector with the input matrix A.
result_b = polyvalm(coeff_poly, A);
% Display the matrix polynomial.
disp('The result of the matrix polynomial is');
disp(result_b);
% (c)
disp('The result of A.^2 is'); disp(A.^2);
disp('The result of A.^3 is'); disp(A.^3);
disp('The result of A.^4 is'); disp(A.^4);
MATLAB results.
The result of the matrix polynomial is
874 -1272 -39 3021
2580 -2306 -723 7536
5191 -4121 -2444 14563
-16852 12539 5649 -46917
The result of the matrix polynomial is
874 -1272 -39 3021
2580 -2306 -723 7536
5191 -4121 -2444 14563
-16852 12539 5649 -46917
The result of A.^2 is
1 4 9 0
1 1 4 1
4 1 9 16
9 4 4 64
The result of A.^3 is
1 8 -27 0
1 1 -8 1
8 1 27 64
-27 8 8 -512
The result of A.^4 is
1 16 81 0
1 1 16 1
16 1 81 256
81 16 16 4096
From the results, we can see that the syntax `A.^k produces the entrywise \(k\)-th powers of the matrix \(A\).
3.3 Elementary Matrices; A Method for Finding \(A^{-1}\)
Exercise 3.2.
In this problem, we solve the linear system \(A \mathbf{x} = \mathbf{b}\) by using matrix inversion, where
\[A = \begin{bmatrix} 3 & 3 & -4 & -3 \\ 0 & 6 & 1 & 1\\ 5 & 4 & 2 & 1 \\ 2 & 3 & 3 & 2 \end{bmatrix} \quad \mathrm{and} \quad \mathbf{b} = \begin{bmatrix} -2 \\ 3 \\ 5 \\ 1 \end{bmatrix}.\]-
Use the MATLAB command
inv
or the syntaxA^(-1)
to find the inverse of \(A\). -
Display the output matrix as a rational form, NOT decimally. You may use the command
format
. -
Using the result of (a), compute the solution of the linear system \(A \mathbf{x} = \mathbf{b}\) by taking \(\mathbf{x} = A^{-1} \mathbf{b}\).
Solution.
% Construct the matrix A and the right-hand-side vector b.
A = [3 3 -4 -3; 0 6 1 1; 5 4 2 1; 2 3 3 2];
b = [-2 3 5 1]';
% (a)
% Use the command inv.
Inv_A1 = inv(A);
% Use the syntax A^(-1).
Inv_A2 = A^(-1);
% (b)
format rat;
disp('The result of the command inv is'); disp(Inv_A1);
disp('The result of the syntax A^(-1) is'); disp(Inv_A2);
% (c)
% Since A is invertible, the solution to Ax=b is x=A^(-1)*b.
x = Inv_A1 * b;
disp('The solution to Ax=b is x = A^(-1)*b'); disp(x');
MATLAB results.
The result of the command inv is
-7 5 12 -19
3 -2 -5 8
41 -30 -69 111
-59 43 99 -159
The result of the syntax A^(-1) is
-7 5 12 -19
3 -2 -5 8
41 -30 -69 111
-59 43 99 -159
The solution to Ax=b is x = A^(-1)*b
70 -29 -406 583
3.4 Subspaces and Linear Independence
Exercise 3.3. (Sigma notation)
Compute the linear combination
\[\mathbf{v}=\Sigma_{j=1}^{25} c_{j}\mathbf{v}_{j}\]for \(c_{j}=1/j\) and \(\mathbf{v}_{j}=(\sin j, \cos j).\)
Solution.
v=zeros(1,2);
for i=1:25
v=v+(1/i)*[sin(i), cos(i)];
end
disp(v);
MATLAB results.
1.0322 0.0553
Exercise 3.4.
Let \(\mathbf{v_{1}}=(4, 3, 2, 1)\), \(\mathbf{v_{2}}=(5, 1, 2, 4)\), \(\mathbf{v_{3}}=(7, 1, 5, 3)\), \(\mathbf{x}=(16, 5, 9, 8)\), and \(\mathbf{y}=(3, 1, 2, 7)\). Determine whether \(\mathbf{x}\) and \(\mathbf{y}\) lie in \(\textrm{span}\{\mathbf{v_{1}}, \mathbf{v_{2}}, \mathbf{v_{3}}\}\).
Solution.
% Construct v1, v2, v3, x, y
v1=[4 3 2 1]'; v2=[5 1 2 4]'; v3=[7 1 5 3]';
x=[16 5 9 8]'; y=[3 1 2 7]';
% Augmented matrices [v1|v2|v3|x] and [v1|v2|v3|y]
X=[v1 v2 v3 x];
Y=[v1 v2 v3 y];
disp('Reduced row echelon form of [v1 v2 v3 x] is');
disp(rref(X));
disp('Reduced row echelon form of [v1 v2 v3 y] is');
disp(rref(Y));
MATLAB results.
Reduced row echelon form of [v1 v2 v3 x] is
1 0 0 1
0 1 0 1
0 0 1 1
0 0 0 0
Reduced row echelon form of [v1 v2 v3 y] is
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Therefore, \(\mathbf{x}\) lies in \(\textrm{span}\{\mathbf{v_{1}}, \mathbf{v_{2}}, \mathbf{v_{3}}\}\) and \(\mathbf{y}\) does not lie in \(\textrm{span}\{\mathbf{v_{1}}, \mathbf{v_{2}}, \mathbf{v_{3}}\}\).
Leave a comment