I'd like to write $2xy+2xz+2yz$ in the form $a(\cdots)^2+b(\cdots)^2+c(\cdots)^2$ where each blank space is a linear combination of $x,y,z$. The closest I have is:
$$(x+y+z)^2-(x-z)^2-y^2=2xy+4xz+2yz$$ Working: Spotting something didn't work so I've noted that:
$$\mathbf{x}^{\text{T}}M\mathbf{x}=2xy+2xz+2yz;\quad M=\begin{pmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 &0 \end{pmatrix}$$ I found eigenvalues $2,-1,-1$ and the eigenvectors $(1,1,1),\;(-1,1,0),\;(-1,0,1)$.
So in the eigenbasis the expression becomes $2u^2-v^2-w^2$. But I'm having trouble writing $u,v,w$ in terms of $x,y,z$. Can someone help?
If it is of any help:
$$P=\begin{pmatrix} -1 & -1 & 1 \\ 0 & 1 & 1 \\ 1 & 0 & 1\end{pmatrix}\quad P^{-1}=\frac{1}{3}\begin{pmatrix} -1 & -1 & 2 \\ -1 & 2 & -1 \\ 1 & 1 & 1\end{pmatrix}$$
Give $M=PDP^{-1}$ where $D$ is diagonal with entries $-1,-1,2$.
You’re on the right track by finding the matrix for this quadratic form and diagonalizing it. Take $\langle-1,2,-1\rangle$ as an eigenvector instead of $\langle-1,1,0\rangle$ so that after normalizing you end up with a rotation: $$ R=\pmatrix{ \frac1{\sqrt3} & \frac1{\sqrt2} & -\frac1{\sqrt6} \\ \frac1{\sqrt3} & 0 & \frac2{\sqrt6} \\ \frac1{\sqrt3} & -\frac1{\sqrt2} & -\frac1{\sqrt6} } \\ M=R\pmatrix{4&0&0\\0&-1&0\\0&0&-1}R^{-1}. $$ Noting that $R^{-1}=R^T$, the terms you’re looking for are then given by $$ R^T\pmatrix{x\\y\\z}=\pmatrix{\frac1{\sqrt3}(x+y+z) \\ \frac1{\sqrt2}(x-z) \\ -\frac1{\sqrt6}(x-2y+z)}. $$ Putting it all together, $$\begin{align} 2xy+2xz+2yz &= 2\left(\frac1{\sqrt3}(x+y+z)\right)^2-\left(\frac1{\sqrt2}(x-z)\right)^2-\left(-\frac1{\sqrt6}(x-2y+z)\right)^2 \\ &= \frac{2}{3}\left(x+y+z\right)^2-\frac1{2}\left(x-z\right)^2-\frac1{6}\left(x-2y+z\right)^2. \end{align}$$ By symmetry, any permutation of the variables in the above expression will also work.
Addendum: The alert reader will have noticed that the squared terms are the dot products of the corresponding normalized eigenvectors with $(x,y,z)$, so the sum-of-squares expression can be written down directly once the eigenvalues and orthonormal eigenvectors are known.