We know that completing $ax^2+bxy+cz^2$ into forms of $k_{1}(a_{1}x+b_{1}y)^2+k_{2}(a_{2}x+b_{2}y)^2$ is easy and have some fixed routine. But the 3 variable case $$ax^2+by^2+cz^2+dxy+exz+fyx$$does not seem as trivial. Is there any general formula that will complete this into a linear combination of 3 squares?
For example, $$xy+xz-3yz=\frac{1}{3}x^2-\frac{3}{4}(\frac{2}{3}x-y-z)^2+\frac{3}{4}(y-z)^2$$ In this example I used undetermined coefficients method, but it is complicated and have too many variables.
I think I will type in the answer first in a readble manner. Finding it is Hermite's method, standard stuff in any book about quadratic forms. It is traditional to write forms in three variables as $$ g(x,y,z) = a x^2 + b y^2 + c z^2 + d y z + e z x + f x y. $$ Note the $zx$ order, everything cyclic...
With variables as coefficients, we cannot cover the occasional difficulties. Define $$ \delta = 4 a b - f^2 $$ and $$ \Delta = 4abc + def - a d^2 - b e^2 - c f^2. $$ Note that $\delta$ is minus the discriminant of the binary form $a x^2 + f x y + b y^2.$ Then $\Delta$ is the discriminant of Brandt and Intrau, minus the discriminant of Watson, and the same as Lehman, for $g$ itself.
In order to avoid denominators, we get $$ 4a \delta g(x,y,z) = \delta (2ax + f y + e z)^2 + (\delta y + (2ad-ef)z)^2 + 4 a \Delta z^2. $$
When $\Delta = 0,$ this just says that $g$ is not full rank, it is really a binary form in disguise. If $\delta = 0,$ it is probably best to permute the variables, in order to permute the coefficients and so make both $a$ and $\delta$ nonzero. As I said, we cannot cover every possible problem when using variable coefficients.
If desired, there is an algorithmic method; depending on the use, one may need to invert a certain matrix at the end. However, that matrix will be three by three with determinant $1,$ so the inverse is not difficult. See answer by el.Salvador at Given a $4\times 4$ symmetric matrix, is there an efficient way to find its eigenvalues and diagonalize it?