How to solve a system of equations of eight variables

2k Views Asked by At

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

There are 1 best solutions below

1
On

This system is under determined. In matrix notation that system becomes: $$\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 $X_5\dots X_8$ just by bringing the $X_1\dots X_4$ to the other side: \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 $X_4$: $$ X_4=600 - X_1 - X_2 - X_3. $$ So the best we can do with the equation system is: \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 $X_1$, $X_2$ and $X_3$, then compute $X_4\dots X_8$ using the last 5 equations above and one has a solution of the system.