$u$-Subtitution with a definite integral that has a constant gives different answer I have the following integral:
$$\int_0^\pi (2+\cos^2(t)\sin(t))\,\mathrm dt$$
Choosing $u = \cos(t)$, I would get the following result:
$$2u - \frac{u^3}{3}$$
which is:
$$2\cos(t) - \frac{\cos^3(t)}{3}\Bigg|_0^\pi.$$ However, if I solve the same integral by taking the constant out as its own integral:
$$2\int_0^\pi\,\mathrm dt+\int_0^\pi\cos^2(t)\sin(t)\,\mathrm dt$$
And the computed antiderivative would be 
$$2\pi-\frac{\cos^3(t)}{3}$$
Why this discrepancy? Which one is the right one?

@JeqHar has given you the correct answer.
To see where your mistake was, remember that when you are doing a $u$-substitution, you are hoping to be able to realize the integrand in the form
$$\int f\bigl(g(t)\bigr)g’(t)\,dt$$
and then set $g(t)=u$, $g’(t)\,dt = du$, and thus get $\int f(u)\,du$.
Here, you are setting $u=\cos(t)$, so $(-1)\,du = \sin(t)\,dt$. However, your integral is
$$\int \Bigl( 2 + \cos^2(t)\sin(t)\Bigr)\,dt.$$
In order to do the substitution the way you want, you should be able to rewrite
$$2 + \cos^2(t)\sin(t)$$
in the form
$$K(t)\sin(t)\,dt$$
(a product) so that you can take the “$\sin(t)\,dt$” and turn it into a $du$, and then do the substitution into $K(t)$.  That would mean writing
$$\int \Bigl(2+\cos^2(t)\sin(t)\Bigr)\,dt = \int \left(\frac{2}{\sin(t)} + \cos^2(t)\right)\underbrace{\sin(t)\,dt}_{(-1)du}$$
Then you turned the $\cos^2(t)$ into $u^2$... but you turned $\frac{2}{\sin(t)}$ into $2$... which is incorrect. You can either turn it into a function of $u$ correctly, or you can separate it out, but you can’t just leave the $2$ alone.
