What is a Compound?
In chemistry, a compound has a precise meaning: it is something composed of multiple different elements that cannot be separated without breaking chemical bonds, and it has a precise formula describing exactly what is in it. For example, regular tap water is not a chemical compound, but pure water is; each molecule of pure water consists of exactly two hydrogen atoms and one oxygen atom. While most water will have a number of other things mixed in, pure water will be only hydrogen and oxygen in that 2:1 ratio, generally written at H2O.
Of course, two samples of a substance may not be identical even though they have the same formula, since they may contain differing amounts of energy; for example, consider one same of water in liquid form, one frozen into ice, and one heated into steam: all three are still H2O!
The Empirical Formula
If we're interested only in what elements make up a compound, and in what ratios, then we look at the empirical formula. The empirical formula for an element simply lists the elements that make it up, reduced to lowest terms.
For example, consider vinegar, which is essentially diluted acetic acid. One molecule of acetic acid contains two carbon atoms, four hydrogen atoms, and two oxygen atoms, or C2H4O2; reducing this to lowest terms, we get the empirical formula of CH2O.
The Molecular Formula
On the other hand, we generally aren't satisfied just knowing what's in something; we also want to know exactly how the elements are arranged. Looking back at our acetic acid example, we can't make an element of acetic acid with just one carbon atom, two hydrogen atoms, and one oxygen atom, even though that's all we see in the empirical formula; every molecule has twice as many of each. Incidentally, this is why different compounds can have the same empirical formula; while they contain different numbers of molecules in different arrangements, if the elements and their ratios are the same, the empirical formula will be the same as well).
The molecular formula, on the other hand, describes how the compound is put together. The molecular formula for acetic acid is
CH3COOH; notice that these are the same atoms we had before, but now we're specifying how they are arranged. In this case, we have two carbon atoms connected to each other; one is also bonded to three hydrogen atoms, while the other has a double bond to an oxygen atom and a single bond to an OH group. An OH pair is called a hydroxyl functional group; when this attaches to a carbon atom, you get an alcohol. Thus, by knowing the chemical structure of the compound, we understand more about its properties.
Converting Between Formulas
Converting the molecular formula of a compound to the empirical formula is easy: just group all the atoms of each element, then reduce to lowest terms. How to determine the molecular formula from the empirical formula, on the other hand, is a little trickier!
Because more than one compound can have the same empirical formula, we need more information before we can do the conversion. There is a very important number that comes up over and over in chemistry: the mole. Also known as Avogadro's Number, it's used to do calculations on atoms or molecules without having to deal with ridiculously large numbers. One mole is equal to 6.022 x 1023 atoms or molecules. In other words, there are 602,200,000,000,000,000,000,000 atoms or molecules in one mole!
Where does that number come from? It was defined so that given one mole of a substance, its mass in grams is equal to its molecular weight. As of 2011, IUPAC (the International Union of Pure and Applied Chemistry) defines one mole to be exactly the number of atoms in 12 grams of carbon-12.
If we know the empirical formula of a compound, as well as the mass percentage, we can calculate the molecular formula. What that means is that we analyze the compound to find out what percentage, by mass, is made up of each element. Continuing with our example, we know that the atomic mass of carbon is 12.00, the mass of hydrogen is 1.008, and the mass of oxygen is 15.999. Adding these up, we find that one mole of CH2O weighs approximately 30.02 grams.
Now we take one mole of acetic acid and find out that it weighs approximately 60.03 grams. Dividing 60.03 by 30.02 and rounding, we get an answer of two, which tells us that we need to double the number of atoms in the empirical formula, giving us C2H4O2. Notice that due to measuring error, the numbers will generally not be exact! Because we know that carbon atoms prefer four bonds, oxygen atoms prefer two, and hydrogen atoms prefer one each, we're able to determine the molecular structure of the compound, CH3COOH.
References & Resources
William Springer was once a science teacher, before returning to school for a PhD.
The image showing the molecular structure of acetic acid is in the public domain.