Good to see you again. Previously, you used matrix multiplication to apply a common coefficient vector to many observations:
That same multiplication also expresses a system of linear equations. The difference is in what is unknown: instead of knowing the coefficients and producing predictions, we may know a target vector and need to solve for the unknown vector that produces it.
In this lesson, you will solve a small system by Gaussian elimination, interpret the possible outcomes, and connect a singular coefficient matrix to exactly redundant model features. This is a useful bridge to regression: when features contain exact duplicate information, there may be no unique set of coefficients to estimate.
Plan for roughly 40–45 minutes, including two short videos.
A linear system in matrix form
A linear equation contains unknowns only to the first power and does not multiply unknowns together. For example,
is linear; and are not.
A system collects several linear constraints. Consider
We can write it compactly as
where
The roles are worth keeping distinct:
- Each row of encodes one equation or constraint.
- Each column of gives the coefficients of one unknown across all equations.
- is the vector we want to find.
- contains the known right-hand-side values.
In a predictive-model setting, can represent unknown model coefficients. A system such as asks: which coefficient vector exactly satisfies these constraints?
Inverse matrices, column space and null space | Chapter 7, Essence of linear algebra
Watch “Inverse matrices, column space and null space” by 3Blue1Brown for the geometric meaning of solving A\mathbf{x}=\mathbf{b}, especially what changes when a transformation collapses information.
Start with matrix form, where systems are turned into one matrix-vector equation and interpreted as finding an input that maps to a target. Then skip to singular case. Focus on the key distinction: when the transformation collapses a dimension, an inverse does not exist, yet a particular target may still have solutions.
For now, treat an inverse as a useful idea rather than a computational method. If a square matrix has an inverse, then the system has one unique solution:
In practice, numerical software solves the system directly rather than explicitly calculating .
Solving a small system by Gaussian elimination
The practical hand method is Gaussian elimination. First, replace the system with its augmented matrix: write the coefficient matrix and append the right-hand-side vector after a vertical divider.
The divider has no mathematical effect; it is a bookkeeping device separating coefficients from constants.
Gaussian elimination uses row operations that preserve the system’s solution set:
- Swap two rows.
- Multiply a row by a nonzero constant.
- Add a multiple of one row to another row.
The aim is to create zeros below successive leading entries, producing an upper-triangular form that can be solved from the bottom upward.
Gaussian Elimination & Row Echelon Form
Watch “Gaussian Elimination & Row Echelon Form” by The Organic Chemistry Tutor for a complete worked three-variable solve. It demonstrates the workflow you will use immediately below: build an augmented matrix, eliminate entries below pivots, then back-substitute.
Watch continuously from matrix setup, where coefficients and constants are placed in the augmented matrix. Continue through row elimination, focusing on how each row operation produces zeros below a leading entry. Finish with back substitution, where the triangular system is translated back into values for the unknowns.
Now solve our system. Use the first row to eliminate the -terms below it:
This gives
It is convenient to swap rows 2 and 3, putting the leading in the second row:
Next, eliminate the below the second-row leading entry:
This corresponds to the simpler system
Now work upward.
From the last equation,
Substitute this into the second equation:
Finally, substitute and into the first equation:
Therefore,
A fast verification is to multiply the original matrix by the proposed solution:
The product matches , so the solution is correct.
Three possible outcomes
Elimination does more than calculate values. It reveals the structure of the system. A linear system can have only one of three outcomes:
| Outcome | What elimination reveals |
|---|---|
| One unique solution | A leading entry ultimately determines every unknown. |
| Infinitely many solutions | At least one unknown is free because a row reduces to all zeros. |
| No solution | A contradiction appears, such as . |
The distinction between the last two outcomes matters for singular matrices.
Consider the coefficient matrix
Its second row is exactly twice its first row. Thus it does not provide two independent constraints.
First choose
The system is
Eliminate the second row:
The second equation adds no information. We have only
Let , where can be any real number. Then
So there are infinitely many solutions:
Now keep the same , but use a different target:
Elimination gives
The last row says
This is impossible, so the system has no solution.
A square matrix is singular when it has no inverse. The example matrix is singular because it collapses one independent direction: its two rows and its two columns contain redundant information.
The crucial conclusion is:
A singular coefficient matrix does not automatically mean “no solution.” It means there cannot be exactly one solution for every possible . Depending on , the system has either infinitely many solutions or no solution.

Redundant features create non-unique coefficients
Now connect singularity to a regression design matrix.
Suppose a data pipeline creates two numerical features for every trial workspace:
- : active days during the first week;
- : an “activity points” feature defined as exactly twice active days.
By construction,
A design matrix with an intercept and these two features might look like
The third column is exactly twice the second. It contributes no new independent information.
If a linear model is
then, since ,
Only the combined quantity
affects predictions. There is no way for the data alone to decide how much of that combined effect belongs to and how much belongs to .
More formally, for any number , changing coefficients as follows leaves every prediction unchanged:
Indeed,
So the model has infinitely many coefficient vectors that make identical predictions. The coefficient-estimation problem is not uniquely solvable.
This is exact multicollinearity or feature redundancy. Common sources include:
- a duplicated feature column;
- one feature coded as an exact constant multiple of another;
- a total and all of its mutually exclusive parts included together;
- an intercept plus one indicator column for every category of a categorical variable.
For example, if each workspace belongs to exactly one plan type, then
If the model already has an intercept column of ones, including all three plan indicators creates an exact linear dependency. The usual solution is to keep the intercept and omit one category indicator as the reference category.
Do not confuse exact multicollinearity with two features being merely highly correlated:
- Exact redundancy: one column is an exact linear combination of others. The relevant matrix is structurally singular.
- High but imperfect correlation: columns are not identical combinations, so a unique solution may exist, but coefficient estimates can be unstable.
Neither condition is causal confounding. These are algebraic properties of the features you supplied to a model; causal confounding concerns how treatment, outcome, and other variables are generated and related.
Solving in NumPy
For a small square, nonsingular system, use np.linalg.solve. It solves directly.
import numpy as np
A = np.array([
[1.0, 1.0, 1.0],
[2.0, -1.0, 1.0],
[1.0, 2.0, -1.0],
])
b = np.array([6.0, 3.0, 2.0])
x = np.linalg.solve(A, b)
print(x) # [1. 2. 3.]
print(np.allclose(A @ x, b)) # True
Avoid the less direct pattern below:
# Avoid this as a default approach
x = np.linalg.inv(A) @ b
Computing an inverse is unnecessary when the task is to solve one system, and it is generally less numerically appropriate.
For an exactly singular matrix, np.linalg.solve raises a LinAlgError because there is no unique solution:
A_singular = np.array([
[1.0, 1.0],
[2.0, 2.0],
])
b = np.array([3.0, 6.0])
np.linalg.solve(A_singular, b)
That error should trigger investigation of the matrix construction and feature definitions. It should not automatically be “fixed” by selecting an arbitrary coefficient solution: the underlying question is whether the model specification contains redundant information.
Real datasets also bring floating-point rounding and near-redundant features, which are more subtle than the exact examples here. The next lesson introduces rank as the systematic language for diagnosing exact linear dependence.
Key takeaways
A system of linear equations can be written as
Gaussian elimination transforms its augmented matrix using solution-preserving row operations, then uses back-substitution to recover unknowns.
A system has exactly one outcome:
- one unique solution;
- infinitely many solutions;
- no solution.
For a square matrix, singular means “not invertible.” Singularity reflects lost independent information. A singular system can have infinitely many solutions when its constraints are compatible, or no solution when they are contradictory.
In a predictive model, exact redundant feature columns mean that multiple coefficient vectors produce exactly the same predictions. This makes separate coefficients non-identifiable, even when predictions themselves may be unchanged.
Next, you will use matrix rank to detect these missing independent directions directly in a design matrix.