Find $\int \csc^2(x) \,dx$ I did:
\begin{align}
& \int \csc^2(x) \,dx \\
= {} &\int \left(\frac 1 {\sin(x)}\right)^2 \, dx\\
= {} & \int (\sin(x)^{-1})^2 \, dx\\
= {} & \int \sin(x)^{-2} \, dx\\
= {} & \frac{\sin(x)^{-1}}{-1} \cdot \int \sin(x) \\
= {} & -\frac{1}{\sin(x)}\cdot -\cos(x) \\
= {} & \cot(x)
\end{align}
But the right answer is $-\cot(x)$. Where did it go wrong?
 A: Observe that
$$\frac {1}{\sin^2 (x)}=-\frac {-\sin^2(x)-\cos^2 (x)}{\sin^2 (x)} $$
$$=-\frac {d}{dx}\frac {\cos (x)}{\sin (x)} $$
A: I was puzzled by this step:
$$
\int \sin(x)^{-2} \, dx = \frac{\sin(x)^{-1}}{-1} \cdot \int \sin(x) \,dx \text{ ?}
$$
Then I realized you were trying to apply a sort of chain rule.
If you have something like $\displaystyle \int (5x+3)^{12} \,dx$ you can say that it's equal to $\dfrac{(5x+3)^{13}}{13}\cdot \dfrac 1 5$ and that's an application of the chain rule for differentiation. Or a bit more elaborately:
$$
\int(5x+4)^{12} \, dx = \int u^{12} \, \left(\frac{du} 5\right) = \frac{u^{13}}{13} \cdot \frac 1 5 + \text{constant}
$$
and like all "$u$-substitutions" that is an application of the chain rule.
But consider this:
$$\require{cancel}
\xcancel{\frac d {dx} \left( \frac{\sin(x)^{-1}}{-1} \cdot \int\sin(x)\, dx \right) = \sin(x)^{-2} \cdot \sin(x)}
$$
The problem is that you're multiplying two functions and then differentiating what you get, and for that you need the product rule. You can't just differentiate the two separately.
