Skip to content
AI360Xpert
Beta

Algebra: Solving for Unknowns in ML

Algebra is arithmetic with a placeholder: name the unknown, write what you know as an equation, and undo operations until the placeholder stands alone. Every solved hyperparameter works this way.

A balance scale holds 3x plus 7 against 22, and subtracting 7 then dividing by 3 from both pans leaves x alone at 5 with the beam level
A balance scale holds 3x plus 7 against 22, and subtracting 7 then dividing by 3 from both pans leaves x alone at 5 with the beam level

Why Does This Exist?

Formulas answer forward questions: given the inputs, what is the output? Practice asks backward questions: given the output I want, what input gets it? What learning rate halves the loss in ten epochs? What threshold gives 90% recall? What batch fills the GPU? Each one is an equation with the answer hiding inside, and algebra is the extraction tool.

The move is always the same: isolate the unknown by undoing operations, then verify by substitution. Master it once and every rearranged formula, from solving for a learning rate to inverting a normalisation, is the same loop. Systems of such equations get their own machinery in linear systems and least squares; rates of change built on top live in derivatives and partial derivatives.

The one idea you need first. An equation is a balanced scale: the two sides are equal now and must stay equal after every move. Anything done to one side must be done to the other. That single rule is the whole sport.

Think of It Like This

A balance scale with parcels

A scale holds a parcel labelled 3x+73x + 7 against a 2222kg weight, beam level. You want the parcel labelled xx alone. Remove 7kg from both pans: the scale stays level, reading 3x3x against 1515. Split both pans into 3 equal piles and keep one pile from each: xx against 55. The beam never tilted because every move touched both sides identically.

Substitution is re-weighing. Put 55 back where xx was: 3×5+7=223 \times 5 + 7 = 22, level again. If it tilts, the solution is wrong, no matter how tidy the steps looked.

Where it stops: real scales have friction and parcels have packaging. Equations are exact, so a solution either balances perfectly or it is not a solution. There is no close enough.

How It Actually Works

A variable is a named unknown, usually xx. An equation states two expressions are equal. A solution is the value making that statement true. Solving means applying inverse operations to both sides until the variable stands alone: subtraction undoes addition, division undoes multiplication, roots undo powers.

Worked example: two isolations and two checks

First: 3x+7=223x + 7 = 22. Subtract 7 from both sides: 3x=153x = 15. Divide both sides by 3: x=5x = 5. Check by substitution: 3×5+7=15+7=223 \times 5 + 7 = 15 + 7 = 22. It balances, so x=5x = 5 is the solution.

Second, with brackets: 2(x−3)=102(x - 3) = 10. Divide both sides by 2 first, the outermost operation: x−3=5x - 3 = 5. Add 3 to both sides: x=8x = 8. Check: 2×(8−3)=2×5=102 \times (8 - 3) = 2 \times 5 = 10. Balances. Notice the order: undo the outermost operation first, working inward, which is precedence in reverse.

Code

def solve_linear(a: float, b: float, c: float) -> float:    # Solve a*x + b = c by undoing addition, then multiplication.    return (c - b) / a

x: float = solve_linear(3.0, 7.0, 22.0)print(x)  # -> 5.0print(3.0 * x + 7.0 == 22.0)  # -> True

The function is the worked example generalised: subtract the constant, divide the coefficient. The second print is the habit that matters, substitution as an assertion. Real solvers verify the same way, comparing residual against tolerance instead of equality.

Watch Out For

Dividing by the variable and deleting a solution

Solving x2=3xx^2 = 3x by dividing both sides by xx gives x=3x = 3 and quietly deletes x=0x = 0, which also satisfies the equation. Division by an expression assumes it is nonzero, and when it is zero the step is both invalid and lossy.

Move everything to one side and factor instead: x2−3x=x(x−3)=0x^2 - 3x = x(x - 3) = 0, giving x=0x = 0 and x=3x = 3. Never divide by something containing the unknown.

Skipping the substitution check

Squaring both sides of x=−2\sqrt{x} = -2 gives x=4x = 4, which fails the original: 4=2\sqrt{4} = 2, not −2-2. Non-reversible steps manufacture imposters, and the algebra never apologises.

Substitute every solution back into the original equation, not the derived one. If it does not balance there, it is not a solution, however clean the steps.

The Quick Version

  • An equation is a scale: every move must touch both sides identically.
  • Isolate by undoing the outermost operation first, working inward.
  • 3x+7=223x + 7 = 22 gives x=5x = 5; 2(x−3)=102(x - 3) = 10 gives x=8x = 8.
  • Verify by substituting into the original equation, as an assertion, every time.
  • Never divide by the unknown; factor instead, or solutions vanish silently.