Find a basis of $\mathbb{R}^2$ that is orthogonal for $q_1$ and in which $q_2$ is diagonal. On $\mathbb{R}^2$, with coordinates $(x, y)$ consider the quadratic forms $q_1$ and $q_2$ defined by $q_1(x, y, z)=2 x^2+4 x y+3 y^2+2 y z+2 z^2$ and $q_2(x, y, z)=x y+x z+z^2$.
Find a basis of $\mathbb{R}^2$ that is orthogonal for $q_1$ and in which $q_2$ is diagonal.
First I notice that $q_1$ is definitely positive and we can write is as
$$ q_1 = 2(x+y)^2 + (y+z)^2 + z^2$$
Let $B_C$ be the canonical basis of $\mathbb{R}^3$. I want to find the reciprocal basis of the linear forms $l_1(x,y,z) = \sqrt{2}(x+y)$, $l_2(x,y,z) = y+z$ and $l_3(x,y,z) =z$.
Thus we want to solve the system
$$\begin{cases}
l_1(v) = 1 \\
l_2(v) = 0 \\
l_3(v) = 0 \\
\end{cases}$$
which gives us the first vector $v = \left( \frac{1}{\sqrt{2}}, 0, 0\right)$
Doing an analogous approach for $l_2$ and $l_3$, we find the vectors $w = (-1,1,0)$ and $t = (1,-1,1)$.
We then set the change of basis matrix
$$ P = \begin{pmatrix}
1/\sqrt{2} & -1 & 1\\
0 & 1 & -1 \\
0 & 0 & 1
\end{pmatrix}.$$
Notice in addition that the matrix of $q_2$ in the canonical basis is
$$ M_{B_C}{q_2}\begin{pmatrix}
0 & 1/2 & 1/2\\
1/2 & 0 & 0 \\
1/2 & 0 & 1
\end{pmatrix}.$$
If I compute now $P^t M_{B_C}q_2 P$ then I get a matrix which is not diagonal.. Do I have to apply gram schmidt process? I've asked myself if the quadratic forms are even simultaneously diagonalizable since their matrices in the canonical basis do not commute.
 A: Let $Q_1$ and $Q_2$ be the matrix representations of $q_1$ and $q_2$ respectively, i.e., let
$$
Q_1=\pmatrix{2&2&0\\ 2&3&1\\ 0&1&2},
\quad Q_2=\pmatrix{0&\frac12&\frac12\\ \frac12&0&0\\ \frac12&0&1}.
$$
We want to find an invertible matrix $P$ and a diagonal matrix $D$ such that $Q_1=P^TP$ and $Q_2=P^TDP$.
If $P_0$ is a particular solution to the equation $Q_1=P_0^TP_0$, the general solution to $Q_1=P^TP$ is given by $P=U^TP_0$ where $U$ is an orthogonal matrix.
So, to find $P$, there are two tasks to fulfil:

*

*Find a matrix $P_0$ such that $Q_1=P_0^TP_0$.

*Find an orthogonal matrix $U$ such that $Q_2=P_0^TUDU^TP_0$ for some diagonal matrix $D$. This is equivalent to finding a spectral decomposition $UDU^T$ of $(P_0^T)^{-1}Q_2P_0^{-1}$.

Finally, set $P=U^TP_0$.
The first task is easy if you take $P_0$ as the Cholesky factor of $Q_1$. The second task is rather tedious if you want to write down the exact values of $U$ and $D$, because the eigenvalues of $D$ are roots of a cubic polynomial equation, which may not have nice-looking forms. But this is not a problem if you only want a numerical solution.
