Before generation
Use this diagnostic after learners can identify ions and need evidence about the formula-construction step. It calculates the smallest cation and anion counts that balance charge, adds parentheses around a repeated polyatomic ion, and compares the resulting formula with the response. This supports discussion of crossed subscripts, lowest ratios, and grouping. It does not infer charge from a name, select an oxidation state, name a compound, or establish that a proposed substance exists.
Worked example
The worked rows confirm CaCl2, Al2O3, (NH4)2SO4, and Mg3N2. The calcium hydroxide response CaOH2 uses the right total atom counts only if read incorrectly; the complete hydroxide ion must repeat, so the expected notation is Ca(OH)2. The evidence table displays the number of each ion, the positive and negative contribution, expected formula, entered formula, and a targeted notation review rather than silently replacing the response.
Formula or methodology
Let the cation charge magnitude be p and the anion charge magnitude be q. Divide both by gcd(p,q): cation count equals q/gcd(p,q), and anion count equals p/gcd(p,q). These counts make total positive charge equal total negative charge in the smallest whole-number ratio. A polyatomic fragment is enclosed in parentheses when its count exceeds one; a subscript of one is omitted.
How to interpret the result
A neutral lowest-ratio match means the response agrees with the supplied ion fragments, roles, and charge magnitudes. A reversed-order flag means the anion precedes the cation. Other mismatches require review of subscripts, greatest-common-factor reduction, parentheses, or copied ion data. Because the engine trusts the supplied ions, a matching formula can still be chemically wrong when an ion identity, oxidation state, or charge was entered incorrectly.
Common mistakes
Do not carry charge signs into ordinary formula subscripts, leave a reducible ratio such as Ca2O2, change subscripts already inside a polyatomic ion, omit parentheses around two or more polyatomic ions, place the anion first, or use prefixes from molecular naming. Write the verified ions with charges, find the least common charge total, count complete ions, remove only a common factor from the external ratio, and perform a final charge-balance check.