Q:

Convert $-2xy+2zx-x^2$ into a sum of three squares of expressions of $x,y$ and $z$

Convert $-2xy+2zx-x^2$ into a sum of three non-zero squares of linearly independent expressions of $x,y$ and $z$
I can do 2: $-(x+y-z)^2+(y-x)^2$ , but I  need exactly 3 squares.
Got stuck on a little riddle here. Is there any general theory for it?

A:

What you’re asking for is impossible.  
Let $$Q=\begin{bmatrix}-1&-1&1\\-1&0&0\\1&0&0\end{bmatrix}$$ so that your quadratic form can be written as $(x,y,z)Q(x,y,z)^T$. Your problem is then equivalent to finding some invertible $3\times3$ matrix $P$ such that $D=P^TQP$ is diagonal and has no zeros along the main diagonal.  
Observe that $\det(Q)=0$, so $\det(D)=\det(P^TQP)=\det(Q)\det(P)^2=0$, but this means that at least one of those main-diagonal elements must be zero. In other words, no matter how you rewrite this quadratic form as a linear combination of independent perfect squares, you will have at most two terms.

