Math for AI course · Lesson 13 of 180
No solution, one solution, or many solutions
Learn to classify two-variable linear systems, connect each solution count to parameter identifiability, and handle contradictory or repeated data.
Three two-row datasets can make the same model behave in three radically different ways. Let the affine prediction rule be
where the real numbers and are the unknown weight and bias.
| Dataset | First observation | Second observation | Exact-fit result |
|---|---|---|---|
| A | One pair: | ||
| B | No pair: the same input demands two different outputs | ||
| C | Infinitely many pairs: the second row repeats the first |
Dataset A identifies both parameters. Dataset B contradicts the exact model. Dataset C adds a row but no new restriction. The number of rows alone cannot tell us how much information the data contain.
By the end of this lesson, you will be able to recognize inconsistent, unique, and underdetermined two-variable linear systems from equations and geometry; justify each classification without determinants or matrix rank; and explain what the result says about parameter identifiability.
Learning outcome: Recognize inconsistent, unique, and underdetermined systems.
This lesson builds on Lesson 12: Systems of Equations as Intersections, where one solution had to satisfy every constraint and appeared as a shared point. The official Mathematics for Machine Learning companion develops the no, one, or infinitely many classification in Sections 2.1 and 2.3. The datasets, derivations, code, explorer, and assessments here are original.
A solution count diagnoses the available information
Consider two equations in the real unknowns and . Each nondegenerate equation—one whose two left-side coefficients are not both zero—draws a line in the plane. The system’s solution set is the intersection of those lines.
The three possibilities are not a memorized catalog. They follow from the geometry of lines. Two nonparallel lines meet once. Distinct parallel lines never meet. If two lines share two different points, both pass through the one line determined by those points, so they coincide and share every point. Two linear equations in two variables therefore cannot have exactly two, three, or any other finite number greater than one of real solutions.
In machine-learning language, parameters are identifiable from the given observations when only one parameter setting fits them under the stated model. Identifiability depends on the information supplied by the constraints, not simply on how many rows were collected.
Elimination reveals a value, a contradiction, or an identity
The most direct classification test at this stage of the course is to combine the equations while preserving their shared solutions. Watch what the last line of the calculation says.
One solution leaves a value to substitute
Solve
\begin{aligned} 2u+v&=7, \tag{1}\\ u-v&=2. \tag{2} \end{aligned}Adding equations (1) and (2) removes :
Substitute into equation (2):
No solution ends in a contradiction
Now consider
\begin{aligned} u+2v&=4, \tag{3}\\ 2u+4v&=11. \tag{4} \end{aligned}Doubling equation (3) gives . Equation (4) demands that the identical left side equal . Subtracting twice equation (3) from equation (4) makes the conflict explicit:
No values of and can make true. The system is inconsistent, its two lines are parallel and distinct, and its solution set is . The calculation did not fail to find a hidden answer; it proved that no exact answer exists.
Infinitely many solutions end in an identity
Finally, take
\begin{aligned} 3u-v&=5, \tag{5}\\ -6u+2v&=-10. \tag{6} \end{aligned}Equation (6) is times equation (5). Adding twice equation (5) to equation (6) gives
The identity is true for every and ; it contributes no new restriction. It does not mean every pair solves the original system. One independent equation still remains. Choose any real number for , then equation (5) forces :
For every real ,
and multiplying this equality by verifies equation (6). The free choice of generates infinitely many solutions along the shared line.
Compare all three geometries in one parameter plane
The explorer keeps as one observation constraint, then changes what the remaining data demand. Choose a configuration with the native select. The lines transition between states unless the device requests reduced motion. Solid, dashed, and dotted patterns carry the same distinctions as color, and the captioned table states every conclusion without relying on the SVG or JavaScript.
Use the arrow keys to move through the options. The graph, status, and table update to the selected exact-fit problem.
The lines cross once at (w, b) = (2, 2), so both parameters are identifiable.
| Constraint | Equation | What it contributes |
|---|---|---|
| Constraint 1 (solid) | w + b = 4 | Defines the first set of parameter pairs that fit. |
| Constraint 2 (dashed) | 2w + b = 6 | Crosses the first line once and fixes both parameters. |
| Exact classification | Unique and consistent | |
| Solution set | {(2, 2)} | |
| Meaning for the model parameters | The observations identify weight w = 2 and bias b = 2. | |
The first server-rendered state is the unique system and , including its status, graph, and semantic table. Selecting the noisy case adds the three constraints created by observations , , and for the model . The first two select , but the third requires , which is false.
A coefficient test that does not divide by zero
For two nondegenerate equations
compare the coefficient pairs and . They are proportional when one is a real multiple of the other: there is a number such that
This formulation is safer than separately comparing and , because either denominator might be zero.
| Coefficient relationship | Right-side relationship | Geometry | Solutions |
|---|---|---|---|
| No multiplier matches both coefficients | Not needed | Nonparallel lines | Exactly one |
| Distinct parallel lines | None | ||
| The same line twice | Infinitely many |
The unique case means the two equations constrain different directions. The parallel cases have the same left-side pattern; scaling the first left side either reproduces the second right side or exposes a contradiction.
Zero coefficients remain ordinary data. The system
is simply and . A horizontal line and a vertical line meet at the unique point . Ratio tests that try to divide by are the problem; the zero coefficient is not.
If an entire left side is zero, the equation is degenerate and must be read directly:
| Degenerate equation | Meaning | Effect on a larger system |
|---|---|---|
| An identity true for every real pair | Adds no restriction | |
| A contradiction true for no real pair | Makes the complete system inconsistent |
For example, together with still leaves the infinite family . The identity does not upgrade one line into a unique point.
Identifiability asks what the observations add
Return to . Each observation becomes one parameter constraint
For observations and , the constraints are
Subtracting yields , so and . The different input values made the observations constrain the parameters differently.
Repeating one hundred times still writes one hundred times. The dataset has more rows, but the allowed parameter family remains . Those observations do not identify and separately.
If the repeated input carries two targets, such as and , the constraints become and . The exact affine model cannot satisfy both. This is an exact-fit diagnosis, not proof that the data are worthless. Measurement noise, rounded labels, or a model that is too simple can all make real observations inconsistent.
Later lessons will introduce rank as vocabulary for counting independent linear information. The present lesson needs only the visible test: do the constraints cross, conflict, or repeat?
NumPy separates exact solving from approximate fitting
The unique worked system can be written as an array equation. Each row of A
contains the coefficients multiplying , and each entry of c contains
the required right side:
import numpy as np
A = np.array([
[2.0, 1.0],
[1.0, -1.0],
])
c = np.array([7.0, 2.0])
solution = np.linalg.solve(A, c)
verified = np.allclose(A @ solution, c, rtol=0.0, atol=1e-12)
print("solution:", solution)
print("A @ solution:", A @ solution)
print("passes both equations:", verified)
# Three slightly inconsistent observations of y_hat = w*x + b.
x_observed = np.array([0.0, 1.0, 2.0])
y_observed = np.array([2.0, 4.0, 6.1])
design = np.column_stack((x_observed, np.ones_like(x_observed)))
approximate, _, _, _ = np.linalg.lstsq(design, y_observed, rcond=None)
predictions = design @ approximate
residuals = predictions - y_observed
print("approximate [w, b]:", np.round(approximate, 6))
print("predictions:", np.round(predictions, 6))
print("residuals:", np.round(residuals, 6))
print(
"all three exact:",
np.allclose(residuals, 0.0, rtol=0.0, atol=1e-12),
)
The verified output is:
solution: [3. 1.]
A @ solution: [7. 2.]
passes both equations: True
approximate [w, b]: [2.05 1.983333]
predictions: [1.983333 4.033333 6.083333]
residuals: [-0.016667 0.033333 -0.016667]
all three exact: False
The official numpy.linalg.solve
documentation
specifies an exact numerical solve for a square system with a unique solution;
it raises LinAlgError for a singular or nonsquare coefficient array. That
error alone cannot distinguish “no solution” from “infinitely many,” because
both parallel configurations fail the unique-solution requirement. Algebraic
classification must supply the meaning.
numpy.allclose
checks arrays within chosen tolerances. The code sets rtol=0.0 and an explicit
absolute tolerance because the reference residual is zero; NumPy warns that
its default absolute tolerance is not suitable for every small-number scale.
This numerical check supports the exact derivation but does not redefine
mathematical equality.
The noisy rows have no shared exact parameter pair, so the second calculation
asks a different question. numpy.linalg.lstsq
documentation
describes the returned vector as minimizing the Euclidean size of the residual
when an exact solution is unavailable. Its produces
small residuals, not zero residuals. Least squares will receive its own later
lesson; here it marks the boundary between solving every constraint and
approximating incompatible observations.
The next row should change the intersection
Classifying a system is ultimately a question about what each constraint adds. A crossing fixes a single point. A contradiction empties the solution set. A scaled repeat leaves a free choice. For an AI model, those outcomes translate to identifiable parameters, an impossible exact fit, or parameters the data cannot distinguish.
The next lesson will give vectors a formal role as representations of AI data. Keep the diagnostic from this lesson close: before trusting a recovered parameter, check whether the observations actually selected it uniquely.
Check your understanding
Question 1
Solve 2x + y = 8 and x − y = 1. Show why the system has exactly one solution and verify the point in both equations.
Show the step-by-step solution
Add the equations so that cancels:
Substitute into :
Now test in both originals:
The elimination fixed , substitution fixed , and the point passes both truth tests. The solution set is therefore exactly .
Question 2
Classify x + 3y = 5 and 2x + 6y = 13. Derive the decisive statement and interpret its geometry.
Show the step-by-step solution
Twice the first left side is . Subtract twice the first equation from the second:
The contradiction cannot hold for any real or . The coefficient pair is twice , but the right side is not twice . The lines are parallel and distinct, so the system is inconsistent and its solution set is .
Question 3
Find every solution of 4p − 2q = 6 and −2p + q = −3. Explain why 0 = 0 is not the final answer.
Show the step-by-step solution
Multiplying the second equation by gives
which is the first equation. Eliminating one with the other therefore yields , showing that the equations repeat the same restriction.
One restriction remains. Divide by :
Choose for any . Then every solution is
The identity diagnosed redundancy; the parameterized line, not the identity alone, is the complete infinite solution set.
Question 4
Without dividing by a zero coefficient, classify 0x + y = 4 and 3x + 0y = 9.
Show the step-by-step solution
Read the zero coefficients directly. The first equation is , a horizontal line. The second is , so division by the nonzero number gives , a vertical line.
Those lines meet once at . Verification gives
The system is consistent and unique. No ratio such as is needed.
Question 5
What happens to the system x + y = 2 if a second equation is (a) 0x + 0y = 0 or (b) 0x + 0y = 7? Give each solution set.
Show the step-by-step solution
For part (a), the second equation is , true for every real pair. It adds no restriction. The first line remains, so choose and obtain :
The system is consistent and underdetermined, with infinitely many solutions.
For part (b), the second equation is , false for every real pair. A solution would have to satisfy that contradiction as well as the first line, which is impossible. Therefore
and the system is inconsistent.
Question 6
The model ŷ = wx + b receives the observation (2, 7) fifty times. Are w and b identifiable? Parameterize every exact fit and explain what the repeated rows add.
Show the step-by-step solution
Every repeated observation produces the same constraint:
Choose the weight freely as . Then the bias must be
Thus all exact fits are
Fifty copies still draw one parameter line, so infinitely many pairs fit. The rows confirm the same observation but add no distinct restriction. Neither parameter is identifiable from this dataset alone.
Question 7
For observations (0, 2), (1, 4), and (2, 6.1) under ŷ = wx + b, prove there is no exact fit. Then explain what the NumPy least-squares output [2.05, 1.983333] does and does not claim.
Show the step-by-step solution
The first observation forces . The second then gives
The only pair satisfying the first two rows is . Test it on the third:
Therefore no parameter pair satisfies all three constraints exactly.
The least-squares output uses and . Its predictions are approximately , leaving residuals approximately . Those values are small but nonzero. The output minimizes a specified residual measure; it does not turn the inconsistent exact system into a consistent one or claim that every observation is matched exactly.