Why is the ionic formula for sodium hydroxide, NaOH but magnesium hydroxide is Mg(OH)2 ?
In writing the formula for an ionic compound, you must consider a balance between the charge on the cation and the anion in the formula. In this case sodium ion, the cation has a charge of +1 and the hydroxide ion, the anion has a charge of -1, the combination of one each of the ions results in the neutral crystal, NaOH. in the case of magnesium, a Group 2A element, Mg cation is +2 and requires two -1 hydroxide ions to have electrostatically neutral crystal, Mg(OH)2.