The quadratic form
$$10x^2+20y^2+2z^2+4xy-6xz+8yz$$
can be written as $x^TAx$, where A = [ [10,2,-3] , [2,20,4] , [-3,4,2] ]
Using diagonalization, this can be written in the form $a_1y_1^2+a_2y_2^2+a_3y_3^2$
But how do I get the alternative form
$$(x+2y)^2+(3x-z)^2+(4y+z)^2$$
In general, how can I check if a quadratic form can be transformed in this way in $\mathbb Q$ ?
The eigenvalues do not help because in my example there are only irrational eigenvalues.
Define $u=x+2y,v=3x-z, w=4y+z$ and $r=\{x,y,x\}^T, R=\{u,v,w\}^T$.
Then we have $$\left(\begin{matrix}u \\v \\w \end{matrix}\right)=\left(\begin{matrix}1 & 2 & 0\\3 & 0 & -1\\0 & 4 & 1\end{matrix}\right)\left(\begin{matrix}x \\y \\z \end{matrix}\right) \implies R =Pr \implies r=P^{-1}R......(1)$$
where $$P:=\left(\begin{matrix}1 & 2 & 0\\3 & 0 & -1\\0 & 4 & 1\end{matrix}\right)$$
$$I=10x^2+20y^2+2z^2+4xy-6xz+8yz=r^TAr$$
$$\implies I=R^TBR$$ where $$B:=(P^{-1})^TAP^{-1}=\left(\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right)......(2)$$
Thus if the basis $u,v,w$ are known as linear combinations of $x,y,z$, then we can always find matrix $B$. However if we require that $B$ is an identity matrix, then we may not be able to solve $P^{-1}$ from (2).