<s>[INST] Completing squares with three variables. I want to complete the squares for this polynomial 
$2x^2+2y^2-z^2+2xy+3xz-4yz$
Is there any kind of easy and non-confusing way to solve it?
I’ve done this up until now:
$$2x^2+2y^2-z^2+2xy+3xz-4yz$$
$$2x^2+2xy+3xz-4yz+2y^2-z^2$$
$$2(x^2+xy+\frac{3}{2}xz)-4yz+2y^2-z^2$$
$$2(x^2+x(y+\frac{3}{2}z))-4yz+2y^2-z^2$$
$$2(x^2+x(y+\frac{3}{2}z))+(\frac{1}{2}(y+\frac{3}{2}z))^2-(\frac{1}{2}(y+\frac{3}{2}z))^2-4yz+2y^2-z^2$$
Then things get kinda messy from here and I get totally lost from then on, could anyone help me out factoring this? And telling me if there is an eaay and non-confusing way to solve it? 
 [/INST] If you mean writing polynomial as the sum of squares, here is one solution:
$p=2x^2+2y^2-z^2+2xy+3xz-4yz$
polynomial p can be written as following forms:
$p=(x+y)^2+(x+z)^2+(y-2z)^2-5z^2+xz$
$p=(x+y)^2 +(x+2z)^2+(y-2z)^2-5z^2 -xz$
Summing these relations and dividing the result by 2 we get:
$p= (x+y)^2 +\frac{1}{2}(x+z)^2+\frac{1}{2}(x+2z)^2 +(y-2z)^2 -(5^{1/2}z)^2$
</s>