<s>[INST] Maximizing $3\sin^2 x + 8\sin x\cos x + 9\cos^2 x$. What went wrong? 
Let $f(x) = 3\sin^2 x + 8\sin x\cos x + 9\cos^2 x$. For some $x \in \left[0,\frac{\pi}{2}\right]$, $f$ attains its maximum value, $m$. Compute $m + 100 \cos^2 x$.

What I did was rewrite the equation as $f(x)=6\cos^2x+8\sin x\cos x+3$. Then I let $\mathbf{a}=\left<6\cos x,8\cos x\right>$ and $\mathbf{b}=\left<\cos x,\sin x\right>$.
Using Cauchy-Schwarz, I got that the maximum occurs when $\tan x=\frac{4}{3}$, and that the maximum value is $10\cos x$. However, that produces a maximum of $9$ for $f(x)$, instead of the actual answer of $11$.
What did I do wrong, and how do I go about finding the second part? Thanks!
 [/INST] Let's ignore the condition that $x\in[0,\pi/2]$ for the moment.
We are maximising $3u^2+8uv+9v^2$ subject to the constraint $u^2+v^2=1$.
For a given $a$, $3u^2+8uv+9v^2=a$ is soluble under this constraint
iff $3u^2+8uv+9v^2=a(u^2+v^2)$ is. This means that $Q(u,v)=(3-a)u^2+8uv+(9-a)v^2=0$. If this has a solution $\ne(0,0)$ it can be scaled to one with
$u^2+v^2=1$. This is the case if the quadratic form $Q$ factors over the
reals, that is if $8^2-4(3-a)(9-a)\ge0$. This gives $a^2-12a+11\le0$,
equivalently $(a-1)(a-11)\le0$. The possible values of $a$ form
the interval $[1,11]$.
Does $11$ occur as a maximum for some acute angle $x$? When $a=11$,
$Q(u,v)=-8u^2+8uv-2v^2=-2(2u-v)^2$, so at a maximum, $v=2u$. The
solutions of this when $u^2+v^2=1$ are $(1/\sqrt5,2/\sqrt5)$
and $(-1/\sqrt5,-2/\sqrt5)$ and the first comes from the acute
angle $x=\tan^{-1}2$.
</s>