from sympy import Matrix, symbols
= symbols("a b c")
a,b,c = Matrix([[1,2,1,3],[2,4,0,2],[3,6,-1,1]])
A = Matrix.hstack(A,Matrix([a,b,c])) # finds the augmented matrix
B # finds the echelon form B.echelon_form()
5 Systems of Linear Equations
Systems of linear equations form the cornerstone of linear algebra. They emerge naturally in mathematics, physics, engineering, and data science whenever we need to describe multiple linear relationships simultaneously.
5.1 Equivalent Representations
A key observation in linear algebra is that we can represent the same system in three different ways. Each representation offers unique advantages. Consider:
As a Vector Equation
Here, we view the system as a sum of scaled vectors:
As a Matrix Equation
Here, we package all coefficients into a single matrix:
The vector equation representation offers a geometric interpretation of linear systems. When we write the system as a vector equation, we’re asking whether a target vector can be obtained as a linear combination of given vectors. This connects systems of equations directly to fundamental concepts of linear algebra: linear combinations and spanning sets. We can visualize the solution process as asking whether the target vector lies in the span of our coefficient vectors, and if so, how we can reach it through scaling and adding these vectors.
Matrix equations package the coefficients efficiently. They are particularly useful in the square case, where the coefficient matrix is
These three representations—systems of equations, vector equations, and matrix equations—each illuminate different aspects of linear systems. Fluency in moving between these representations and understanding their connections is important for both theoretical understanding and practical problem-solving.
5.2 Characterization of the Solution Set
A fundamental result of linear algebra is that every system of linear equations must have exactly one of these three outcomes:
- No solution exists (inconsistent system)
- Exactly one solution exists (unique solution)
- Infinitely many solutions exist
Let’s visualize each case in
Case 1: No Solution
This system has no solution because:
- The vectors
and span only a line - The target vector
lies off this line - No combination of the vectors can reach the target
Case 2: Unique Solution
This system has exactly one solution:
Case 3: Infinite Solutions
This system has infinitely many solutions because:
- The vectors are parallel (one is a multiple of the other)
- The target vector lies on their shared line
- Solutions:
for any real
5.3 Solution Methods
In Algebra 1 (typically 8th or 9th grade), students learn three approaches:
- Graphing (limited to
) - Substitution
- Elimination
Let’s examine the algebraic methods using this system:
Substitution Method
Choose a variable and solve for it:
Substitute into the other equation:
Back-substitute:
Elimination Method
Set up the aligned system:
Multiply second equation by -2:
Add equations:
Back-substitute:
While both methods work, elimination systematically transforms the system into an “upper triangular” form, making solutions easier to find. Consider this upper triangular system:
From this form, we can easily find all solutions:
- Substituting
in the second equation, we get is free (can be any real number)- Susbtituting
and in the first equation, we get
The general solution is:
This represents all solutions, with
5.4 Gauss Elimination
The elimination method discussed previously naturally extends to a systematic algorithm known as Gaussian Elimination. This algorithm formalizes and generalizes the process of using row operations to transform a system of equations into “upper triangular” form, also called echelon form. The key insight is that through a careful sequence of row operations (adding multiples of one equation to another, swapping equations, or multiplying an equation by a nonzero scalar), we can systematically create zeros below the diagonal, one column at a time.
When a system is in echelon form, the pattern of coefficients forms a “staircase” shape, making it significantly easier to find solutions through back-substitution. This systematic approach works for systems of any size, making it a fundamental tool in linear algebra. The detailed algorithm and its implementation are presented in the accompanying slide presentation.
Why does Gaussian Elimination work?
The mathematical foundation of Gaussian elimination lies in matrix multiplication: each row operation is equivalent to left multiplication by an invertible matrix. The following theorem shows why these operations preserve the solution set of the original system.
Theorem 5.1 Let
is a solution of the system is a solution of the system
Proof. The equivalence follows because
- If
, then multiplying both sides by gives - Conversely, if
, then multiplying both sides by gives .
Each elementary row operation corresponds to multiplication by a specific type of invertible matrix:
- Row swap
: Multiply by a permutation matrix that differs from the identity matrix only in rows and , where the 1’s are swapped. The inverse is itself since swapping twice returns to the original - Row scaling
: Multiply by diagonal matrix with in position , 1’s elsewhere. The inverse multiplies row by - Row addition
: Multiply by the matrix that differs from the identity only in position where there is a . This adds times row to row . The inverse has in position , which subtracts times row from row
Therefore, if we perform a sequence of row operations to transform
This also explains why we use the augmented matrices. Notice that
5.5 Homogeneous Systems
A linear system
- Exactly one solution:
- Infinitely many solutions
This dichotomy follows because if a homogeneous system has any nonzero solution
Solving Homogeneous Systems
To solve a homogeneous system, we reduce
In row echelon form, a free column is any column that does not contain a pivot. When solving the system, variables corresponding to free columns can take any value, while the other variables are determined by these choices. Each free column thus generates a dimension of solutions.
Consider the system:
Row reduction gives:
Notice that columns 2 and 4 are free because they have no pivots. Using back substitution, we that the solution of the reduced system is:
is free , is free, and .
Writing all values in terms of
Since
Connection Between Solutions and Column Dependencies
Solutions to homogeneous systems reveal linear dependencies among the columns of the coefficient matrix. Consider:
where
We just saw that the general solution to
Each basic solution reveals a column dependency (Equation 3.1):
- Setting
gives solution . This means: - Setting
gives solution . This means:
These relationships, which can be easily verified by replacing the values of the columns, show that free columns (
Homogeneous Systems: Dependence and Independence
The previous example illustrates important principles that we expand in this section. Let
- If
solves , then is also a solution for any , giving infinitely many solutions. - From Equation 3.1,
solves if and only if
- When any
, we can solve for , expressing as a linear combination of the other columns: Conversely, if we can write in terms of the other columns, there exist constants such that Then subtracting from both sides, we obtain and we obtain a non-zero solution of the homogeneous system because the coefficient of is 1.
The following two theorems capture these important relations:
Theorem 5.2 Suppose that
- The homogeneous system
has infintely many solutions - The homogeneous system
has a non-zero solution - We can write a column of
as a linear combination of the other columns - The row reduced Echelon form of
has a free column
Theorem 5.3 Suppose that
- The homogeneous system
has a unique solution - Let
. If , then - Let
. If , then - We cannot write any column of
as a linear combination of the other columns - The row reduced Echelon form of
doesn’t have any free columns
Condition 3 of Theorem 5.3 motivates the following definition
Definition 5.1 Suppose that
Notice that
is linearly independent if and only if we cannot write any of these vectors as a linear combination of the other ones. However, checking this requires solving vector equations. From a computational point of view, the statement in the definition is much more practical. We only solve one vector equation. We look at:
and we solve it. If the only solution is , the set is linearly independent.
If
5.6 Linear Systems and the Span of Columns
Let
- Given
, when does have at least one solution? - If
has a solution, when is that solution unique? - Under what conditions does
have solutions for every
Let’s start with existence. Suppose that
Therefore,
Theorem 5.4 Let
has a solution can be written as a linear combination of the columns of
Let’s examine some examples. Consider:
First, let’s solve
This system has solutions. Using back substitution:
is free is free
The general solution is:
This example illustrates the following
Theorem 5.5 Let
has a unique solution- The matrix
, the reduced row echelon form of , has a pivot position in every column. - The matrix
, the reduced row echelon form of , does not have a free column.
Now consider
This system has no solution since the last equation becomes:
For the general case, let echelon_form()
method that finds the row echelon form and not the row reduced echelon form.
The last equation is:
The last two examples illustrate the following
Theorem 5.6 Let
has a solution for every . has a pivot position in every row. does not have a zero row.- Every
can be written as a linear combination of the columns of
The last condition motivates the following definition
Definition 5.2 Suppose that
5.7 Finding Inverses
Let
Suppose now that
- A pivot in every row
- a pivot in every column, because
has an equal number of rows and columns - No free columns
This leads to a key result:
Theorem: If
This gives us an algorithm to find
- Form the augmented matrix
- Row reduce to get
for some matrix - Then
We’ll explore this algorithm in detail during the lab.
5.7.1 Writing Invertible Matrices as Products of Elementary Matrices
Let
To illustrate, consider the case where
- Start with
- Multiply from the left by
: - Multiply from the left by
: - Multiply from the left by
: - Finally multiply from the left by
: