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. 1  Write the symbols for the cation and the anion: Mg and Cl. 2  Determine the charge on the cation and anion.