We want to find constants x1,x2,x3,x4 such that
x1H3PO4 + x2Mg(OH)2→x3Mg3(PO4)2 +x4H2O
is balanced. To turn this into a vector equation, we represent the molecules in the equation with the vectors in R4 :

We get
x1⎣⎢⎢⎢⎡3140⎦⎥⎥⎥⎤+x2⎣⎢⎢⎢⎡2021⎦⎥⎥⎥⎤=x3⎣⎢⎢⎢⎡0283⎦⎥⎥⎥⎤+x4⎣⎢⎢⎢⎡2010⎦⎥⎥⎥⎤
Moving all the terms to the left side and performing the linear combination of vectors, we get the homogeneous system
3x1+2x2–2x4=0
x1–2x3=0
4x1+2x2–8x3–x4=0
x2–3x3=0
Row reducing the corresponding coefficient matrix gives
⎣⎢⎢⎢⎡314020210−2−8−3−20−10⎦⎥⎥⎥⎤∼⎣⎢⎢⎢⎡100001000010−1/3−1/2−1/60⎦⎥⎥⎥⎤
We find that a vector equation for the solution space is
⎣⎢⎢⎢⎡x1x2x3x4⎦⎥⎥⎥⎤=t⎣⎢⎢⎢⎡1/31/21/61⎦⎥⎥⎥⎤, t∈R
To get the smallest positive integer values, we take t=6. This gives x1=2,x2=3,x3=1 and x4=6.Thus, a balanced chemical equation is
2H3PO4 + 3Mg(OH)2→Mg3(PO4)2 +6H2O