# How to solve system of 4 equations with four unknowns?

I have got system of 4 equations as shown below and I am considering if there is any other method than brute force to solve them.

B + C + D = S1
A + C + D = S2
A + B + D = S3
A + B + C = S4


Values of S1-S4 are given:

S1 = 70
S2 = 75
S3 = 80
S4 = 75


I tried to to solve that, but always I have infinite equation what means to solve A I need B, to solve B I need C, to solve C I need D and to solve D I need.. A. I know the answer, but need the solution how to solve it. Answer:

A = 30
B = 25
C = 20
D = 25

-

## migrated from mathematica.stackexchange.comOct 22 '13 at 17:35

This question came from our site for users of Mathematica.

a) what exactly did you try? and, b) it is a very bad idea to use capital letters (or functions starting with capital letters), as they are reserved for system symbols. This is definitely the case for C, D. Use small letters instead. Also see mathematica.stackexchange.com/questions/18393/… –  gpap Oct 22 '13 at 15:39
Solve[{b + c + d == S1, a + c + d == S2, a + b + d == S3, a + b + c == S4}, {a, b, c, d}]?? –  belisarius Oct 22 '13 at 15:40
I tried to change the equations to other forms like A = S3 - S1 + C or A = S2 - C - D. I am thinking about on paper solution, without using any built-in functions. In this case it doesn't matter if I use capital or small letters. –  Kobra Oct 22 '13 at 15:49
@Kobra In that case, you want Mathematics, not this site. This is a site for users of Mathematica, a software. –  rm -rf Oct 22 '13 at 15:59
yep, voting to migrate –  belisarius Oct 22 '13 at 16:05

If you subtract the last from the third, you get $D-C=-1$ or $D=C-1$. Now you can substitute this into three equations and eliminate $D$. Similarly subtracting the first two allows you to eliminate $B$ You will then have two equations in two unknowns, and again can solve one equation for one unknown in terms of the other. This is a standard technique for simultaneous equations, which works very well with this set because of the structure.

-
Thank you so much! I did it! :) , A = (S4 + S3 + S2 - 2 * S1) / 3, B = A + S1 - S2, C = S4 - A - B, D = C + S3 - S4 –  Kobra Oct 22 '13 at 19:09

Use Gaussian elimination/method:

$$\left[\begin{array}{cccc|c} 1 & 1 & 1 & 0 & 75 \\[0.55ex] 1 & 1 & 0 & 1 & 80 \\[0.55ex] 1 & 0 & 1 & 1 & 75\\[0.55ex] 0 & 1 & 1 & 1 & 70 \end{array}\right]$$

You can multiply rows and add/subtract them from another row, which will not affect the solution. So you can subtract the first row from the second and the thirdrow and the matrix will become:

$$\left[\begin{array}{cccc|c} 1 & 1 & 1 & 0 & 75 \\[0.55ex] 0 & 0 & -1 & 1 & 5 \\[0.55ex] 0 & -1 & 0 & 1 & 0\\[0.55ex] 0 & 1 & 1 & 1 & 70 \end{array}\right]$$

Now add the third row to the fourth:

$$\left[\begin{array}{cccc|c} 1 & 1 & 1 & 0 & 75 \\[0.55ex] 0 & 0 & -1 & 1 & 5 \\[0.55ex] 0 & -1 & 0 & 1 & 0\\[0.55ex] 0 & 0 & 1 & 2 & 70 \end{array}\right]$$

And at last add the second row to the fourth row:

$$\left[\begin{array}{cccc|c} 1 & 1 & 1 & 0 & 75 \\[0.55ex] 0 & 0 & -1 & 1 & 5 \\[0.55ex] 0 & -1 & 0 & 1 & 0\\[0.55ex] 0 & 0 & 0 & 3 & 75 \end{array}\right]$$

Now from the last row we get that $3D = 75 \implies D=25$

From the third row we get that $D-B = 0 \implies D=B \implies B=25$

From the second row we get that $D-C = 5 \implies C=25-5 \implies C=20$

And from the first row we get that: $A+B+C = 75 \implies A=30$

-

B=D So use the first equation b+c+d=b+c+b=70 and the second a+c+d=75 and the third a+b+d=80 so b-c=5 (b+c+b+5) divided by 3 equals b and d (70+5) divided by 3 equals 25(b and d) 25-5=20(c) (a+c+b)-(b+c+b)=5(a-b) 25+5=30(a) a=30 b=25 c=20 d=25

-