Math for AI course · Lesson 9 of 180
Equations for AI: One Prediction Can Fit Many Parameter Pairs
Learn to read equations as constraints, describe one- and two-variable solution sets, preserve them safely, and test model parameters in NumPy.
A toy prediction model returns
where the weight and bias are real numbers. For one observed example, the target is . Matching that target imposes the constraint
The pair works because . So do , , and . One target has not revealed one privileged parameter setting. It has selected the full parameter-pair solution set
That set is a line in the plane: every point on it makes the model predict exactly , and every point away from it misses the target. By the end of this lesson, you will be able to tell expressions, equations, constraints, and identities apart; describe all values that solve an equation; and recognize when an algebraic shortcut changes the solution set.
Learning outcome: Treat an equation as a constraint and describe all values satisfying it.
This lesson uses the domain discipline from Lesson 3: Domain, Codomain, and Valid Model Inputs: an equation’s solutions cannot be stated until its allowed values are known. The official Mathematics for Machine Learning companion organizes mathematical foundations as tools for understanding models and learning. Its Chapter 1 and Section 2.1 motivate the path from model parameters toward solution sets and later systems of linear equations. The single-equation bridge below is original; it stops before solving systems, Gaussian elimination, rank, or optimization.
An equals sign turns a calculation into a truth test
The symbols form an expression. Once and have values, the expression has a numerical value. It does not claim that the value is any particular number.
The symbols form an equation. They make a claim that can be true or false for a given assignment. With it is true; with it is false because .
These related terms do different jobs:
| Term | Example over the real numbers | What it tells us |
|---|---|---|
| Expression | A quantity to evaluate; it has no equals sign and no truth value | |
| Equation | A claim whose truth depends on and | |
| Constraint | Require | Only assignments satisfying the equation are feasible |
| Identity | True for every | |
| Solution | One assignment that makes the equation true | |
| Solution set | Every satisfying assignment, not just one example |
The difference between “equation” and “constraint” is its role. The same string is an equation as mathematical syntax and a constraint when it filters candidate parameters. “Identity” is stronger: does not filter any real at all.
One variable does not guarantee one answer
Consider the equation
Adding to both sides and then dividing both sides by the nonzero number gives
The double arrow means “if and only if.” Each step can be undone, so the real solution set is . Substitution checks the answer in the original equation: .
The number of written variables does not determine the number of solutions:
| Equation and stated domain | Solution set | Reason |
|---|---|---|
| , | Exactly one real value passes the truth test | |
| , | Subtracting gives the false statement | |
| , | Both sides are equal for every real | |
| , | Two real values square to | |
| , | Neither real solution is rational |
Here is the empty set, is the set of real numbers, and is the set of rational numbers. The last two rows use the same equation but different domains, so they answer different questions.
One target leaves a parameter family
Return to with . The notation means ordered pairs of real numbers. Isolate :
Nothing in that step fixes . Name its arbitrary real value ; then is forced to be . This produces every solution:
Why is the description complete? For every real , substitution gives , so every listed pair is a solution. Conversely, any pair that satisfies must satisfy ; setting puts that pair in the listed family. The two directions establish equality of the sets.
| Pair | Weight w | Bias b | 2w + b | Residual | Constraint verdict |
|---|---|---|---|---|---|
| Selected linked pair | 1 | 3 | 5 | 0 | Solution |
| Independent candidate | 1 | 2 | 4 | -1 | Not a solution |
| Reference pair A | 0 | 5 | 5 | 0 | Solution |
| Reference pair B | 2 | 1 | 5 | 0 | Solution |
The solid line, selected circle-with-cross, candidate diamond, written verdict, and table carry the same conclusion without depending on color. Moving the linked controls changes the parameter pair but never the prediction: an increase of in requires a decrease of in . Moving the candidate off the line produces a nonzero residual. One observation therefore establishes feasibility—it says which pairs fit—not which fitting pair should be preferred.
Reversible steps preserve every solution
Algebraic manipulation is safe when it produces an equivalent equation, not merely an equation that every old solution happens to satisfy. The distinction is the reverse direction.
Suppose and are defined for . For any expression defined on that same domain,
The forward step adds the same value to both sides. The reverse step subtracts that same value, recovering the original equation. Because both implications hold for every , the two equations have exactly the same solution set.
Similarly, for a fixed nonzero number ,
Multiplication by is reversible because division by is defined. The condition is part of the argument, not a technical footnote.
For the one-variable example, the reversible path can be read in both directions:
The labels below and above each arrow name inverse operations. A useful audit is simple: state the domain and ask how to undo every step for every candidate in that domain.
Four shortcuts can change the question
An operation may carry solutions forward without carrying all candidates back. Writing instead of keeps that one-way relationship honest.
Multiplying by zero erases information
Starting with and multiplying both sides by zero gives
The original solution set is ; the final identity is true for every real . There is no division by zero that can recover the original restriction.
Dividing by a variable can discard its zero case
Rewrite and factor as and then . The original real solutions are and . Dividing the original equation by silently assumes :
The division did not prove that zero was invalid; it removed zero from the domain of the transformed step. Separate the case before dividing by an expression that could vanish.
Squaring can introduce an extra candidate
The equation has solution set . Squaring both sides produces , whose real solution set is . Both sides of the first equation being equal guarantees their squares are equal, but equal squares do not guarantee equal original signs. Any candidate created after squaring must be checked in the original equation.
A principal square root can hide a negative solution
From , writing loses . Over the real numbers,
not for every . The complete step is , hence . Squaring and taking a principal root are not inverse operations on all real numbers; sign and domain conditions determine which direction is valid.
NumPy tolerance is a numerical policy, not symbolic equality
In algebra, a pair belongs to only when exactly. Software often
evaluates decimal approximations, so an implementation may adopt a separate
acceptance policy. NumPy’s official
isclose documentation
defines an element-wise tolerance test. With the target supplied as the
reference and relative tolerance set to zero, this lesson asks whether
The following executed example makes the two questions visible:
import numpy as np
np.set_printoptions(precision=13)
candidates = np.array([
[0.0, 5.0],
[0.0, 5.0000000000005],
[1.0, 2.999],
[2.0, 1.0],
])
target = 5.0
predictions = 2.0 * candidates[:, 0] + candidates[:, 1]
residuals = predictions - target
print(predictions)
print(residuals)
print(predictions == target)
print(np.isclose(predictions, target, rtol=0.0, atol=1e-12))
[5. 5.0000000000005 4.999 5. ]
[ 0.0000000000000e+00 5.0004445029117e-13 -9.9999999999945e-04
0.0000000000000e+00]
[ True False False True]
[ True True False True]
The first and fourth stored pairs produce a stored prediction equal to the stored target. The second does not, although its residual falls inside the chosen engineering tolerance. The third misses by about and fails both tests.
Neither Boolean mask proves an exact symbolic statement. == compares the
stored floating-point values, while isclose applies a deliberately selected
inequality. NumPy also documents that its general relative-tolerance formula
treats the second argument as the reference and that the default absolute
tolerance can be inappropriate for very small reference values. Naming the
tolerances makes the implementation rule reviewable; substituting a candidate
back into the original symbolic equation remains the mathematical check.
One observation tells us what fits, not what to choose
The parameter line exposes a practical limit before any training algorithm appears. The single observation “input coefficient , target ” supplies one restriction on two real parameters. It can reject , yet it cannot choose between and because both predictions are exactly .
Additional observations can impose additional constraints, and later lessons will ask how constraints interact. This lesson’s stopping point is earlier and more fundamental: write the domain, treat the equation as a truth condition, describe the entire satisfying set, and keep every transformation accountable to an inverse or an explicit candidate check. That habit is the foundation for reading the next lesson’s derivations line by line.
Check your understanding
Question 1
Classify each item as an expression, conditional equation, identity, solution, or solution set: 3q + 1; 3q + 1 = 7; 2(q + 4) = 2q + 8; q = 2; and {2}. Use the domain q ∈ ℝ.
Show the step-by-step solution
- is an expression: it has a value after is supplied but makes no equality claim.
- is a conditional equation: it is true for some real values and false for others. Used to filter , it is also a constraint.
- is an identity over . Expanding the left side gives for every real .
- states the solution after solving the conditional equation: .
- is the solution set. The braces describe the collection of every real solution, even though this collection has only one member.
The domain matters to the identity and solution-set statements; each classification above is made over .
Question 2
Solve 5x + 2 = 17 over the real numbers, show reversible steps, and state the solution set.
Show the step-by-step solution
Subtract from both sides:
This is reversible because adding recovers the first equation. Divide both sides by the nonzero number :
Multiplying by reverses that step. Check the candidate in the original equation:
Therefore the real solution set is .
Question 3
Describe every real pair (u, v) satisfying 3u + v = 7, then verify the pairs obtained at u = −1, 0, and 2.
Show the step-by-step solution
Isolate by subtracting from both sides:
Let stand for any real choice of . The complete solution set is
Now substitute the three requested values:
| Check | ||
|---|---|---|
Every row satisfies the equation, but the parameter ranges over all real numbers, so these three rows are examples rather than the whole set.
Question 4
A derivation changes 4(x − 3) = 20 into x − 3 = 5 and then x = 8. Explain why both steps preserve the real solution set, and check the result.
Show the step-by-step solution
First divide both sides by :
Because , multiplication by reverses this step. Next add to both sides:
Subtracting reverses the second step. Both arrows therefore work in both directions for every real candidate. Substitution checks the result:
The real solution set is .
Question 5
Find every real solution of z² = 3z. Then explain which solution is lost if both sides are divided by z immediately.
Show the step-by-step solution
Move all terms to one side and factor:
A product of real numbers is zero when at least one factor is zero, so
which gives or . Both check in the original equation: and . Thus .
Dividing by assumes and leaves . The step loses the valid solution because division by zero is undefined. The zero case must be separated before division.
Question 6
Solve √(x + 5) = x − 1 over the real numbers. Show how squaring creates a candidate that must be rejected.
Show the step-by-step solution
The square root requires . Its value is nonnegative, so equality also requires , or . Square both sides to generate candidates:
Move all terms to one side and factor:
The squared equation gives or . The second candidate violates the required condition and also fails the original equation: while . The first candidate checks:
Therefore the original real solution set is . Squaring preserved the true solution but introduced , so checking the original equation was essential.
Question 7
For 2w + b = 5, software computes a candidate prediction of 5 + 4 × 10⁻¹³. Is the pair an exact symbolic solution? Would np.isclose(prediction, 5, rtol=0, atol=10⁻¹²) accept it? Explain both answers.
Show the step-by-step solution
The exact residual stated in the prompt is
which is not zero. Therefore the pair is not an exact solution of the symbolic equation as stated.
For the NumPy policy, compare the absolute residual with the absolute
tolerance because rtol=0:
That inequality is true, so np.isclose returns True. The result means
“accepted under this tolerance,” not “proved symbolically equal.” If the
application requires a tighter or scale-dependent policy, its tolerances must
be chosen and documented accordingly.