Chemical Formula
A chemical formula uses element symbols and subscripts to show which elements are in a substance and how many atoms of each.
Definition
A chemical formula is a short code that tells you which atoms are in a substance and how many, using element symbols and small numbers. Each subscript gives the number of atoms of the element before it in one molecule or formula unit, parentheses group polyatomic ions, and a subscript after a parenthesis multiplies everything inside; the formula states the fixed ratio that defines a compound. Formulas come in several forms: the empirical formula gives the simplest whole-number ratio of atoms, the molecular formula gives the actual number of atoms per molecule, and the structural formula shows connectivity. Ionic compounds are written as empirical formula units because they form lattices rather than molecules, and the molecular formula is always an integer multiple of the empirical formula, determined from molar mass.
Example
$H_2O$ means $2$ hydrogen atoms and $1$ oxygen atom, and $CO_2$ means $1$ carbon atom and $2$ oxygen atoms. Calcium hydroxide is $Ca(OH)_2$, with $1$ calcium, $2$ oxygen, and $2$ hydrogen atoms, and glucose, $C_6H_{12}O_6$, has $24$ atoms total; a capital-lowercase pair like $Co$ is cobalt while $CO$ is carbon monoxide, so capitalization matters. Benzene has the empirical formula $CH$ and the molecular formula $C_6H_6$, and its molar mass of $78.11\text{ g/mol}$ is six times the empirical mass of $13.02\text{ g/mol}$; hydrogen peroxide is $HO$ empirically and $H_2O_2$ molecularly.
Key Insight
If there is no small number after a symbol, it means $1$, and nobody writes $H_2O_1$. The formula tells you the recipe, not the arrangement: $C_2H_6O$ is both ethanol (a drinkable alcohol) and dimethyl ether (a gas), so chemists sometimes need structural formulas to tell them apart. Combustion analysis converts a burned sample's $CO_2$ and $H_2O$ masses into moles of carbon and hydrogen and from there into an empirical formula, and that mass-to-formula pipeline was how nineteenth-century chemists worked out the composition of organic compounds before any spectroscopy existed.