# Solutions to $x+y+z=31$ and $x+2y+3z=41$

For the equations $$x+y+z=31$$ $$x+2y+3z=41$$ is there a elegant way or method to find all the positive solutions in integers? Thus far, I have been using trial and error (which is time consuming). Another approach I tried was subtracting the first equation from the second to get $y+2z=10$. But I feel like there must be some faster way of doing this that I am not thinking of right now. Any input is appreciated.

• Can you use link .. gauss-jordan method. – Wmmoreno Oct 26 '13 at 0:23

No, I think the second approach you had is as quickly as this can be solved. Subtracting the first equation from the second gives $y + 2z = 10$, and the only possible ways that both $y$ and $z$ are positive integers is when $(y,z) = (8,1), (6,2), (4,3), (2,4)$. Plugging each set back into the first equation, we get that the four possible combinations for $(x,y,z)$ are $(22,8,1), (23,6,2), (24,4,3), (25,2,4)$.

Solve your two equations for "y" and "z". You obtain y = 52 - 2 x and z = x - 21. Since all "x", "y" and "z" must be positive you arrive to 21 < x < 26. So the only solutions correspond to x=22,23,24,25 from which you get the corresponding values of "y" and "z".

(31-y-z)+2y+3z = y+2z+31 = 41 Since y+2z=10 Hence y=a+2t, z=b-t Let a=10, b=0 Then x=31-(10+2t)-(-t)=-t+21 Thus x=-t+21, y=10+2t, z=-t

Since t=-1,-2,-3,-4 (10+2t>0, -t>0) t=-1 → x=22,y=8,z=1 Similary, (23,6,2), (24,4,3), (25,2,4)

the problem is that there are only two equations and 3 unknowns. This means there are an infinite number of solutions.

You can set any of x,y, and z to be anything at all you like that then solve for the other two. If I want y to be ... say 527 then I have x + z = -497 and x + 3z = -1013 so 2z = -517 so z = -517/2 and x = -377/2.

If you had a third equation and if the equations are "linearly independent" there will be exactly one solution.

Say... $x + y + z = 31$ and $x + 2y + 3z = 41$ and $2x + y + z = 40$.

There are three efficient ways to solve this:

i) Solve one variable in terms of the other and substitute:

Example: $x + y + z = 31$ so

$x = 31 - y - z$ so

$x + 2y + 3z = 41$ so 31 -y - z + 2y + 3z = 41$so$y + 2z = 10$so$y = 10-2z$so$2x + y + z = 40$so$2(31 - y - z) + (10 - 2z) + z = 40$so$2(31 - (10 - 2z) - z) + (10 - 2z) + z = 40$so$62 - 20 + 4z - 2z + 10 - 2z + z = 40$so$52 + z = 40$so$z = -12$so$y = 10 - 2z = 10 - 2(-12) = 34x = 31 - y - z = 31 - 34 + 12 = 9$Note: you could have solved x,y, z in any order. ii) combining equations to eliminate terms and simplify 1)$x + y + z = 31$2)$x + 2y + 3z = 41$3)$2x + y + z = 40$Subtract 1 from 2 and from 1 times 2: 1)$x + y + z = 31

2)$y+ 2z = 10$

3)$x = 9$

Subtract 3 from 1

1)$y + z = 22$

2)$y + 2z = 10$

3)$x = 9$

Subtract 1 from 2

1)$y + z = 22$

2)$z = -12$

3)$x = 9$

Subtract 2 from 1

1)$y = 34$

2)$z = -12$

3)$x = 9$

iii) Linear algebra and matrices. I won't go into those here.

=====

However if the are only two equations and 3 variables, you will never get only one solution. You will get an infinite system of solutions.

You can use the above ways to get:

$x + y + z = 31$

$x + 2y + 3z = 41$

=====

$x + y + z = 31$

$y + 2z = 10$

==

$x - z = 21$

$y + 2z = 10$

$2x + y = 52$

And that's as for as you can go. You set any of the 3 to anything you want and solve for the other 2, but there are an infinite number of solutions.

There are three ways to express the solutions:

$y = 52 - 2x; z = x - 21; x \in \mathbb Z$

or

$x = (52-y)/2; z = (10- y)/2; y \in \mathbb Z$

or

$x = z + 21; y = 10 - 2z; z \in \mathbb Z$

Those are three ways of saying the same thing.

Subtract the first equation from the second.

Express $y$ in terms of $z$

Now substitute into the first equation and you'll get and relation for $x$ with respect for $z$.

Because $z \in \mathbb{R}$ there are infinite amount of solutions and all of them are of a closed form, you'll obtain. And this is the fastest way to compute solution, maybe you were confused, because there are infinite amount of them.