Integration by Parts with Trigonometric Functions Trying to evaluate this indefinite integral:
$$ \int (x^2 + 1)\cos2xdx$$
So far I have the following: $u=x^2 + 1 \Rightarrow du = 2xdx$ and $dv=\cos2x \Rightarrow v = \frac {\sin2x}{2}$. So the integral is equal to:
$$\int (x^2+1)\cos2xdx = (x^2+1)\frac{\sin2x}{2}-\int {\frac{\sin2x}{2}}2xdx$$
Next, I make another substitution for the integral on the right hand side; let $ u = x \Rightarrow du = dx$ and let $dv = \sin2x \Rightarrow v = \frac {-\cos2x}{2}$. Now I have the following:
$$\int (x^2+1)\cos2xdx = (x^2+1)\frac{\sin2x}{2}-\left (-\frac {x\cos2x}{2} - \int -\frac {cos2x}{2}dx\right)$$
Which after integrating becomes:
$$\int (x^2+1)\cos2xdx = (x^2+1)\frac{\sin2x}{2}-\left(-\frac {x\cos2x}{4} + \frac {\sin2x}{4}\right)$$
But when solving with the integrator on my calculator, I get a different answer (it looks like I am getting closer, but still off). What am I doing wrong here??

I see three mistakes in your calculations:


*

*As Andre pointed out in the comments, in the first substitution $du = 2x dx$.

*There is a sign error in the second integration by parts:
$$-\left(-\frac{x\cos 2x}{2} - \int \frac{-\cos 2x}{2} dx\right) = \frac{x\cos 2x}{2} - \int \frac{\cos 2x}{2} dx.$$

*An integration constant should appear as early as the first integration by parts.

