[SOLVED] Basic Chain Rule Problem with Trig Functions

Hi, everyone. First post but I have a feeling I'll be coming back often. (Hi)

**Problem**: For what values of $\displaystyle x$ in the interval $\displaystyle [0,2\Pi]$ does the graph of $\displaystyle f(x)=\cos^2(x)+\sin(x)$ have a horizontal tangent?

**Answer**: $\displaystyle f'(x)=-2\cos(x)\sin(x)+\cos(x)$

f(x) has horizontal tangents at $\displaystyle x=\frac{\Pi}{2}, \frac{3\Pi}{2}$

I don't have a problem getting the x-values for the horizontal tangents but I can't get the right derivative. Here's my work:

$\displaystyle f(x)=\cos^2(x)+\sin(x)$

$\displaystyle f(x)=u^2+\sin(x)$, $\displaystyle u=\cos(x)$

$\displaystyle \frac{dy}{du}=2u+\cos(x)$, $\displaystyle \frac{du}{dx}=-\sin(x)$

$\displaystyle \frac{dy}{dx}=(2u+\cos(x))(-\sin(x))$

$\displaystyle \frac{dy}{dx}=-2u\sin(x)-\sin(x)\cos(x)$

Substitute $\displaystyle \frac{du}{dx}$ back into the equation.

$\displaystyle \frac{dy}{dx}=-2\sin(x)\cos(x)-\sin(x)\cos(x)$

$\displaystyle \frac{dy}{dx}=-3\sin(x)\cos(x)$

Where is my error?

Thank you for your help,

Tim