There is a method I asked about at
reference for linear algebra books that teach reverse Hermite method for symmetric matrices
The main advantage is that it is a recipe with matrices, no need to carry variable names. The main disadvantage is the need to invert one matrix at the end; however, the matrix has determinant $\pm 1$ and may very well be upper triangular (it is this time).
It leads to $$ x^2 + z^2 + 4 xy - 4 zx = (x +2y-2z)^2 - 4 (y-z)^2 + z^2 $$
and comes from this matrix stuff; I did it first by hand, it did work, but I thought i would check everything. The Pari code is not quite as readable as Latex but is not too bad.
parisize = 4000000, primelimit = 500509
? m = [ 1,2,-2; 2,0,0; -2,0,1]
%2 =
[1 2 -2]
[2 0 0]
[-2 0 1]
? m - mattranspose(m)
%3 =
[0 0 0]
[0 0 0]
[0 0 0]
? p1 = [1,-2,2; 0,1,0; 0,0,1]
%4 =
[1 -2 2]
[0 1 0]
[0 0 1]
? m1 = mattranspose(p1) * m * p1
%5 =
[1 0 0]
[0 -4 4]
[0 4 -3]
? p2 = [ 1,0,0; 0,1,1; 0,0,1]
%6 =
[1 0 0]
[0 1 1]
[0 0 1]
? d = mattranspose(p2) * m1 * p2
%7 =
[1 0 0]
[0 -4 0]
[0 0 1]
? p = p1 * p2
%8 =
[1 -2 0]
[0 1 1]
[0 0 1]
? matdet(p)
%9 = 1
? q = matadjoint(p)
%10 =
[1 2 -2]
[0 1 -1]
[0 0 1]
? confirm = mattranspose(q) * d * q
%12 =
[1 2 -2]
[2 0 0]
[-2 0 1]
? m
%13 =
[1 2 -2]
[2 0 0]
[-2 0 1]
? m - confirm
%14 =
[0 0 0]
[0 0 0]
[0 0 0]
?
? ( x + 2 * y - 2 * z)^2 - 4 * (y - z)^2 + z^2
%1 = x^2 + (4*y - 4*z)*x + z^2
=========================================================
Places on this site I put this, several typeset:
reference for linear algebra books that teach reverse Hermite method for symmetric matrices
Bilinear Form Diagonalisation
Given a $4\times 4$ symmetric matrix, is there an efficient way to find its eigenvalues and diagonalize it?
Find the transitional matrix that would transform this form to a diagonal form.
Writing an expression as a sum of squares
Determining matrix $A$ and $B$, rectangular matrix
Method of completing squares with 3 variables