Hi
Flame Haze,
RED-HAIR-SHANKS,
maximR,
crazywing26 and
delsoo,
Most chemical equations in STPM/A-level are sufficiently simple that they could have been balanced by trial and error, but for more complicated chemical equations we will need a systematic method. There are various methods that can be used, but I will give one that uses Matrix theory.
To balance a chemical equation, we let x1, x2, x3, and x4 be positive integers that balance the equation

Equating the number of atoms of each type on the two sides yields
Hydrogen (H) :: 1 x1 = 3 x3
Chloride (Cl) :: 1 x1 = 1 x4
Sodium (Na) :: 3 x2 = 1 x4
Phosphorus (P) :: 1 x2 = 1 x3
Oxygen (O) :: 4 x2 = 4 x3
from which we obtain the homogeneous linear system

The augmented matrix for this system is

I leave it for you to show that the reduced row echelon form of the augmented matrix for this system is

from which we conclude that the general solution of the system is
x1 = t, x2 = t/3, x3 = t/3, x4 = t
where t is arbitrary. To obtain the smallest positive integers that balance the equation, we let t = 3, in which case we obtain x1 = 3, x2 = 1, x3 = 1, and x4 = 3. Substituting these values in the original problem produces the balanced equation