# Completing the square

How might I find linear combinations \begin{align*} A&=a_1x+a_2y+a_3z\\ B&=b_1x+b_2y+b_3z\\ C&=c_1x+c_2y+c_3z \end{align*}

Such that I can transform the two polynomials

$$2x^2+3y^2-2yz+3z^2\text{ and }x^2+6xy+3y^2+2yz-6zx+3z^2$$

into

$A^2+B^2+C^2$ and $\alpha A^2+\beta B^2+\gamma C^2$ respectively for some $\alpha, \beta,\gamma\in \mathbb R$?

I think I should be completing the square, but I can't see how to.

-
So, the first equation is equal to (A^2 +B^2+C^2) and the second to the multiple of it? And are you allowed matrix algebra to solve systems of linear equations? – Drew Christianson Dec 4 '11 at 23:12
@DrewChristianson: Yes and no. The first equation is indeed equal to $A^2 +B^2+C^2$ but the second one is not necessarily a multiple of it since $\alpha, \beta, \gamma$ are not necessarily equal. Any method of solving it would be appreciated! – Ralph Dec 5 '11 at 0:21
I think this is the standard linearly algebraic algebra course(Simultaneous Diagonalization); maybe the tag could be changed? – awllower Dec 6 '11 at 14:24

## 2 Answers

Your question is equivalent to finding a matrix $S$ such that $S^\top XS=I$ and $S^\top YS$ is diagonal, where $$X=\begin{pmatrix}2&0&0\\ 0&3&-1\\ 0&-1&3\end{pmatrix}, Y=\begin{pmatrix}1&3&-3\\ 3&3&1\\ -3&1&3\end{pmatrix}.$$ In a related question (BTW, the $X,Y$ here are exactly the same as the matrices $A,B$ in that question; is this a homework question or something else?), I have explained how to find a matrix $M$ such that both $M^\top XM=\Lambda_1$ and $M^\top YM=\Lambda_2$ for some diagonal matrices $\Lambda_1$ and $\Lambda_2$. Concretely, $$M=\frac{1}{\sqrt{\lambda+4}} \begin{pmatrix} 2&1&0\\ -1&1&1\\ 1&0&1 \end{pmatrix} \begin{pmatrix}1&0&0\\0&\lambda-4&-2\\0&2&\lambda-4\end{pmatrix}, \quad \lambda=\frac{9+\sqrt{17}}{2}.$$ Now you may take $S=M\Lambda_1^{-1/2}$. The coefficients of $A$ can be read off from the first row of $S^\top$, and vice versa for $B$ and $C$. The coefficients $\alpha,\beta,\gamma$ are the diagonal entries of $S^\top YS$.

Another way of solving the problem is to find the square root of $X$, then orthogonally diagonalize $(\sqrt{X}^\top)^{-1}Y\sqrt{X}^{-1}$. In other words, if $\sqrt{X}$ is a matrix such that $\sqrt{X}^\top\sqrt{X}=X$, and $Q$ is an orthogonal matrix such that $Q^\top(\sqrt{X}^\top)^{-1}Y\sqrt{X}^{-1}Q$ is diagonal, then you may set $S=\sqrt{X}^{-1}Q$.

-
Thanks! This is set for discussion and for "pondering over"... :) – Ralph Dec 5 '11 at 9:55

Here's my setup and a numeric solution to the problem; I'm not sure how to find an explicit solution as of now, I'll keep researching.

Anyway, first note that: \begin{align}A^2 &= a_1^2x^2+2a_1a_2xy + 2a_1a_3xz+a_2^2y^2 +2a_2a_3yz+a_3^2z \\ B^2 &= b_1^2x^2+2b_1b_2xy + 2b_1b_3xz+b_2^2y^2 +2b_2b_3yz+b_3^2z \\C^2 &= c_1^2x^2+2c_1c_2xy + 2c_1c_3xz+c_2^2y^2 +2c_2c_3yz+c_3^2z\end{align}

Thus, after some factoring,

$A^2+B^2+C^2 = (a_1^2+b_1^2+c_1^2)x^2 + 2(a_1a_2+b_1b_2+c_1c_2)xy + 2(a_1a_3+b_1b_3+c_1c_3)xz$ $+ (a_2^2+b_2^2+c_2^2)y^2 + 2(a_2a_3+b_2b_3+c_2c_3)yz+(a_3^2+b_3^2+c_3^2)z^2$

It follows that:

$\alpha A^2 + \beta B^2 + \gamma C^2 = (\alpha a_1^2+\beta b_1^2+\gamma c_1^2)x^2 + 2(\alpha a_1a_2+\beta b_1b_2+\gamma c_1c_2)xy + 2(\alpha a_1a_3+\beta b_1b_3+\gamma c_1c_3)xz$ $+ (\alpha a_2^2+\beta b_2^2+\gamma c_2^2)y^2 + 2(\alpha a_2a_3+\beta b_2b_3+\gamma c_2c_3)yz+(\alpha a_3^2+\beta b_3^2+\gamma c_3^2)z^2$

As

$2x^2+3y^2-2yz+3z^2 =$

$(a_1^2+b_1^2+c_1^2)x^2+ 2(a_1a_2+b_1b_2+c_1c_2)xy + 2(a_1a_3+b_1b_3+c_1c_3)xz$ $+ (a_2^2+b_2^2+c_2^2)y^2 + 2(a_2a_3+b_2b_3+c_2c_3)yz+(a_3^2+b_3^2+c_3^2)z^2$

and

$x^2+6xy+3y^2+2yz-6zx+3z^2 =$

$(\alpha a_1^2+\beta b_1^2+\gamma c_1^2)x^2 + 2(\alpha a_1a_2+\beta b_1b_2+\gamma c_1c_2)xy + 2(\alpha a_1a_3+\beta b_1b_3+\gamma c_1c_3)xz$ $+ (\alpha a_2^2+\beta b_2^2+\gamma c_2^2)y^2 + 2(\alpha a_2a_3+\beta b_2b_3+\gamma c_2c_3)yz+(\alpha a_3^2+\beta b_3^2+\gamma c_3^2)z^2$

The sums of the $a_i, b_i, c_i$ must be equal to the coefficients on the polynomials in question. Thus, we can build a system of nonlinear equations on the $a_i, b_i, c_i$ and $\alpha,\beta,\gamma$:

\begin{align}2&=a_1^2+b_1^2+c_1^2 \\3&= a_2^2+b_2^2+c_2^2 \\ 3&=a_3^2+b_3^2+c_3^2 \\ 0&=a_1a_2+b_1b_2+c_1c_2 \\ 0&=a_1a_3+b_1b_3+c_1c_3 \\ -1&=a_2a_3+b_2b_3+c_2c_3 \\ 1&=\alpha a_1^2+\beta b_1^2+\gamma c_1^2 \\ 3&=\alpha a_2^2+\beta b_2^2+\gamma c_2^2 \\ 3&=\alpha a_3^2+\beta b_3^2+\gamma c_3^2 \\ 1&=\alpha a_2a_3+\beta b_2b_3+\gamma c_2c_3 \\ 3&=\alpha a_1a_2+\beta b_1b_2+\gamma c_1c_2 \\ 3&=\alpha a_1a_2+\beta b_1b_2+\gamma c_1c_2\end{align}

Which is a system of 12 equations in 12 variables. Unfortunately, as it's nonlinear, an explicit solution is difficult to find. Fortunately, Maple happily provides a numeric solution: $\alpha = 2 , \beta = -1 , \gamma = 2,$

$a_1 = .9596238496 , a_2 = 1.240910300 , a_3 = -0.6783373986 ,$

$b_1 = -1 , b_2 = 1, b_3= -1 ,$

$c_1 = -0,2812864509 , c_2 = 0.6783383986, c_3 = 1.240910300$

Which are accurate to $10^{-9}$ Unfortunately, as this is only a numerical solution, I have no way to verify the nature of the solution set

-