Linear Systems
A linear system asks for unknown numbers that satisfy linear equations.
For example:
The solution is x = 3, y = 2.
The same system can be written as a matrix equation:
Here, A contains the coefficients, x contains the unknowns, and b contains
the target values.
There is another useful way to read the same equation:
Can the columns of A, with weights from x, make the target b?
If:
then:
The input vector x gives the weights. The columns of A are the available
directions. The output is what those weighted directions reach.
Three Outcomes
A linear system can have:
- one solution
- no solution
- infinitely many solutions
Geometry explains why. Two lines may cross once, never cross, or be the same line.
The column reading gives the same three outcomes:
- one solution: there is exactly one way to combine the columns to reach
b - no solution: no combination reaches
b - infinitely many solutions: many different combinations reach the same
b
In higher dimensions, the picture is harder to draw, but the question is the same.
The number of equations alone does not decide the outcome. What matters is the geometry of the columns and the target. A system with two equations can fail if the target points outside the column space. A system with many unknowns can have many solutions if different inputs produce the same output.
Shape Check
If A has shape m x n, then:
xmust have lengthnbmust have lengthm
The input length matches the number of columns. The output length matches the number of rows.
Why ML Cares
Many ML computations are not solved as exact linear systems, but the language is everywhere.
A model asks whether a set of weights can map inputs to targets. A projection asks for the closest reachable point. A least-squares fit asks for the best approximate solution when an exact one may not exist.
Solve:
What is x?
Compute it first, then check your number.
Hint
Add the two equations.
Solution
Adding gives (x + y) + (x - y) = 5 + 1, so the y terms cancel and
2x = 6. Therefore x = 3, and substituting back gives y = 2.
Let:
What is Ax?
Compute it first, then check your number.
Hint
The identity matrix keeps the two weights as the two output coordinates.
Solution
The first column gets weight 4, and the second column gets weight -3, so
Ax = [4, -3].
A matrix A has shape 3 x 2. The equation is Ax = b.
How long must b be?
Compute it first, then check your number.
Hint
The output length is the number of rows of A.
Solution
A has 3 rows, so Ax has length 3. Therefore b must also have length 3.
Suppose the only available columns are:
Can any combination of these columns reach [0, 1]?
Answer it first, then check.
Hint
Look at the second coordinate of every possible combination.
Solution
No. Both columns have second coordinate 0, so every combination also has
second coordinate 0. The target [0, 1] cannot be reached.
Enter 1 if a system can have many solutions because different inputs produce
the same target output.
Compute it first, then check your number.
Hint
Ask whether the matrix might send some nonzero input direction to zero.
Solution
Enter 1. If some input direction has no effect on the output, then adding
that direction to one solution can produce another solution with the same
target.
Before Moving On
Read Ax = b as a reachability question: can the matrix A produce the target
b from some input x?