Theorems on Solutions of Linear Equations¶
Rank of a Matrix¶
Let \(\,\boldsymbol{A}\ \) be a matrix with \(\,m\,\) rows \(\ \ \text{and}\ \ \,n\ \) columns over a field \(\,K:\ \,\boldsymbol{A}\,\in M_{m\times n}(K). \\\)
Definition. \(\,\)
The row rank \(\,\) of the matrix \(\,\boldsymbol{A}\ \,\) is the number of linearly independent rows of this matrix. \(\\\) Similarly, the \(\,\) column rank \(\,\) is the number of linearly independent columns.
Theorem. \(\,\)
The column rank is equal to the row rank of the matrix.
It makes sense then to talk about the rank of the matrix \(\,\boldsymbol{A},\,\) which is equal to its number of linearly independent rows or columns. We denote it by \(\ \text{rk}\,\boldsymbol{A}.\)
Corollary 1. \(\\\) The rank of the matrix cannot be greater than any of its two dimensions: \(\ \,\text{rk}\boldsymbol{A}\,\leq\,m,n.\)
Corollary 2. \(\\\) The rank of the matrix equals the dimension of the space spanned by its rows, \(\\\) and also to the dimension of the space spanned by its columns. \(\\\)
Theorem. \(\,\)
Elementary operations on rows or columns do not change rank of the matrix.
The rank of the matrix is equal then to the number of leading unities in its reduced row echelon form.
Theorem. \(\,\)
The rank of the matrix is equal to the highest order of its non-zero minors.
We will apply the aforementioned methods to determine rank of a given matrix by using functions built in Sage. \(\\\)
Rank of the matrix is given by a direct function rank()
:
sage: A = matrix(QQ,[[2, 3, 5,-3,-2],
[3, 4, 3,-1,-3],
[5, 6,-1, 3,-5]])
sage: rk_A = A.rank()
sage: print "Rank of the matrix A is", rk_A
Rank of the matrix A is 2
The methods row_space()
and column_space()
create a space spanned by rows \(\\\)
and columns of the matrix, \(\,\) while dimension()
provides a dimension of the space:
sage: Vrow = A.row_space()
sage: Vcol = A.column_space()
sage: print "Dimension of the row space of matrix A:", Vrow.dimension()
sage: print "Dimension of the column space of matrix A:", Vcol.dimension()
Dimension of the row space of matrix A: 2
Dimension of the column space of matrix A: 2
In reduced row echelon form the matrix \(\,\boldsymbol{A}\,\) has two leading unities:
sage: table([["A", "=", A, '$\\rightarrow$', A.rref()]])
The method minors(k)
provides a list of all the minors of order \(\,k\ \)
of the given matrix:
sage: print A.minors(2)
sage: print ""
sage: print A.minors(3)
[-1, -9, 7, 0, -11, 9, -1, 4, -9, 7, -3, -27, 21, 0, -33, 27, -3, 12,
-27, 21, -2, -18, 14, 0, -22, 18, -2, 8, -18, 14]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
As one can see, the matrix \(\,\boldsymbol{A}\ \) has non-zero minors of order two, whereas all the minors of order three vanish. \(\\\)
Eventually, each of the methods used gives the same result: \(\ \,\text{rk}\,\boldsymbol{A} = 2.\)
General Solution of a System of Equations¶
We consider a (nonhomogeneous) system of linear equations given by a matrix equation of the form
and the corresponding homogeneous system
where \(\,\boldsymbol{A}\,\in M_{m\times n}(K)\,\) and \(\,\boldsymbol{b}\in K^m.\)
A necessary and sufficient condition for any solution to exist provides
Theorem 0. \(\,\) (Kronecker-Capelli) \(\,\)
A system of linear equations (1) has a solution (is consistent) if and only if the rank of its coefficient matrix is equal to the rank of its augmented matrix:
For the homogeneous system (2) the condition (3) is always fulfilled, because adding a zero column does not change the rank of the matrix. Hence, the homogeneous system is always consistent \(\,\) - \(\,\) there always exists at least a zero solution \(\,\boldsymbol{x} = \boldsymbol{0}.\,\) The existence of non-zero solutions explains
Theorem 1. \(\,\)
The homogeneous system of equations (2) has non-zero solutions if and only if the rank of its coefficient matrix is smaller than the number of unknowns: \(\ \ \text{rk}\boldsymbol{A}\,<\,n\,.\)
In particular, the non-zero solutions exist if the number of equations is smaller than the number of unknowns, that is when \(\,m<n.\)
Let us consider an important case of \(\ \,m=n.\ \,\) Then the condition \(\ \,\text{rk}\boldsymbol{A}<n\ \,\) is satisfied if and only if \(\ \det\boldsymbol{A}=0.\ \,\) Hence, and also by Cramer’s formulae follows
Theorem 1a.
The homogeneous system of equations given by the square matrix \(\,\boldsymbol{A}\,\) has non-zero solutions if and only if \(\ \det\boldsymbol{A}=0.\)
\(\;\)
Denote by \(\ S\ \,\) and \(\ \,S_0\ \) the sets of solutions for the systems \(\,\) (1) \(\ \) and \(\ \,\) (2) :
Due to the nature of matrix multiplication, it follows that if both \(\,\boldsymbol{X}_1,\,\boldsymbol{X}_2,\,\) are in the set \(\,S_0,\,\) then so is their every linear combination \(\,a_1\boldsymbol{X}_1+a_2\boldsymbol{X}_2,\ \,a_1,a_2\in K:\)
This means that the set \(\,S_0\,\) is a subspace of the space \(\,K^n\,.\ \) More precisely,
Theorem 2. \(\,\)
The set \(\,S_0\,\) of solutions of the homogeneous system of equations (2) is a vector space (a subspace of the space \(\,K^n\)), whose dimension is equal to the dieference of the number of unknowns and the rank of the coefficient matrix:
We should emphasize that the set \(\,S\,\) of solutions of the nonhomogeneous system of equations (1) is not a vector space (namely, it is a linear variety). If \(\,\text{rk}\boldsymbol{A} = n,\,\) then \(\,\text{dim}\,S_0 = 0,\,\) that is the space \(\,S_0\,\) is reduced to the set containing only one element, the zero vector. This means (in accordance with Theorem 1.) that the system of equations has only the zero solution.
A relation between the solution sets \(\ S\ \,\) and \(\ \,S_0\ \) defined in (4) presents
Theorem 3. \(\,\)
Let \(\,\boldsymbol{X'}\,\) be a particular solution of the system (1):
Then the set \(\,S\,\) of all the solutions of the system (1) may be obtained by adding \(\,\boldsymbol{X'}\,\) \(\\\) to each solution of the system (2) from the set \(\,S_0 :\)
In this way the general solution of the nonhomogeneous system of linear equations is a sum of a particular solution of this system and the general solution of the corresponding homogeneous system.
Corollary. \(\,\)
The nonhomogeneous system (1) has precisely one solution if and only if the rank of the coefficient matrix equals the number of the unknowns: \(\ \text{rk}\boldsymbol{A} = n\,.\ \)
Hence, at least in general, in order to solve a nonhomogeneous system, it suffices to find (or guess) its particular solution and solve the corresponding homogeneous system.
Systems of Linear Equations in Sage¶
According to Theorem 3., \(\,\) the solution of a system of linear equations
where \(\,\boldsymbol{A}\,\in M_{m\times n}(K)\,\) and \(\,\boldsymbol{b}\in K^m,\ \) may be obtained in two stages:
\(\,\) finding a particular solution of the system;
\(\,\) calculation of the general solution of the homogeneous system associated with the original one.
To this end the two methods in Sage may be used:
A.solve_right(b)
or in shortA\b
yields a particular solution of the system;A.right_kernel_matrix()
returns a matrix, whose rows form basis of the space \(\,S_0\,\) of solutions of the associated homogeneous system.
Example. \(\,\) Consider the system over rational field \(\,Q:\)
sage: A = matrix(QQ,[[3,-2, 5, 4],
[6,-4, 4, 3],
[9,-6, 3, 2]])
sage: b = vector(QQ,[2,3,4])
# A particular solution:
sage: X = A.solve_right(b)
# Rows of the matrix B0 form basis of the space
# of solutions of the homogeneous system:
sage: B0 = A.right_kernel_matrix()
sage: show((X, B0))
sage: # Verification of the results:
sage: A*X==b, A*B0.transpose()==zero_matrix(QQ,3,2)
(True, True)
\(\;\)
Hence, the general solution of the system consists of the vecors of the form