If you have to write the chemical formula of a simple, binary ionic compound given the name of the compound, you follow a set of three steps. Let's go through them using magnesium chloride as an example. Write the symbols for the cation and the anion: Mg and Cl. Determine the charge on the cation and anion.