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!

$f(x)=2\sin^2x+8\sin x\cos x+8\cos^2x+1=2(\sin x+2\cos x)^2+1$
Let $\displaystyle \alpha\in\left[0,\frac{\pi}{2}\right]$ and $\displaystyle\cos\alpha=\frac{2}{\sqrt{5}}$. Then $\displaystyle\sin\alpha=\frac{1}{\sqrt{5}}$ and
$$\sin x+2\cos x=\sqrt{5}(\sin x\sin\alpha+\cos x\cos\alpha)=\sqrt{5}\cos(x-\alpha).$$
attaining its maximum when $x=\alpha$.
So, $m=2(\sqrt{5})^2+1=11$ and $\displaystyle m+100\cos^2\alpha=11+100\left(\frac{4}{5}\right)=91$.
