Rewrite a term as sum of squares At the moment I am trying to rewrite this term:
$2x^2-2xy+5y^2-4x+2y+2$
as a sum of squares.
So I am trying to find an experession of $2x^2-2xy+5y^2-4x+2y+2=a^2+b^2+c^2$ (for example)
It looks easy, but everything I have tried failed so far. So I wonder if there is such expression. I know that this term is nonnegativ for every pair $(x,y)$.
One try might look like this:
$2x^2-2xy+5y^2-4x+2y+2=x^2-2xy+y^2+x^2+4y^2-4x+2y+2=(x-y)^2+(x-2)^2+4y^2+2y-2$
Here $4y^2+2y-2=4(y-\frac12)(y+1)$
Do you see a nice sequence of calculations?
Thanks in advance.

The second matrix identity below says
$$  \frac{1}{2} (2x-y-2)^2 + \frac{9}{2} y^2   $$
The method is discussed at
reference for linear algebra books that teach reverse Hermite method for symmetric matrices
$$ P^T H P = D  $$
$$\left( 
\begin{array}{rrr} 
1 & 0 & 0 \\ 
 \frac{ 1 }{ 2 }  & 1 & 0 \\ 
1 & 0 & 1 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rrr} 
2 &  - 1 &  - 2 \\ 
 - 1 & 5 & 1 \\ 
 - 2 & 1 & 2 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rrr} 
1 &  \frac{ 1 }{ 2 }  & 1 \\ 
0 & 1 & 0 \\ 
0 & 0 & 1 \\ 
\end{array}
\right) 
 = \left( 
\begin{array}{rrr} 
2 & 0 & 0 \\ 
0 &  \frac{ 9 }{ 2 }  & 0 \\ 
0 & 0 & 0 \\ 
\end{array}
\right) 
$$
$$ Q^T D Q = H  $$
$$\left( 
\begin{array}{rrr} 
1 & 0 & 0 \\ 
 -  \frac{ 1 }{ 2 }  & 1 & 0 \\ 
 - 1 & 0 & 1 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rrr} 
2 & 0 & 0 \\ 
0 &  \frac{ 9 }{ 2 }  & 0 \\ 
0 & 0 & 0 \\ 
\end{array}
\right) 
\left( 
\begin{array}{rrr} 
1 &  -  \frac{ 1 }{ 2 }  &  - 1 \\ 
0 & 1 & 0 \\ 
0 & 0 & 1 \\ 
\end{array}
\right) 
 = \left( 
\begin{array}{rrr} 
2 &  - 1 &  - 2 \\ 
 - 1 & 5 & 1 \\ 
 - 2 & 1 & 2 \\ 
\end{array}
\right) 
$$
