Evaluate trig function integral I was struggling to evaluate this integral:
$$\int x\sin^2(4x)\;dx$$
Every time I try again I end up with a different answer, my most recent answer I came up with is 
$$-\frac1{12} x\cos^3(4x) + \frac1{16}\sin^4(4x) + C$$
but I was wrong again.
I don't have a reference for what the answer actually is because we have to do the work online and we don't know the correct answer until we submit the correct one. I was just seeing if anyone could point me the right direction. 
Thank you!
-Frank

Consider the integral
\begin{align}
I = \int x \, \sin^{2}(4x) \, dx.
\end{align}
Using $2 \sin^{2}(x) = 1 - \cos(2x)$ then 
\begin{align}
2 I &= \int x (1 - \cos(8x)) \, dx \\
&= \frac{x^{2}}{2} - \int x \, \cos(8x) \, dx.
\end{align}
Using integration by parts yields
\begin{align}
\int x \cos(8x) \, dx &= \frac{x \sin(8x)}{8} - \int \sin(8x) \, dx \\
&= \frac{x \sin(8x)}{8} + \frac{\cos(8x)}{64}
\end{align}
for which
\begin{align}
I = \frac{x^{2}}{4} - \frac{x \sin(8x)}{16} -\frac{ \cos(8x)}{128}. 
\end{align}
Thus
\begin{align}
\int x \, \sin^{2}(4x) \, dx = \frac{x^{2}}{4} - \frac{x \sin(8x)}{16} - \frac{\cos(8x)}{128}.
\end{align}
