Exercises and Problems¶
Exercise 1.
Press “Activate” to display matrices \(\,\boldsymbol{A}\,\) and \(\,\boldsymbol{B}\,\) together with their product \(\,\boldsymbol{A}\boldsymbol{B}.\) \(\\\) To change the size of matrices set a new value of n. \(\,\) Additionally:
Verify by hand the computer result \(\,\boldsymbol{A}\boldsymbol{B}\,\) of the multiplication.
- Add a piece of code that displays the product \(\,\boldsymbol{B}\boldsymbol{A}\,\)and demonstrate thereby the noncommutativity of the matrix multiplication.
Exercise 2.
This example concerns matrices whose elements depend (at least initially) on variables. \(\\\) Starting from the code in the cell below, add the following steps:
- Create the matrix \(\,\boldsymbol{A}\,\) by two other ways.
- Determine the base ring of the matrix \(\,\boldsymbol{A}\ \) (apply \(\,\)
A.base_ring()
). - Write the matrix \(\,\boldsymbol{B}\,\) obtained from \(\,\boldsymbol{A}\,\) by the substition \(\,\) a = -1(apply \(\,\)
A.subs()
) \(\,\) and determine the ring thereof. - Write the matrix \(\,\boldsymbol{C}\,\) obtained from \(\,\boldsymbol{B}\,\) by changing the ring to RDF(apply \(\,\)
B.change_ring()
) \(\,\) and check the ring.
Exercise 3.
The program creates a random matrix \(\,\boldsymbol{A}\,\) over the integer ring with \(\,m\,\) rows and \(\,n\,\) columns. Next it extracts an \(\,i\)-th row and/or a \(\,j\)-th column of \(\boldsymbol{A},\ \) indicating the type thereof.
Set the values of \(\,m,n\,\) as well as of \(\,i,j\,\) \(\ (0 \leq i \leq m-1,\ 0 \leq j \leq n-1)\) \(\\\) and uncomment one or more hashed commands to visualise \(\\\) various ways of obtaining the results.
Exercise 4.
Complete the code below by adding the following steps:
- \(\,\) Create a random \(\ 5 \times 4\ \) matrix \(\,\boldsymbol{A}\,\) over the integer ring\(\,\) (apply
random_matrix()
). - \(\,\) Using the slicing technique, create the matrix \(\,\boldsymbol{B},\,\) whose consecutive rows\(\,\) are the last, middle and first row of matrix \(\,\boldsymbol{A}.\)
- \(\,\) Write down a selected column of matrix \(\,\boldsymbol{A}\,\)\(\,\) as a vector \(\,\boldsymbol{v}\,\) and as a 1-column matrix \(\,\boldsymbol{C}.\ \)\(\,\) Check the type of the obtained objects.
Hint for the item 2.: \(\\\)
Use the template [p:q:r]
with the default value
of q : \(\,\) [p::r]
, \(\\\)
and with \(\,\) p = -1, r = -2. \(\,\)
What is the actual value of q ?
Exercise 5.
Despite the Sage’s “row bias” with respect to vectors and matrices, it is possible to create a matrix with given columns (they are to be input as vectors). Run the following code:
Problem 0. \(\,\)
Check the associative and distributive laws:
for three randomly generated matrices \(\ \boldsymbol{A},\boldsymbol{B},\boldsymbol{C}\in M_3(Q).\)
Problem 1. \(\,\)
Take, for example, the matrices
to show that the identity
no longer holds true in algebra of matrices. In view of that, investigate the two issues:
What is the actual formula for the square of a sum or difference \(\ (\boldsymbol{A}\pm\boldsymbol{B})^2\ \,\) of matrices?
- When, i.e. on what conditions for \(\ \boldsymbol{A},\boldsymbol{B}\in M_n(K),\ \) the equation (1) remains true?
Problem 2. \(\,\)
For the matrices \(\ \ \boldsymbol{P}\ =\ \left[\begin{array}{ccc} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{array}\right] \quad\text{and}\quad\ \boldsymbol{Q}\ =\ \left[\begin{array}{ccc} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{array}\right]\quad \in\ M_3(R):\)
Calculate the products \(\ \,\boldsymbol{P}\boldsymbol{Q},\ \,\boldsymbol{Q}\boldsymbol{P},\ \boldsymbol{P}^2,\ \boldsymbol{Q}^2.\)
- Investigate the result of multiplying an arbitrary matrix \(\ \boldsymbol{A}\in M_3(R)\ \)from the left or from the right by \(\ \boldsymbol{P}\ \) or \(\ \boldsymbol{Q}.\)
- Find other matrices from \(\ M_3(R),\ \) whose square equals the identity matrix \(\ \boldsymbol{I}_3\,.\)
Hint for the item 3.: \(\\\) Try matrices obtained from \(\ \boldsymbol{I}_3\ \) by swapping around two rows or two columns.
Problem 3. \(\,\)
Experiment with small exponents \(\ n=2,3,4,\,\ldots\ \) to come up with a general formula for an arbitrary power of the following matrices over the rational field \(\ Q:\)
Problem 4. \(\,\)
Given the matrix \(\ \boldsymbol{A}\ \) and the vector \(\ \boldsymbol{x},\ \) calculate \(\ \boldsymbol{A}^n,\ n\in\boldsymbol{N},\ \) and the product \(\ \boldsymbol{A}^n\,\boldsymbol{x}:\)