Decomposing bivariate quadratic form into sum of two squares

I would like to decompose

$$ax_1^2 + bx_2^2 + 2cx_1x_2$$

into two expressions, each involving only one variable. I'm trying to use a transform like $$x_1 = x_+ + x_-$$ and $$x_2 = x_+ - x_-$$ to hopefully get something like

$$\left( bx_+ + \frac ac \right)^2 + \left(ax_ - + \frac bc \right)^2$$

or something of that form. Is this possible?

You can write quadratic expressions as $$x^T Q x$$; in this case $$x^T = (x_1, x_2), Q = \begin{pmatrix}a & c \\ c & b\end{pmatrix}$$.

Then, if you write $$Q$$ as $$Q = A^TDA$$, with $$D$$ diagonal, you have $$x^TQx = x^TA^TDAx = (Ax)^TD(Ax)$$: $$Ax = (y_1, y_2)^T$$ are the new variables you are searching, $$D = \begin{pmatrix}d_1 & 0 \\ 0 & d_2\end{pmatrix}$$ are the new coefficients; so you can rewrite $$ax_1^2 + bx_2^2 + 2cx_1x_2 = d_1 y_1^2 + d_2y_2^2$$.

EDIT: another (somewhat equivalent) trick is to "complete the squares":

\begin{aligned} ax_1^2 + bx_2^2 + 2cx_1x_2 &= ax_1^2 + 2cx_1x_2 + \frac{c^2}{a}x_2^2 + \left( b - \frac{c^2}{a} \right)x_2^2 \\ &= \left( \sqrt{a}x_1 + \frac{c}{\sqrt{a}}x_2 \right)^2 + \left(b - \frac{c^2}{a} \right)x_2^2 \end{aligned}

• Thanks dcolazin, I had a play around with some easier examples (e.g. setting a=b) and found a good solution using this method. The new variables $y_1,y_2$ turned out to be $x_1 + x_2$ and $-x_1 + x_2$, with a factor of $\frac{1}{\sqrt2}$.The diagonalisation problem for my original matrix turned out to be pretty algebraically heavy but in principle it looks like this works. – Tapedeck Apr 23 at 22:26
• @Tapedeck check my edit for a less algebraically heavy solution – dcolazin Apr 24 at 7:22
• Thanks again- completing the squares does create two expressions with squares but for this particular task I was looking to get each expression in only one variable, which I think requires you to diagonalise a matrix per your original response and create new variables $y_1,y_2$. The reason I wanted the expressions to be in only one variable is that this is part of a PDE question with a few more terms and I'd like to use separation of variables – Tapedeck Apr 24 at 22:27
• @Tapedeck can't you use the variables $y_1 = x_1 + c/a x_2, y_2 = x_2$? – dcolazin Apr 25 at 18:43
• That looks like it does it, I believe you get $ay_1^2 + (b-c^2/a)y_2^2$ - but how do you come up with a substitution like that? – Tapedeck Apr 25 at 22:25