<s>[INST] How to transform quadratic terms to something like $u^2+v^2$? I am told that by the substitution of $x = (a\cos \theta)u - (b\sin \theta) v$ and $y = (a\sin \theta)u + (b\cos \theta)v$, we can reduce $3x^2 + 2xy + 3y^2$ to $u^2 + v^2$.
I tried to plug in the substitutions, but I did not see how the quadratic term is reduce to $u^2 + v^2$. What I got was something complicated containing $a$, $b$, $\cos \theta$ and $\sin \theta$.
I am asked to reduce $3x^2 + 2xy + 3y^2 - x - 2y$ to $u^2 + v^2$ by similar substitutions. I do not know how to construct this substitution. Could you explain how do find this kind of substitutions in general?

 [/INST] The answer is $x=\frac{-1}{2}$, $b=-\frac{1}{\sqrt{2}}$, $\theta=\frac{\pi}{4}$ and
$$
x=(a\cos\theta)u-(b\sin\theta)v\textrm{, }y=(a\sin\theta)u+(b\cos\theta)v.\tag 1
$$
Setting this into $3x^2+2xy+3y^2$ you get $u^2+v^2$.
By demanding $kx^2+lxy+my^2$ to be $u^2+v^2$, you get after some calculations
$$
a=\frac{\pm1}{\sqrt{k\cos^2 \theta+l\cos \theta \sin \theta+m \cos^2\theta}}
$$
$$
b=\frac{\pm1}{\sqrt{m\cos^2 \theta-l\cos \theta \sin \theta+k\sin^2 \theta}}
$$
$$
l\cos 2\theta+(m-l)\sin 2\theta=0
$$
</s>