# A system of equations

Given three equations $x^2+y^2+xy=a$, $y^2+z^2+yz=b$ and $x^2+z^2+xz=c$, how can I solve for $x,y$ and $z$ in terms of $a,b$ and $c$?

-

If we multiply second equation by $-1$ and add to first we have:

$x^2+y^2+xy-y^2-z^2-yz=(x+y+z)(x-z)=a-b$

Next do the same with other equation:

$(x+y+z)(y-z)=a-c$

$(x+y+z)(y-x)=b-c$

Now if $a \neq c$ we can divide first by second and get:

$\frac{x-z}{y-z}=\frac{a-b}{a-c}$, so:

$(x-z)(a-c)=(a-b)(y-z)$. It's linear.

Next do the same with the other equations and we get a system of three linear equation which is easy to solve. There are also cases $a=c$, $a=b$ or $b=c$, but it's easier than in general case.

-
Thank you, much appreciated. I'd vote up if I could. –  jgailberg Jun 3 '14 at 20:35
It's a curious case. Actually what I get from your suggestion is not three distinct linear equations but only one and same which is $(a-c)x+(b-a)y+(c-b)z=0$ so I'm a little bit stuck again. –  jgailberg Jun 3 '14 at 23:09

Using the groebner function from sympy we get a somewhat unwieldy groebner basis, of which the last equation (out of 9) is:

$$a^4 - 4a^3b - 4a^3c + 3a^3z^2 + 6a^2b^2 + 10a^2bc - 12a^2bz^2 + 6a^2c^2 - 12a^2cz^2 + 9a^2z^4 - 4ab^3 - 8ab^2c + 15ab^2z^2 - 8abc^2 + 9abcz^2 - 9abz^4 - 4ac^3 + 15ac^2z^2 - 9acz^4 + b^4 + 2b^3c - 6b^3z^2 + 3b^2c^2 - 3b^2cz^2 + 9b^2z^4 + 2bc^3 - 3bc^2z^2 - 9bcz^4 + c^4 - 6c^3z^2 + 9c^2z^4=0$$

By inspection (or using the sympy .subs() method) we see that this equation is a fourth degree univariate polynomial equation in $z$ if $a,b,c$ are constant.

-
Thank you! I was hoping for a lot simpler solution but I guess your answer shows why it could not be found. –  jgailberg Jun 3 '14 at 20:21
No. What i wrote shows that it is solvable. See what agha wrote to see that it is easily solvable. –  Peter Sheldrick Jun 3 '14 at 20:23