Exercises – Long Day#


Exercise 1: Intro to Systems of Linear Equations with SymPy#

In Exercise 6 from Short Day in Week 7 the following three systems of linear equations over \(\mathbb R\) were investigated:

\[\begin{split} \left\{ \begin{array}{ccc} x_1 + x_2+ x_3 & = & 1\\ x_1+ 2x_2 +4x_3 & = & 1\\ x_1 +3x_2+9x_3 & = & 1\\ \end{array} \right. \end{split}\]
\[\begin{split} \left\{ \begin{array}{ccc} x_1 + x_2+ x_3 & = & 1\\ x_1+ 2x_2 +4x_3 & = & 1\\ x_1 +3x_2+7x_3 & = & 1\\ \end{array} \right. \end{split}\]
\[\begin{split} \left\{ \begin{array}{ccc} x_1 + x_2+ x_3 & = & 1\\ x_1+ 2x_2 +4x_3 & = & 1\\ x_1 +3x_2+7x_3 & = & 0.\\ \end{array} \right. \end{split}\]

We now want to investigate these three systems again, this time using the CAS tool SymPy. Open a Jupyter notebook and begin by running the command from sympy import *. The command enables the use of SymPy commands.

Question a#

The augmented matrix \(\mathbf T_1\) of linear equation system no. 1 can be defined in SymPy as follows:

T1=Matrix([[1,1,1,1],[1,2,4,1],[1,3,9,1]]).

Try this command. To see the matrix on your screen, just type T1. To compute its reduced row-echelon form, type T1.rref(). Note that “rref” is simply an abbreviation of “reduced row-echelon form”. How should we interpret the output?

If you use the command T1.rref(pivots=False), then you will only see the reduced row-echelon form of \(\mathbf T_1\). Try this command as well.

Question b#

The solution can be read directly from the reduced row-echelon form of \(\mathbf T_1\). One can also solve the system directly in SymPy. First, the system’s coefficient matrix A=Matrix([[1,1,1],[1,2,4],[1,3,9]]) must be defined as well as the system’s right-hand side b=Matrix([[1],[1],[1]]). Now test the command linsolve((A,b)) and interpret the output.

Question c#

Now try on your own to go through the same steps as in Questions a and b, this time for equation system no. 2. Which columns of the reduced row-echelon form of its augmented matrix \(\mathbf T_2\) contain a pivot element? What is the solution set to the system?

Question d#

Now repeat this one more time for equation system no. 3. Which columns of the reduced row-echelon form of its augmented matrix contain pivot elements? What is the solution set to the system?


Exercise 2: Linear Combinations#

We are given the following vectors in \(\mathbb{R}^3\):

\[\begin{split} {\mathbf u}=\left[ \begin{array}{c} 4\\ -2\\ 0\\ \end{array} \right], \quad {\mathbf v}=\left[ \begin{array}{c} 7\\ 4\\ 3\\ \end{array} \right], \quad {\mathbf w}=\left[ \begin{array}{c} 1\\ 7\\ 3\\ \end{array} \right]. \end{split}\]

Question a#

Compute by hand the following linear combinations of the three vectors \({\mathbf u}, {\mathbf v},\) and \({\mathbf w}.\)

  1. \(4{\mathbf v}.\)

  2. \(2{\mathbf u}-3{\mathbf w}\).

  3. \(3{\mathbf u}-2{\mathbf v}+2{\mathbf w}\).

Question b#

Determine whether the vectors \({\mathbf u}, {\mathbf v},\) and \({\mathbf w}\) are linearly independent based on the answers from Question a.

Question c#

Show that the vectors \({\mathbf u}\) and \({\mathbf v}\) are linearly independent.


Exercise 3: Linearly Independent Vectors in \(\mathbb{R}^4\)#

The following three vectors in \(\mathbb{R}^4\) are given:

\[\begin{split} {\mathbf u}=\left[ \begin{array}{c} 1\\ 1\\ 0\\ 0\\ \end{array} \right], \quad {\mathbf v}=\left[ \begin{array}{c} 0\\ 1\\ 1\\ 0\\ \end{array} \right], \quad {\mathbf w}=\left[ \begin{array}{c} 0\\ 0\\ 1\\ 1\\ \end{array} \right]. \end{split}\]

Question a#

Show that the vectors \({\mathbf u}, {\mathbf v},\) and \({\mathbf w}\) are linearly independent.

Question b#

Determine a vector \({\mathbf b} \in \mathbb{R}^4\) such that the vectors \({\mathbf u}, {\mathbf v}, {\mathbf w},\) and \({\mathbf b}\) are linearly independent.

Question c#

Assume that \({\mathbf c} \in \mathbb{R}^4\) fulfills that the vectors \({\mathbf u}, {\mathbf v}, {\mathbf w},\) and \({\mathbf c}\) are linearly independent. Show that if so, then vector \(\mathbf c\) cannot be written as a linear combination of \({\mathbf u}, {\mathbf v},\) and \({\mathbf w}\).


Exercise 4: Linear Independency and Reduced Row-Echelon Form#

We are given the following four vectors in \(\mathbb{C}^4\):

\[\begin{split} {\mathbf v_1}=\left[ \begin{array}{c} 1+i\\ 1\\ 0\\ 4\\ \end{array} \right], \quad {\mathbf v_2}=\left[ \begin{array}{c} 0\\ 1\\ 0\\ 7\\ \end{array} \right], \quad {\mathbf v_3}=\left[ \begin{array}{c} 2+2i\\ 0\\ 1\\ 1\\ \end{array} \right] \quad {\mathbf v_4}=\left[ \begin{array}{c} 2+2i\\ 5\\ 1+i\\ 1\\ \end{array} \right]. \end{split}\]

Question a#

Define in SymPy the \(4 \times 4\) matrix \(\mathbf A\) that has columns \({\mathbf v}_1, {\mathbf v}_2, {\mathbf v}_3,\) and \({\mathbf v}_4\). Use SymPy to compute the reduced row-echelon form of the matrix. Use this row-echelon form to determine the rank of \({\mathbf A}\).

Question b#

Are the given vectors \({\mathbf v}_1, {\mathbf v}_2, {\mathbf v}_3,\) and \({\mathbf v}_4\) linearly independent?


Question 5: Matrix Product#

We are given the following three matrices:

\[\begin{split} {\mathbf A}=\left[ \begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ \end{array} \right] \quad {\mathbf B}=\left[ \begin{array}{cc} 1 & 4\\ 2 & 1\\ 3 & 0\\ \end{array} \right] \quad {\mathbf C}=\left[ \begin{array}{ccc} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 2 & 0 & 0 \\ \end{array} \right]. \end{split}\]

Question a#

Which of the nine combinations of matrix products \({\mathbf A}\cdot{\mathbf A}\), \(\, {\mathbf A}\cdot{\mathbf B}\), \(\, {\mathbf A}\cdot{\mathbf C}\), \(\, {\mathbf B}\cdot{\mathbf A}\), \(\, {\mathbf B}\cdot{\mathbf B}\), \(\, {\mathbf B}\cdot{\mathbf C}\), \(\, {\mathbf C}\cdot{\mathbf A}\), \(\, {\mathbf C}\cdot{\mathbf B}\), \(\, {\mathbf C}\cdot{\mathbf C}\) are defined?

Question b#

Compute by hand the matrix products \({\mathbf A}\cdot{\mathbf B}\) and \({\mathbf B}\cdot{\mathbf A}\). Does it apply that \({\mathbf A}\cdot{\mathbf B}={\mathbf B}\cdot{\mathbf A}\)?

Question c#

Compute the product of the scalar \(-1/2\) and the matrix \(\mathbf C\). In other words, compute \((-1/2) \cdot {\mathbf C}\).

Question d#

Determine whether the following sums of matrices are defined, and compute those that are: \((-1/2) \cdot {\mathbf C}+{\mathbf A} \cdot {\mathbf B}\) and \((-1/2) \cdot {\mathbf C}+{\mathbf B} \cdot {\mathbf A}.\)


Exercise 6: Matrix-Vector Product and Systems of Linear Equations#

We are given the linear equation system

\[\begin{split} \left\{ \begin{array}{ccc} x_1 + x_4 & = & 0\\ -2x_1+x_2 +3x_4 & = & 1\\ 5x_1 +x_3 -4x_4 & = & 1\\ 4x_1 +x_2 +x_3 & = & 2.\\ \end{array} \right. \end{split}\]

Question a#

Write the system in the form as in Equation (7-5) in Chapter 7 of the textbook.

Question b#

We define

\[\begin{split}{\mathbf A}=\left[ \begin{array}{ccccc} 1 & 0 & 0 & 1 \\ -2 & 1 & 0 & 3 \\ 5 & 0 & 1 & -4 \\ 4 & 1 & 1 & 0 \\ \end{array} \right], \quad {\mathbf b}=\left[ \begin{array}{c} 0 \\ 1 \\ 1 \\ 2 \\ \end{array} \right].\end{split}\]

Check that the given linear equation system has the augmented matrix \([{\mathbf A}|{\mathbf b}]\). In Exercise 3b from Short Day in Week 7 we checked by hand that the linear equation system with augmented matrix \([{\mathbf A}|{\mathbf b}]\) has the following particular solution:

\[\begin{split} {\mathbf v}=\left[ \begin{array}{c} 0 \\ 1 \\ 1 \\ 0 \\ \end{array} \right]. \end{split}\]

Check this again, this time by computing the product \({\mathbf A}\cdot{\mathbf v}\) in SymPy.

Question c#

Let \({\mathbf A}\) and \({\mathbf v}\) be the same as before. The product \({\mathbf v}\cdot{\mathbf A}\) is not defined. What happens if you try to compute the product in SymPy anyways?


Exercise 7: Computing Inverse Matrices#

We are given the following square matrix:

\[\begin{split}{\mathbf A}=\left[ \begin{array}{ccc} 1 & 1 & 0 \\ -1 & 1 & 0 \\ 5 & 0 & 1 \\ \end{array} \right].\end{split}\]

Question a#

Determine by hand whether the matrix \({\mathbf A}^{-1}\) exists, and if so then compute it (still by hand).

Question b#

Check your computations with SymPy.


Exercise 8: Inverse Matrices and Systems of Linear Equations#

Let \({\mathbf A} \in \mathbb{C}^{n \times n}\) be a square matrix and assume that \({\mathbf A}\) is an invertible matrix. Furthermore, let \({\mathbf b} \in \mathbb{C}^n\) be a vector.

Question a#

Show that the vector \({\mathbf A}^{-1}\cdot {\mathbf b} \in \mathbb{C}^n\) is a solution to the linear equation system with augmented matrix \([{\mathbf A}|{\mathbf b}].\)

Question b#

Show that the vector \({\mathbf A}^{-1} \cdot {\mathbf b}\) is the only solution to the linear equation system with augmented matrix \([{\mathbf A}|{\mathbf b}].\)


Exercise 9: Equation Systems with a Variable Coefficient#

We are for every real value of \(a\) given the linear equation system

\[\begin{split} \begin{align*} ax_1 + x_2 + x_3 &= 1\\ x_1 + ax_2 + x_3 &= 1\\ x_1 + x_2 + ax_3 &= 1. \end{align*} \end{split}\]

Question a#

State the augmented matrix of the system.

Question b#

What is the solution to the system in the specific case where \(a=-2\).

Question c#

Determine the solution to the linear equation system for all \(a\).

Question d#

Can SymPy solve the exercise?