Smallest whole-number balance of a reaction equation in elements and charge, version 1.0.3
rxn-balance-equation@1.0.3: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.
What this page can and cannot show
Level: Checked against a reference; the species and sides as written; the smallest whole-number balance, where exactly one exists. Reference kind: our own exact-arithmetic script and a hand-worked case.
Not fully recorded, and not independently reviewed. Items marked "Not recorded" are missing from this project's records for the version named. Apart from any worked example shown, the cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed these methods or checks.
Every version of this method · Every method · What the levels mean
Version 1.0.3
Level: Checked against a reference; the species and sides as written; the smallest whole-number balance, where exactly one exists. Reference kind: our own exact-arithmetic script and a hand-worked case. rxn-balance-equation@1.0.3
Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.
Verification statement: the species as written, on the sides written; the smallest whole-number balance in elements and charge, where exactly one exists
The coefficients are the null vector of the element-and-charge matrix, as smallest whole numbers, where the matrix admits exactly one balance and it has every species on the side written; otherwise refused with the reason. The decision ladder, the smallest whole numbers and the charge row are the record's conventions: the Green Book (4th edition abridged, §4.10 note 13) says their values depend on how the equation is written. The formulas are read for counts and charge only; no molar mass is formed, so formula-reading's molar-mass guard is not reached. With only the zero solution and no element on one side only, `speciesNotTakingPart` is absent. The order of notes carries no meaning.
- How results are reported: none: coefficients are exact whole numbers with greatest common divisor 1
- Uncertainty: Exact integer and rational arithmetic on the formulas as written; nothing is measured.
- Reference, as its record states it: exact arithmetic in a Python program, cross-checked against chempy 0.10.2; a second implementation in Python by a separate agent of the same model family
- Computes through:
formula-reading@1.0.2 - Level confirmed by this project's ruling of 25 November 2026
What this page can and cannot show
What was checked
93 cases in 2 files, linked by this exact version.
Run through the tool at build against our own exact-arithmetic script and a hand-worked case: 64 agree within the tolerance the file states, 29 refuse as the case expects, 0 differ, 0 were not run.
File 1, 36 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-10
- Reference: Python standard library decimal and fractions, Python 3.13.18; licence PSF-2.0
- Tolerance as the file states it: coefficients and counts exact; statuses, codes and species exact
File 2, 57 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-14
- Reference: second implementation (Python 3.13), 2026-11-14; licence BSD-3-Clause
- Tolerance as the file states it: coefficients and counts exact; statuses, codes and species exact
Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.
What was not checked
That the species react, that the equation is the reaction that occurs, or that the products are right. Independent balances 0 to 3 are tested exactly; 4 or more are refused BALANCES_ABOVE_RANGE without a test of positivity. speciesNotTakingPart is not claimed to list every species forced to zero. A formula starting with a digit (13C3H8) is refused FORMULA_INVALID since 1.0.3, through formula-mass 1.3.0, with no case in this method's fixtures; the refusal is covered by stored reference values and unit tests only.
Definition or model
A closed form: the result follows from the inputs by the equations alone.
Equations
Equation 1
A[e][s] = +count_e(s) for a reactant, −count_e(s) for a product, for every element e and a last row of charges
a balance is ν > 0 with A·ν = 0
| Symbol | Meaning and unit |
|---|---|
| A | element-and-charge matrix |
| ν | stoichiometric coefficients |
Source: IUPAC, Quantities, Units and Symbols in Physical Chemistry (the IUPAC Green Book), 4th edition, abridged version, eds. Brett CMA, Frey JG, Hinde R, Kuroda Y, Marquardt R, Pavese F, Quack M, Stohner J, Thor AJ, RSC Publishing 2023, p. 45, section §4.10, note 13: a general chemical equation 0 = Σ_j ν_j B_j, ν_j the stoichiometric number of species B_j, negative for reactants and positive for products; here ν is its magnitude and the sign is carried by the rows of A, and a balance in each element and in charge is the record's reading of the equation, labelled so, 4th edition, abridged version (2023): IUPAC's online PDF release of March 2025 (122 pages; PDF created 26 October 2023), not the RSC e-book of record; read in full on 2026-11-24 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 31e11316dcce. Free to read (free PDF from IUPAC; © IUPAC 2023, reproduction beyond fair dealing needs permission (definitions used, not text)), checked 2026-11-17. No erratum found (searched IUPAC's Green Book page (iupac.org/what-we-do/books/greenbook/) as retrieved 17 November 2026: no erratum listed for the 4th edition, crossref (10.1039/9781839163180): no update or erratum relation, web search for errata to the 4th edition, abridged), 2026-11-17.
Equation 2
Definition: linear algebra: the dimension of the null space of A, the number of independent balances; the record's construction.
d = number of species − rank(A), by exact Gauss–Jordan elimination over rationals
| Symbol | Meaning and unit |
|---|---|
| d | independent balances |
Equation 3
Definition: the record's decision ladder and its smallest-whole-number convention; the Green Book, 4th edition abridged, §4.10 note 13 p. 45 gives the signs of stoichiometric numbers and says their values depend on how the reaction equation is written (N2 + 3 H2 = 2 NH3 and its halves), and §4.10.1(iii) p. 47 that redox equations are often balanced with integer stoichiometric numbers or per one exchanged electron (SF-F14); those pages read on 24 November 2026.
an element on one side only: refused EQUATION_IMPOSSIBLE
d = 0: refused EQUATION_IMPOSSIBLE
d = 1: the null vector, if all of one sign and none zero, scaled to the smallest whole numbers, else refused EQUATION_IMPOSSIBLE
d = 2 or 3: refused EQUATION_UNDERDETERMINED if a strictly positive null vector exists (exact Fourier–Motzkin, each verdict checked by its certificate), else EQUATION_IMPOSSIBLE
d of 4 or more: refused BALANCES_ABOVE_RANGE
| Symbol | Meaning and unit |
|---|---|
| d | independent balances |
Constants
Constants: none used.
Worked example
Worked example: one case of rxn-balance-equation@1.0.3, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- reactants[0].formula = C3H8
- reactants[1].formula = O2
- products[0].formula = CO2
- products[1].formula = H2O
Steps
- d = 1, from reactants[0].formula, reactants[1].formula, products[0].formula, products[1].formula; by equation 2.
- a = 1, from d; by equation 3; gives reactants[0].coefficient.
- c = 3, from a; by equation 1; gives products[0].coefficient.
- dH2O = 4, from a; by equation 1; gives products[1].coefficient.
- b = 5, from c, dH2O; by equation 1; gives reactants[1].coefficient.
The working, as the case writes it:
C 3 = 3·1
H 8 = 2·4
O 2·5 = 2·3 + 4: (1, 5, 3, 4), gcd 1
Answer
reactants[0].coefficient= 1products[0].coefficient= 3products[1].coefficient= 4reactants[1].coefficient= 5
Where these values came from: our own exact-arithmetic script and a hand-worked case; exact: d = 1, null vector ['1/4', '5/4', '3/4', '1']; cross-check chempy.balance_stoichiometry: {'C3H8': 1, 'O2': 5} -> {'CO2': 3, 'H2O': 4}.
At build the tool returned this answer within the tolerance the file states: coefficients and counts exact; statuses, codes and species exact.
Who worked this case: not recorded.
What it refuses, and its input ranges
EQUATION_IMPOSSIBLE: no balance has every species taking part on the side written: an element on one side only, only the zero solution, a single balance with a zero or mixed-sign coefficient, or two or three independent balances none of which is strictly positive Next: Check each species and the side it is on; leave out or move a species that cannot take part.EQUATION_UNDERDETERMINED: the species admit two or three independent balances in elements and charge and at least one has every species taking part, so no one balance is chosen Next: Split the equation into the separate reactions it describes, or leave out a by-product; this tool does not choose among balances.BALANCES_ABOVE_RANGE: No element is on one side only, and the species admit four or more independent balances in elements and charge (number of species minus the rank of the element-and-charge matrix is 4 or more). Next: Split the species list into the separate reactions it describes.DUPLICATE_SPECIES(invalid input): the same formula, as written, appears more than once among the reactants and productsFORMULA_IS_SMILES(invalid input): a formula reads as a SMILES (= # @ / \ or a lower-case letter not after an upper-case one); for a structure, molecule_descriptorsFORMULA_INVALID(invalid input): the formula cannot be read exactly as written: it is an electron; it writes a charge of zero; the formula-mass parser refuses it (an unknown symbol or one without a standard atomic weight, an ambiguous charge such as Fe3+, an unclosed bracket, a number before the formula such as 13CH4); it holds a count of zero; a count or the charge is above 2^53 − 1; or its molar-mass sum is too large to hold exactly (the shared routine formula-reading)
Flags and notes a reply may carry
A note a reply may carry:
ASCII_DOT_ADDUCT: An ASCII dot between digits was read as an adduct (a hydrate written with a dot is read as the salt with its water); write · for an adduct. Decimal counts are not accepted: check the formula as read.
Changes
2026-11-25-rxn-balance-equation@1.0.3-1
2026-11-25 · rxn-balance-equation@1.0.3 · Corrections to our methods
- What was wrong: A number written before a species' formula was read as a multiplier, so another species was balanced. Propane and oxygen written C3H8 + 13O2 → CO2 + H2O were read as O26 and balanced as 13 C3H8 + 5 O26 → 39 CO2 + 52 H2O, where the equation as meant is C3H8 + 5 O2 → 3 CO2 + 4 H2O.
- Affected: rxn_balance_equation at rxn-balance-equation 1.0.2 and earlier, only where a reactant or product formula starts with a digit. Every other output is unchanged.
- What changed: In 1.0.3, through formula-mass 1.3.0, a formula starting with a digit is now refused (FORMULA_INVALID); every other output is unchanged, and every pinned output hash is the same.
- How it was found: A review of the formula reader's grammar on 24 November 2026 found that no rule or test documented a number at the start of a formula, while the shared reader (formula-mass) applied the adduct multiplier to the first part as well; the scientific review ruled the same day that such a formula is refused. A sweep of the tools' worked examples with 13 written before each formula argument, before and after the fix, found which tools computed on it.
- Cases added: None in the fixtures: no published case starts a formula with a digit, and every pinned output hash is unchanged. The refusal is covered by the formula reader's hand cases and unit tests; the widened sweep records each tool's reply before and after.
Tools that use it
Cite this version
Smallest whole-number balance of a reaction equation in elements and charge. Drybench; rxn-balance-equation@1.0.3; https://www.drybench.com/methods/m/rxn-balance-equation/1.0.3 (accessed [date]).