# 用配方法化二次型为标准形

\begin{align*}f(x_1,x_2,x_3)&=2x_1^2+3x_2^2+x_3^2-4x_1x_2-4x_1x_3-8x_2x_3 \\ &=(2x_1^2-4x_1x_2-4x_1x_3)+3x_2^2+x_3^2-8x_2x_3 \\ &=2(x_1^2-2x_1(x_2+x_3))+3x_2^2+x_3^2-8x_2x_3 \\ &=2(x_1^2-2x_1(x_2+x_3)+(x_2+x_3)^2-(x_2+x_3)^2)+3x_2^2+x_3^2-8x_2x_3\\ &=2(x_1-x_2-x_3)^2+3x_2^2-2(x_2+x_3)^2+x_3^2-8x_2x_3\\ &=2(x_1-x_2-x_3)^2+3x_2^2-2x_2^2-4x_2x_3-2x_3^2+x_3^2-8x_2x_3\\ &=2(x_1-x_2-x_3)^2+(x_2^2-12x_2x_3)-x_3^2\\ &=2(x_1-x_2-x_3)^2+(x_2^2-12x_2x_3+36x_3^2)-36x_3^2-x_3^2 \\ &=2(x_1-x_2-x_3)^2+(x_2-6x_3)^2-37x_3^2\end{align*}

$\begin{pmatrix}x_1\\x_2\\x_3\end{pmatrix}=\begin{pmatrix}1&1&-\frac{7}{\sqrt{37}}\\ 0&1&-\frac{6}{\sqrt{37}}\\ 0&0& \frac{1}{\sqrt{37}}\end{pmatrix}\begin{pmatrix}y_1\\y_2\\y_3\end{pmatrix}$

$f(x_1,x_2,x_3)=2(y_1+y_2)(y_1-y_2)+4(y_1+y_2)y_3=2y_1^2-2y_2^2+4y_1y_3+4y_2y_3$

\begin{align*}f(x_1,x_2,x_3)&=2y_1^2-2y_2^2+4y_1y_3+4y_2y_3\\ &=2(y_1^2+2y_1y_3)-2y_2^2+4y_2y_3\\ &=2(y_1+y_3)^2-2y_2^2-2y_3^2+4y_2y_3\\ &=2(y_1+y_3)^2-2(y_2-y_3)^2\end{align*}

$C_2=\begin{pmatrix}1&0&-1\\ 0&1&1\\ 0&0&1\end{pmatrix}$

$C=C_1C_2=\begin{pmatrix}1&1&0\\ 1&-1&0\\ 0&0&1\end{pmatrix}\begin{pmatrix}1&0&-1\\ 0&1&1\\ 0&0&1\end{pmatrix}=\begin{pmatrix}1&1&0\\1&-1&-2\\ 0&0&1\end{pmatrix}$