# How to solve a system of equations of eight variables

It is a long time since I have studied any maths and I am not even sure I will be able to phrase my question clearly so apologies in advance.

I am trying to understand how the author of the equations below (on a thread elsewhere about a MySQL query problem) got from the information below to one of the many potential solutions at the bottom.

Any pointers on where to look would be most helpful. My internet searches thus far have all taken me into discussions too deep for my understanding and, probably, needs. All of the values below will always be whole numbers greater than zero.

If it helps, the 600 and 400 totals represent genders and the other four are geographies. I need to know how to calculate the individual values, as there will usually be other criteria such as age group or education level, so the example here is probably a simple one.

Any help would be much appreciated, cheers.

X1+X2+X3+X4=600

X5+X6+X7+X8=400

X1+X5=100

X2+X6=200

X3+X7=300

X4+X8=400

Now solve for X1,X2, …X8 in the above. There are many solutions. Here is a solution:

X1=60, X2=120, X3=180,X4=240,X5=40,X6=80,X7=120,X8=160

=================

=================

1

=================

This system is under determined. In matrix notation that system becomes: (111100000000111110001000010001000010001000010001)(X1X2X3X4X5X6X7X8)=(600400100200300400).\left(
\begin{array}{cccccccc}
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\
1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 \\
\end{array}
\right)\left(
\begin{array}{c}
X_1 \\
X_2 \\
X_3 \\
X_4 \\
X_5 \\
X_6 \\
X_7 \\
X_8 \\
\end{array}
\right)=\left(
\begin{array}{c}
600 \\
400 \\
100 \\
200 \\
300 \\
400 \\
\end{array}
\right).
Solving this problem involves next to no algebra, since the equations are already decoupled very much.

One can easily solve the last four equations to eliminate four variables for example X5…X8X_5\dots X_8 just by bringing the X1…X4X_1\dots X_4 to the other side:
X5=100−X1,X6=200−X2,X7=300−X3,X8=400−X4.\begin{align}
X_5&=100-X_1,\\
X_6&=200-X_2,\\
X_7&=300-X_3,\\
X_8&=400-X_4.
\end{align}
If one plugs in those four solutions into the second equation it becomes equivalent to the first one, so it holds no new information. One can see this immediately from the coefficient matrix: the second row is just the sum of the last four rows minus the first row – it is not linear independent.

So the last thing we can do is eliminate one last variable using the first equation, for example X4X_4:
X4=600−X1−X2−X3.
X_4=600 – X_1 – X_2 – X_3.

So the best we can do with the equation system is:
X4=600−X1−X2−X3,X5=100−X1,X6=200−X2,X7=300−X3,X8=−200+X1+X2+X3.\begin{align}
X_4&=600 – X_1 – X_2 – X_3,\\
X_5&=100-X_1,\\
X_6&=200-X_2,\\
X_7&=300-X_3,\\
X_8&=-200+X_1 +X_2 +X_3.
\end{align}

One can choose any combination of X1X_1, X2X_2 and X3X_3, then compute X4…X8X_4\dots X_8 using the last 5 equations above and one has a solution of the system.

Thanks for the response, I am afraid I didn’t realise that the example was as structured as it was. I need to go away and try to work out how to phrase my question properly. In the meantime, I will use your answer to try and get my maths head working.
– Eirikr
2 days ago