Magnesium (Mg) has an atomic number of 12, and its electronic configuration is 2, 8, 2. This means that magnesium has two valence electrons in its outermost shell. To achieve a stable configuration, magnesium tends to lose these two electrons, resulting in a positive charge of 2+ (Mg²⁺).
Phosphorus (P) has an atomic number of 15, and its electronic configuration is 2, 8, 5. Phosphorus has five valence electrons in its outermost shell. To achieve a stable configuration, phosphorus tends to gain three electrons, resulting in a negative charge of 3- (P³⁻).
When magnesium and phosphorus atoms come together to form an ionic compound, the positively charged magnesium ions (Mg²⁺) and the negatively charged phosphorus ions (P³⁻) attract each other due to electrostatic forces. To maintain electrical neutrality, the ratio of magnesium and phosphorus ions in the compound must be such that the total positive charge of the magnesium ions is equal to the total negative charge of the phosphorus ions.
The simplest ratio of magnesium and phosphorus ions that achieves this electrical neutrality is 3:2. This means that for every three magnesium ions (3Mg²⁺), there are two phosphorus ions (2P³⁻). The formula of the ionic compound formed by magnesium and phosphorus atoms is, therefore, Mg₃P₂.
In summary, the formula of the ionic compound formed by magnesium and phosphorus atoms is Mg₃P₂, which represents three magnesium ions (Mg²⁺) combined with two phosphorus ions (P³⁻) to achieve electrical neutrality.