Brief
Balancing a chemical equation means choosing how many of each molecule to use so that every atom is accounted for. In this project you turn that puzzle into a matrix and let elimination solve it.
Write the unknown coefficients as . Each element gives one equation. For propane burning, carbon says , hydrogen says , oxygen says . Move everything to one side and you have a linear system : one row per element, one column per molecule, with product columns negated.
You solve it with Gaussian elimination. Pick a pivot in the first column, subtract multiples of its row to clear the entries below, then move to the next column. Swap rows whenever the pivot would be zero. At the end, any column without a pivot holds a free variable. With one free variable there is a single family of answers: set it to 1, solve for the rest, and scale to whole numbers. That family is the null space of , which you met in BM-03 as the set of inputs a matrix squashes to zero.
DATA · 50 equations you collect
Objectives
Read-only. Log in to update progress.
VICTORY CONDITIONS
- All 50 equations balanced with the same coefficients as SymPy nullspace, recorded with `python tools/mlarena.py record BM-04 "50/50 match"`.
- Every answer satisfies A·x = 0 exactly, with positive whole-number coefficients that share no common factor.
- Equations that cannot be balanced, or have more than one independent answer, are reported clearly instead of printed as if they worked.
Side quests
Terms in plain words
- Linear system
- A set of equations where every unknown appears only multiplied by a number, written as Ax = b. Here b is all zeros.
- Gaussian elimination
- Subtract multiples of one row from the others until the matrix has zeros below a staircase of leading entries.
- Pivot
- The leading non-zero entry in a row that you use to clear its column. Pivoting means swapping rows so the pivot is not zero (or, with floats, is the largest available).
- Reduced row echelon form
- The end of elimination where every pivot is 1 and is the only non-zero entry in its column, so you can read the answer straight off.
- Free variable
- An unknown whose column has no pivot. You may pick its value freely; every other unknown then follows from it.