# Completing the square

1. Dec 14, 2011

### Ted123

How do I complete the square for: $$x^2 + 2y^2 + 2z^2 + 4xy +4xz + 4yz$$
I can do it for a normal quadratic $ax^2 + bx + c$ but how do I do it for something like this with more than one variable?

2. Dec 14, 2011

### SammyS

Staff Emeritus
I doubt that there is one particular "correct" result for this.

Notice that this polynomial does contain a perfect square for two of the variables, y & z: $2y^2+4yz+2z^2=2(y+z)^2\,.$

Factor 4x out of the two remaining "mixed" terms.
$x^2+4x(y+z)+2(y+z)^2$​
I see two ways to finish. You can figure out how many terms of (y+z)2 to add & subtract, or you can figure out how many terms of x2 to add & subtract. The latter way gives a simpler looking answer.

3. Dec 14, 2011

### Ted123

I've got it equal to the sum of squares: $$2(x+y+z)^2 - x^2$$ What does this mean the rank and signature is? There is 1 positive square and 1 negative square so is the rank 1+1=2 and the signature 1-1=0?

4. Dec 14, 2011

### Ray Vickson

You can apply (essentially) the algorithm that leads to Cholesky factorization of a matrix. In your example, start by looking at the x-terms, which are $x^2 + 4xz + 4yz .$ These are what you would get if you looked at $(x+2y+2z)^2,$ because that is where you would get terms of the form 4xy and 4xz. Anyway, we have $$x^2 + 4xy + 4xz = (x+2y + 2z)^2 - 4y^2 - 4z^2 - 8yz,$$, so your function f(x,y,z) is
$$(x+2y+2z)^2 -2y^2 - 2z^2 -4yz.$$ Now $$2y^2+2z^2+4yz = 2(y+z)^2,$$
so we finally have $$f(x,y,z) = (x+2y+2z)^2-2(y+z)^2.$$

RGV

5. Dec 14, 2011

### Ted123

So is the rank 2 and the signature 0?