How the Chemistry Equation Balancer Balances
AnyTool Chemistry Equation Balancer treats balancing as a linear-algebra problem solved entirely in the browser. It parses each species into a map of element → atom count, then builds the element-composition matrix: one column per species, one row per element (plus a charge row if any species is charged), with reactant counts positive and product counts negative. A valid coefficient set is a non-trivial vector in the null space of this matrix. The engine finds it with exact rational Gauss-Jordan elimination using BigInt fractions — never floating point — then multiplies through by the lowest common multiple of the denominators and divides by the greatest common divisor to give the smallest positive integer coefficients. Because the arithmetic is exact, the answer is always the correct textbook balance, and a per-element table verifies that reactant atoms equal product atoms.
- Element-composition matrix: species as columns, elements as rows
- Reactants positive, products negative; optional charge row
- Balancing = null space of the matrix (non-trivial solution)
- Exact rational (BigInt fraction) Gauss-Jordan — no float error
- Scaled to smallest positive integers via LCM then GCD
