Chemical formula (source code)

= Chemical formula
{wiki}

A <chemical formula> uses symbols of <chemical elements> and numerical subscripts to record composition. In the <molecular formula> $\mathrm H_2\mathrm O$ of <water>, the subscript $2$ counts two <hydrogen> <chemical atoms>, and the omitted subscript after $\mathrm O$ means one <oxygen> <chemical atom>. A <molecular formula> describes one <molecule>; a <chemical formula> need not describe a discrete <molecule>.

Read a preceding coefficient separately from the subscripts. One $\mathrm H_2\mathrm O$ contains two <hydrogen> and one <oxygen> <chemical atom>; $2\mathrm H_2\mathrm O$ contains four <hydrogen> and two <oxygen> <chemical atoms> distributed between two <water> <molecules>. In $\mathrm H_2\mathrm O_2$, the second subscript instead puts two <oxygen> <chemical atoms> into each <hydrogen peroxide> <molecule>. Thus $2\mathrm H_2\mathrm O\ne\mathrm H_2\mathrm O_2$: the coefficient scales the whole <chemical formula>, while a subscript specifies its composition. See https://openstax.org/books/chemistry-2e/pages/2-4-chemical-formulas[Flowers et al., Chemistry 2e, §2.4: chemical formulas].

\Image[/chemical-formula-and-coefficient.png]
{title=A coefficient counts whole <molecules>; a subscript counts <chemical atoms> within each <molecule>}
{description=The three columns show one <water> <molecule>, two <water> <molecules>, and one <hydrogen peroxide> <molecule>. Their <hydrogen> counts are $2,4,2$ and their <oxygen> counts are $1,2,2$. Connections are schematic $\mathrm{H-O-H}$ and $\mathrm{H-O-O-H}$, not models of actual <bond angles> or <bond lengths>.}

For crystalline $\mathrm{NaCl}$, the <chemical formula> specifies a $1:1$ ratio of <sodium> <ions> $\mathrm{Na}^+$ to <chlorine> <ions> $\mathrm{Cl}^-$. Its <formula unit> is the accounting entity; the ordinary crystal is an extended arrangement of <ions>, rather than a collection of discrete $\mathrm{NaCl}$ <molecules>. Specifying the entity matters when assigning an <amount of substance>. See <formula unit> and <Chemistry 2e by Paul Flowers and others/2.6 Ionic and Molecular Compounds> (§2.6: ionic and molecular compounds).

A <molecular formula> gives an atom inventory, not the full arrangement of <chemical bonds> or the <molecular geometry>. For example, $\mathrm C_6\mathrm H_{12}\mathrm O_6$ counts six <carbon>, twelve <hydrogen>, and six <oxygen> <chemical atoms> in a <glucose> <molecule>, but does not specify the pattern shown by its <Fischer projection>. Different structures can share a <molecular formula>. This compact inventory is useful for <chemical equation> accounting precisely because it leaves the structural detail to other representations.

The choice of letters has an early explanation in https://web2.lemoyne.edu/~giunta/berzelius.html[Jöns Jacob Berzelius, Essay on the Cause of Chemical Proportions (1813–1814), §III, transcribed by Carmen Giunta]: letters made chemical signs easier to write and print, and formulas compressed information about composition. His numerical notation differed from modern subscripts; the lasting idea was to make proportions readable in ordinary text.