# Completing the Square - Multiple Variables

Completing the square of an expression with multiple variables is a technique which manipulates the expression into a perfect square plus some constant. As an example, \(x^2+2x+y^2-6y+z^2 - 8z + 1\) can be written in the complete square form as

\[(x+1)^2+(y-3)^2+(z-4)^2-25.\]

This technique is useful in factorizing an expression, dealing with the conic sections, and finding the maxima and minima of an expression.

#### Contents

## Introduction

Let us look at how \(x^2+y^2+z^2+2x-6y-8z + 1\) can be split into squares.

Firstly, notice that the expression does not have any product terms such as \(xy\) or \(yz\). This means that we could split this into squares of single variable polynomials, i.e. something like

\[(Ax + a)^2 + (By + b)^2 + (Cz + c)^2 + d^2 \]

The key in such cases is to complete the square for each variable separately and combine them.Let us deal with \(x, y\) and \(z\) separately as follows:

\[\begin{align} x^2 + 2x &= (x + 1)^2 - 1\\ y^2 - 6y &= (y - 3)^2 - 9\\ z^2 - 8z &= (z - 4)^2 - 16. \end{align}\]

Then, the original polynomial could be written as

\[\begin{align} x^2+y^2+z^2+2x-6y-8z + 1 &=\big((x + 1)^2 - 1 \big) + \big( (y - 3)^2 - 9 \big) + \big((z - 4)^2 - 16 \big) + 1 \\ &= (x+1)^2 + (y-3)^2 + (z-4)^2 - 25\\ &= (x+1)^2 + (y-3)^2 + (z-4)^2 - 5^2.\ _\square \end{align} \]

What if there are product terms? In that case, *we guess which variables need to be together in order to make the product term and manipulate accordingly*.

Express \(x^2 + 13y^2 + z^2 + 6 x y + 4 y z\) as a sum of squares.

Here the product terms contain \(xy\) and \(yz\). We could hope to possibly rewrite the polynomial as something like

\[(Ax + By + C)^2 + (Py + Qz + R)^2.\]

As for the terms with \(x\) and \(y\), we have

\[x^2 + 6 x y + 13 y^2 = (x + 3y)^2 + (2y)^2.\]

For the terms with \(y\) and \(z\), we have

\[13y^2 + 4 y z + z^2 = (z + 2y)^2 + (3y)^2.\]

Now, we add them up, and then subtract \(13y^2\) as we are double counting it, to write the original polynomial as

\[ \big( (x + 3y)^2 + (2y)^2 \big)+ \big((z + 2y)^2 + (3y)^2 \big) - 13y^2 = (x + 3y)^2 + (2y + z)^2.\ _\square \]

## Application - Factorization

Solve for \( x \) in \( ax^2 + bx + c = 0 \), where \( a, b, c \in \mathbb{R} \).

We can use completing the square method:

\[ x^2 + \dfrac{b}{a} x + \dfrac{c}{a} = 0. \]

What must we add so that we have a perfect square? \( \frac{b}{a}x = 2xz \) and a perfect square would be in the form \( x^2 + 2xz + z^2, \) so we need to find \( z \) and square it: \( z = \frac{b}{2a}\) and \(z^2 = \frac{b^2}{4a^2} \). We add \( z^2 \) to both sides:

\[\begin{align} x^2 + \dfrac{b}{a}x + \dfrac{b^2}{4a^2} + \dfrac{c}{a} &= \dfrac{b^2}{4a^2} \\ \left( x + \dfrac{b}{2a}\right)^2 &= \dfrac{-c}{a} + \dfrac{b^2}{4a^2} \\ \left( x + \dfrac{b}{2a} \right)^2 &= \dfrac{b^2 -4ac}{4a^2} \\ x + \dfrac{b}{2a} &= \pm \sqrt{\dfrac{b^2 - 4ac}{4a^2 }} \\&= \pm \dfrac{\sqrt{b^2 - 4ac}}{2a} \\ x &= \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a }.\ _\square \end{align}\]

Factor \( x^4 + x^2 y^2 + y^4 \).

This seems unfactorable, but we can make it factorable by adding and subtracting \( x^2 y^2: \)

\[\begin{align} x^4 + x^2 y^2 + y^4 &= x^4 + 2x^2 y^2 + y^4 - x^2 y^2 \\ &= \big(x^2 + y^2\big)^2 - x^2 y^2 &\qquad \text{(a perfect square)}\\ &= \big(x^2 + y^2 + xy\big)\big(x^2 + y^2 - xy\big).\ _\square &\qquad \text{(difference of two squares)} \end{align}\]

Factor \(x^4+4y^4\).

Again, we can complete the square by adding and subtracting the middle term \(4x^2y^2\):

\[\begin{align} x^4+4y^4&=x^4\color{red}{+4x^2y^2}+4y^4\color{red}{-4x^2y^2} \\ &=\big(x^2+2y^2\big)^2-4x^2y^2, \end{align}\]

which can be factored into

\[\big(x^2+2xy+2y^2\big)\big(x^2-2xy+2y^2\big),\]

which is best know as

Sophie Germain identity. \(_\square\)

## Application - Conic Sections

For a general conic \(ax^2+cy^2+dx+ey+f=0,\) we can complete the square to find all of its elements. Let's begin identifying the conics:

- When \(ac>0,\) we have an
**ellipse**(\(a\) and \(c\) have the same sign but \(a \neq c\)). - When \(a=c\) and \(a,c \neq 0,\) we have a
**circle**. - When \(ac<0,\) we have an
**hyperbola**(\(a\) and \(c\) have different signs). - When \(ac=0,\) we have a
**parabola**(only one of \(a\) and \(c\) is zero).

For each one, we have different forms and elements:

A

circlewith center at \(C=(h,k)\) and radius \(r\) has the equation\[(x-h)^2+(y-k)^2=r^2.\]

**Strategies for completing the square - Circles**:

- Move all terms containing \(x\) and \(y\) to one side, and the constant term (if there is) to the other side.
- Divide the equation by the coefficient of \(x\) and \(y\) if it's different from one.
- Complete the square in \(x\) and \(y\).
- Rearrange and identify its elements.

Identify all the elements of the conic \(x^2+y^2-6x+14y+42=0\).

Since the coefficients of \(x^2\) and \(y^2\) are both \(1,\) we have a circle, so we are looking for its center and radius. We move the constant term \(42\) to the other side:

\[x^2+y^2-6x+14y=\color{green}{-42}.\]

Now, we complete the square in \(x\) and \(y\):

\[x^2-6x+\color{red}{9}+y^2+14y+\color{blue}{49}=-42+\color{red}{9}+\color{blue}{49}.\]

Finally, we rearrange:

\[(x-3)^2+(y+7)^2=16.\]

Comparing with the equation of the circle, we find \(C=(3,-7)\) and \(r=\sqrt{16}=4\). \(_\square\)

An

ellipsewith center at \(C=(h,k)\), semi-major axis \(a,\) and semi-minor axis \(b\) has the equations below.

- Horizontal ellipse: \[\dfrac{(x-h)^2}{a^2}+\dfrac{(y-k)^2}{b^2}=1.\]
- Vertical ellipse: \[\dfrac{(y-k)^2}{a^2}+\dfrac{(x-h)^2}{b^2}=1.\]

**Strategies for completing the square - Ellipses**:

- Move all terms containing \(x\) and \(y\) to one side, and the constant term (if there is) to the other side.
- Factorize the \(x^2\) and the \(x\) term by common factor, using such factor as the coefficient of \(x^2\).
- Do the same with \(y^2\) and \(y\).
- Complete the square in \(x\) and \(y\).
- Simplify both sides.
- Divide both sides by the term in the right side.
- Simplify the fractions.
- Identify all the elements.

Identify all the elements of the conic \(9x^2+25y^2+36x-50y-164=0\).

Since the coefficients of \(x^2\) and \(y^2\) are different but have the same sign, we have an ellipse. First we move the constant term to the right side:

\[9x^2+25y^2+36x-50y=\color{green}{164}.\]

Next, we factorize the \(x^2\) and the \(x\) terms. We see that the coefficient of \(x^2\) is \(9\), so it will be the common factor. We will have to divide the coefficient of \(x\), which is \(36\) by \(9\). We also do the same with \(y^2\) and \(y\):

\[\color{red}{9(x^2+4x)}+\color{blue}{25(y^2-2y)}=164.\]

Now we complete the square, without forgetting to multiply the terms that we will add on the right side by \(9\) and \(25\):

\[9(x^2+4x+\color{red}{4})+25(y^2-2y+\color{blue}{1})=164+\color{red}{9(4)}+\color{blue}{25(1)}.\]

Simplify:

\[9(x+2)^2+25(y-1)^2=225.\]

Divide both sides by \(225\):

\[\dfrac{9(x+2)^2}{\color{green}{225}}+\dfrac{25(y-1)^2}{\color{green}{225}}=1.\]

Finally simplify the fractions to obtain the form of the equation of the ellipse:

\[\dfrac{(x+2)^2}{25}+\dfrac{(y-1)^2}{9}=1.\]

Since \(25>9,\) we have an horizontal ellipse with \(a=\sqrt{25}=5\), \(b=\sqrt{9}=3\) and center in \(C=(-2,1)\). \(_\square\)

A

hyperbolawith center at \(C=(h,k)\), semi-major axis \(a,\) and semi-minor axis \(b\) has the equations below.

- Horizontal hyperbola: \[\dfrac{(x-h)^2}{a^2}-\dfrac{(y-k)^2}{b^2}=1.\]
- Vertical hyperbola: \[\dfrac{(y-k)^2}{a^2}-\dfrac{(x-h)^2}{b^2}=1.\]

**Strategies for completing the square - Hyperbola**:

The steps are almost the same as those for the ellipse, but we have to be more careful with the signs.

Identify all elements of the conic \(7x^2-10y^2+70x+80y-55=0\).

Since the coefficients of \(x^2\) and \(y^2\) have different signs, we have an hyperbola. First we move the constant term to the right side:

\[7x^2-10y^2+70x+80y=\color{green}{55}.\]

Next, we factorize the \(x^2\) and the \(x\) terms. We see that the coefficient of \(x^2\) is \(7\), so it will be the common factor. We will have to divide the coefficient of \(x\), which is \(70,\) by \(7:\)

\[\color{red}{7(x^2+10x)}-10y^2+80y=55.\]

Do the same with \(y^2\) and \(y\). We see that the coefficient of \(y^2\) is \(-10\), so that will be the common factor. We will have to divide the coefficient of \(y\), which is \(80,\) by \(-10:\)

\[7(x^2+10x)\color{blue}{-10(y^2-8y)}=55.\]

Now we complete the square, without forgetting to multiply the terms that we will add on the right side by \(7\) and \(-10\):

\[7(x^2+10x+\color{red}{25})-10(y^2-8y+\color{blue}{16})=55\color{red}{+7(25)}\color{blue}{-10(16)}.\]

Simplify:

\[7(x+5)^2-10(y-4)^2=70.\]

Divide both sides by \(70\):

\[\dfrac{7(x+5)^2}{\color{green}{70}}-\dfrac{10(y-4)^2}{\color{green}{70}}=1.\]

Finally simplify the fractions to obtain the form of the equation of the hyperbola:

\[\dfrac{(x+5)^2}{10}-\dfrac{(y-4)^2}{7}=1.\]

We have an horizontal hyperbola with \(a=\sqrt{10}\), \(b=\sqrt{7},\) and center at \(C=(-5,4)\). \(_\square\)

A

parabolawith vertex at \(V=(h,k)\) and focal distance \(p\) has equations as follows:

Horizontal parabola: \((y-k)^2=4p(x-h)\)

If \(p>0,\) the parabola is directed to the right; if \(p<0,\) it's directed to the left.Vertical parabola: \((x-h)^2=4p(y-k)\)

If \(p>0,\) the parabola is directed upwards; if \(p<0,\) it's directed downwards.

**Strategies for completing the square - Parabola**:

- Identify the variable that is squared. Factorize it with the linear one by common factor, using such factor as the coefficient of the squared variable.
- Complete the square in the squared variable.
- Move the constant terms and the terms with the variable that is not squared, to the right side.
- Factorize the right side again using common factor, using such factor as the coefficient of the linear variable.
- Divide both sides by the coefficient of the squared binom on the left side.
- Identify all the elements.

Identify all elements of the conic \(3x^2-30x-20y+235=0\).

Since we have an \(x^2\) term but no \(y^2\) term, we have a parabola. First we will factorize the \(x^2\) and \(x\) terms. We see that the coefficient of \(x^2\) is \(3\), so it will be the common factor:

\[\color{red}{3(x^2-10x)}-20y+235=0.\]

Next, we will complete the square in \(x\), without forgetting to multiply the term that we will add on the right side by \(3\):

\[3(x^2-10x+\color{red}{25})-20y+235=\color{red}{3(25)}.\]

Next, we will move the \(y\) and the constant term to the other side, and simplify:

\[\begin{align} 3(x-5)^2&=\color{green}{20y-235}+\color{red}{75}\\ &=20y-160. \end{align}\]

Factorize the right side. We see that the coefficient of \(y\) is \(20\), so it will be the common factor:

\[3(x-5)^2=\color{blue}{20(y-8)}.\]

Divide both sides by \(3\):

\[(x-5)^2=\color{green}{\dfrac{20}{3}}(y-8).\]

We have a vertical parabola which opens upwards. It has vertex at \(V=(5,8)\) and its focal distance is \(4p=\frac{20}3 \implies p=\frac53\). \(_\square\)

## Application - Quadric Surfaces

We can also have **3-dimensional conic sections**, referred to as **quadric surfaces**.
Given an equation in terms of \( x, y,\) and \(z,\) we can use multi-variable completing the square to identify certain characteristics of these quadric surfaces.

An

ellipsoidhas the equation \( \dfrac{(x-h)^2}{a^2} + \dfrac{(y-k)^2}{b^2} + \dfrac{(z-l)^2}{c^2} = 1 \).

- All traces are
ellipses. (Atraceis the equation of intersection between a plane and the given surface.)- Its center is at \( (h, k, l ) \).
- If \( a = b = c\), then the ellipsoid is a sphere.
- Ellipsoids have 3 axes of symmetry: \( \left\{\begin{matrix} \begin{align} x&= h\\ y&=k\\ z&=t-l, \end{align} \end{matrix}\right. \) \( \left\{\begin{matrix} \begin{align} x&= h\\ y&=t-k\\ z&=l, \end{align} \end{matrix}\right. \) and \( \left\{\begin{matrix} \begin{align} x&= t-h\\ y&=k\\ z&=l. \end{align} \end{matrix}\right. \)

An

elliptic paraboloidhas the equation \( \dfrac{z-l}{c} = \dfrac{(x-h)^2}{a^2} + \dfrac{(y-k)^2}{b^2} \).

- The vertex of the elliptic paraboloid is at \( (h, k, l ) \). Conceptually, this is similar to the vertex-form of a parabola in 2D.
- Horizontal traces are ellipses, and vertical traces are parabolas.
- The axis of symmetry is \( \left\{\begin{matrix} \begin{align} x&= h\\ y&=k\\ z&=t-l. \end{align} \end{matrix}\right. \)

A

hyperbolic paraboloid, or commonly known as Pringles chip, has the equation \( \dfrac{z-l}{c} = \dfrac{(x-h)^2}{a^2} - \dfrac{(y-k)^2}{b^2} \).

The center of the hyperbolic paraboloid (in this case, the

saddle point, where the partial derivatives in all directions equal zero, but this point is neither a maximum nor a minimum) is \( (h, k, l) \).The axis of symmetry is \( \left\{\begin{matrix} \begin{align} x&= h\\ y&=k\\ z&=t-l. \end{align} \end{matrix}\right. \)

An

elliptical conehas the equation \( \dfrac{(z-l)^2}{c^2} = \dfrac{(x-h)^2}{a^2} + \dfrac{(y-k)^2}{b^2} \).

- The "center" is located at \( (h, k, l) \).
- Horizontal traces are ellipses, and vertical traces are hyperbolas or lines, depending on the equation of the plane.
- The axis of symmetry is \( \left\{\begin{matrix} \begin{align} x&= h\\ y&=k\\ z&=t-l. \end{align} \end{matrix}\right. \)

A

hyperboloid of one sheetlooks like a nuclear cooling tower and has the equation \( 1 = \dfrac{(x-h)^2}{a^2} + \dfrac{(y-k)^2}{b^2} - \dfrac{(z-l)^2}{c^2} \).

- The "center" is located at \( (h, k, l) \).
- Horizontal traces are ellipses, and vertical traces are hyperbolas.

A

hyperboloid of two sheetslooks like two mirrored elliptic paraboloids and has the equation \( 1 = -\dfrac{(x-h)^2}{a^2} - \dfrac{(y-k)^2}{b^2} + \dfrac{(z-l)^2}{c^2} \).

- The two sheets are "mirrored" around \( (h, k, l ) \).
- Horizontal traces when the plane is parallel to the \( z\)-axis are ellipses when the plane intersects one of the two sheets. Vertical traces are hyperbolas.

Identify the quadric surface and its elements:

\[ 4604 = 400x^2 - 800x + 225y^2 + 900y - 144z^2 - 1152 z. \]

We have

\[\begin{align} 4604 + 400 + 900 - 2304 &= 400x^2 - 800x + 400 + 225y^2 + 900y + 900 - 144z^2 - 1152z -2304 \\ 3600 &= 400(x-1)^2 + 225(y+2)^2 - 144(z+4)^2 \\ 1 &= \dfrac{(x-1)^2}{3^2} + \dfrac{(y+2)^2}{4^2} - \dfrac{(z+4)^2}{5^2}. \end{align}\]

We can see that the equation is a \( \boxed{\text{hyperboloid of one sheet}} \). Its center is at \( (1, -2, -4 ) \). Its axis of symmetry is \( \left\{\begin{matrix} \begin{align} x&= 1\\ y&=-2\\ z&=t+4.\ _\square \end{align} \end{matrix}\right.\)

## Applications - Extrema Values

When relating squares and inequality, one should be reminded of the trivial inequality:

For any real number \(x\), we have

\[x^2 \geq 0\]

and equality holds if and only if \(x=0\).

Let's look at a simple example.

For real numbers \(x\) and \(y\), what is the minimum value of \( z = x^2 -2x + y^2 + 4y? \)

In this expression we have to deal with two variables. It is hard at first how to approach or even predict the minimum value. Let's try reducing the number of terms by completing the square:

\[\begin{aligned} z &= x^2 -2x + y^2 + 4y \\ &= (x^2 -2x +1 ) - 1 + (y^2 + 4y +4) - 4 \\ &= (x -1 )^2 + (y +2)^2 - 5. \end{aligned}\]

The minimum value of a square is \(0\), and hence the minimum value of \(z\) is \(0+0-5=-5\) and the equality holds when \(x=1\) and \(y=-2\). \(_\square\)

Now, let's try a slightly more difficult question when there are more terms.

\[f(x,y,z)=2x^2+8y^2+9z^2+4xy-12yz+2x-6\]

The function above has a minimum value for real numbers \(x,y,z\). Find the minimum value, and state the ordered triplet \((x,y,z)\) where the minimum occurs.

Notice that there are product terms \(xy\) and \(yz\). We can try to factorize these first. Notice that \(y\) appears in both products and that \(x\) has a term by itself. Therefore, we can start by attempting to factorize \(z\). Notice that

\[\begin{align} 9z^2 &= (3z)^2\\ 12yz &= 2(3z)(2y). \end{align}\]

From here, we can see that we already have most of the required terms to complete the square. What we're missing is \((2y)^2=4y^2\), and we try to obtain the term:

\[\begin{aligned} f(x,y,z)&=2x^2\color{blue}{+8y^2}+9z^2+4xy-12yz+2x-6\\ &=2x^2+4xy+2x-6\color{blue}{+4y^2+4y^2} -12yz+9z^2\\ &=2x^2+4xy+2x-6+4y^2+(2y-3z)^2.\end{aligned}\]

Next, we try to do the same thing for \(xy\). Notice that

\[\begin{align} 4y^2&=(2y)^2\\ 4xy&=2(2y)(x). \end{align}\]

What we need is an \(x^2\):

\[\begin{aligned} f(x,y,z)&=\color{red}{2x^2}+4xy+2x-6+4y^2+(2y-3z)^2\\ &=2x-6\color{red}{+x^2+x^2}+4xy+4y^2+(2y-3z)^2\\ &=x^2+2x+1-1-6+(x+2y)^2+(2y-3z)^2\\ &=(x+1)^2+(x+2y)^2+(2y-3z)^2-7.\end{aligned}\]

All the variables have been placed in squares. Now, the function will be minimized if all 3 squares equal to \(0\). Therefore, we need to find out if we can get all 3 squares to be \(0\):

\[\begin{align} x+1=0&\implies x=-1\\ x+2y=0 &\implies y=-\dfrac{x}{2}=\dfrac{1}{2}\\ 2y-3z=0 &\implies z=\dfrac{2y}{3}=\dfrac{1}{3}. \end{align}\]

We see that it is indeed achievable. Therefore, we get our answer: \(\boxed{f_{\text{min}}(x,y,z)=-7}\) when \(\boxed{(x,y,z)=\left(-1,\dfrac{1}{2},\dfrac{1}{3}\right)}.\) \(_\square\)

## Problem Solving

We will work through several problems to gain a stronger understanding on the usefulness of completing the square.

Prove that there are no integer solution for the equation

\[x^2+2x+y^2+2y+2xy-22=0.\]

Factorize the expression we get

\[\begin{aligned} (x+y)^2+2(x+y)+1&=23 \\ (x+y+1)^2&=23. \end{aligned}\]

\(23\) is not a square, and hence there are no integer \(x,y\) solutions. \(_\square\)

Factor \( x^3 + y^3 + z^3 - 3xyz \).

This isn't really completing the square, but rather completing the cube:

\[\begin{align} x^3 + y^3 + z^3 - 3xyz &=\big(x^3 + y^3\big) + z^3 - 3xyz \\ &=\big(x^3 + 3x^2 y + 3xy^2 + y^3\big) + z^3 - 3xyz - 3x^2 y - 3xy^2 \\ &=(x+y)^3 + z^3 - 3xyz - 3x^2 y - 3xy^2 \\ &=(x + y + z)\big[(x+y)^2 + z^2 - z(x+y) \big] - 3xy(x+y+z) \\ &= (x+y+z) \big(x^2 + y^2 + 2xy + z^2 - xz - yz - 3xy\big) \\ &= (x+y+z)\big(x^2 + y^2 + z^2 - xz - xy - yz\big).\ _\square \end{align} \]

If

\[ \Delta = \begin{vmatrix} a & b & c \\ b & c & a \\ c & a & b \end{vmatrix} = 0 \quad \text{and} \quad a \neq b \neq c,\]

find \( a + b + c. \)

We have

\[ \Delta = \begin{vmatrix} a & b & c \\ b & c & a \\ c & a & b \end{vmatrix}. \]

Adding column 2 and column 3 to column 1, we have

\[\begin{align} \Delta &= \begin{vmatrix} a + b + c & b & c \\ b + c + a & c & a \\ c + a + b & a & b \end{vmatrix} \\ &= (a + b + c) \begin{vmatrix} 1 & b & c \\ 1 & c & a \\ 1 & a & b \end{vmatrix}. \end{align}\]

Subtracting row 3 from row 1 and row 2 gives

\[ \Delta = (a + b + c) \begin{vmatrix} 0 & b-a & c-b \\ 0 & c-a & a-b \\ 1 & a & b \end{vmatrix}. \]

Multiplying out gives

\[\begin{align} \Delta &= (a + b + c) \left \{ (c-a)(c-b) - (a-b)(b-a) \right \} \\ &= (a + b + c) \big(c^2 - bc - ac + ab - ab + a^2 + b^2 - ab\big) \\ &= (a + b + c) \big(a^2 + b^2 + c^2 - ab - bc - ca\big). \end{align} \]

This is where completing the square comes in:

\[\begin{align} \Delta &= 0 \\ (a + b + c) \big(a^2 + b^2 + c^2 - ab - bc - ca\big) &= 0 \\ (a + b + c) \big(2a^2 + 2b^2 + 2c^2 - 2ab - 2bc - 2ca\big) &= 0 \\ (a + b + c) \big\{ (a^2 - 2ab + b^2) + (b^2 - 2bc + c^2) + (c^2 - 2ac + c^2) \big\} &= 0 \\ (a + b + c) \big\{ (a - b)^2 + (b - c)^2 + (c - a)^2 \big\} &= 0. \end{align} \]

Now, \( \left \{ (a - b)^2 + (b - c)^2 + (c - a)^2 \right \} \) cannot be 0. If it were, that would imply \( a = b = c \).

Hence, \( a + b + c = 0.\ _\square \)

**Cite as:**Completing the Square - Multiple Variables.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/completing-the-square-multiple-variables/