Function Repository Resource:

# CompleteTheSquare

Complete the square of a quadratic polynomial having any number of variables but with no mixed terms

Contributed by: Dennis M Schneider
 ResourceFunction["CompleteTheSquare"][quad,vars] completes the square of the quadratic polynomial quad in the variables vars that has no mixed terms.

## Examples

### Basic Examples

Complete the square of a quadratic polynomial in x:

 In[1]:=
 Out[1]=

Complete the square in x of a quadratic polynomial in x and y:

 In[2]:=
 Out[2]=

Complete the square in both x and y:

 In[3]:=
 Out[3]=

Symbolic coefficients are allowed:

 In[4]:=
 Out[4]=

Complete the square symbolically for a trivariate quadratic polynomial:

 In[5]:=
 Out[5]=

### Possible Issues

If the expression is not a polynomial, an error message is returned:

 In[6]:=

If the expression is not a polynomial of degree 2, an error message is returned:

 In[7]:=

If the polynomial contains mixed terms, an error message is returned:

 In[8]:=