Both empirical and molecular formula give information about what different elements make up a compound. The empirical formula shows the simplest whole number ratio of the number of atoms of different elements present in a compound. However, the molecular formula shows the total number of atoms of each elements in a compound.
For example, the alkane butane has a molecular formula of C4H10. One molecule of Butane contains 4 Carbon atoms and 10 Hydrogen atoms. However, the empirical formula of Butane is C2H5. The simplest whole number ratio between the ratio 4:10 is 2:5.Sometimes, for certain molecules, the molecular formula may also be the same formula as the empirical formula. Taking water as an example which has a molecular formula of H2O. The simplest whole number ratio of the number of atoms of different elements in one molecule of water is still 2:1.