Find $\int \sin^4x dx$ In my textbook, I came upon the following problem:
Problem: Find  $\int \sin^4x dx$
Since there was only given a solution sketch and I came to a different conclusion in one step, I ask if my following solution is correct.
Solution: In my solution, I use the following identities:
$$\sin^2x = \frac{1-\cos2x}{2} \tag{1} \label{1}$$
$$\cos^2x = \frac{1+\cos2x}{2} \tag{2} \label{2}$$
Now we can write
$$\int \sin^4x dx = \int \left( \frac{1-\cos2x}{2} \right)^2 dx = \int\frac{1}{4}dx - \frac{1}{2}\int \cos2xdx + \frac{1}{4} \int cos^22xdx$$
My textbook gave the last term in this equation as $\int\frac{1}{4}dx - \int \cos2xdx + \frac{1}{4} \int cos^22xdx$. But, since $(1-\cos2x)^2 = 1 - 2\cos2x + \cos^22x$ the middle integral should simplify to $- \frac{1}{2}\int \cos2xdx$. Is this correct? If not, how do we come to the conclusion of $-\int \cos2xdx$?
To complete the integration, we have
$$\int \frac{1}{4} dx = \frac{x}{4}$$
$$ - \frac{1}{2} \int \cos 2xdx = - \frac{1}{4}\int \cos u du = - \frac{1}{4} \sin2x = - \frac{\sin2x}{4}$$
and
$$\frac{1}{4} \int cos^22xdx = \frac{1}{4} \int \frac{1 + cos4x}{2}dx = \frac{4x + \sin 4x}{32}$$
so
$$\int \sin^4x dx = \frac{x}{4} - \frac{\sin2x}{4} + \frac{4x + \sin 4x}{32}$$
Are these conclusions and computations correct? Thanks for any help!
EDIT: According to the correction of @Eevee Trainer I now use the correct identity $\cos^2x = \frac{1+\cos2x}{2}$. The rest of the computation should be correct. Thanks all for your help and comments!.
 A: To answer the first discrepancy with the textbook, note that
$$\left( \frac{1 - \cos(2x)}{2} \right)^2
= \frac{1- 2 \cos(2x) + \cos^2(2x)}{4}$$
Hence the middle term indeed has a factor of $-1/2$.
Textbooks are just as prone to errors as anything else, being made by humans; it happens. Not much one can do but contact the authors (after doing one's due diligence as you are!).

For the rest of the computations, note that in claiming
$$\int \cos^2(2x) \, \mathrm{d}x
= \int \frac{1 - \cos(4x)}{2} \, \mathrm{d}x$$
you used the identity for $\sin^2(x)$, not $\cos^2(x)$. This should be a $+$, not a $-$.
Your subsequent step then has $\int \cos(x) \, \mathrm{d}x = - \sin(x)+C$, in its essence, when it should be positive.
My guess is you thought about the $\cos^2(x)$ identity the entire time but wrote the middle step with a typo.
Aside from this, as ever, you need a constant of integration in your final answer (a $+C$).
A: I like to rewrite things  so as to reduce errors; as $\sin^4 x$  is even of small degree (as a polynomial in $\sin, \cos$), it can be written in terms of $\cos 2 x$ and $\cos 4x.$ After that the integral is immediate, finally we may wish to expand that back into a polynolial in sine and cosine.
First
$$ \cos 2x = 2 \cos^2 x - 1 = 1 - 2 \sin^2 x$$
Good start. Next $ \cos 4x = 2 \cos^2 2 x - 1 .$  However we know $ \cos 2x = 1 - 2 \sin^2 x$  and find $\cos^2 2x = 1 - 4 \sin^2 x + 4 \sin^4 x.$   Plug that into $ \cos 4x = 2 \cos^2 2 x - 1 ,$  I get
$$ \cos 4x = 8 \sin^4 x - 8 \sin^2 x + 1$$
Anyway, my calculations may be checked for themselves, before starting any calculus, and any necessary corrections made.
Again, I get
$$ \sin^4 x = \; \frac{1}{8} \; \left( \cos 4x - 4 \cos 2 x + 3 \right) = \frac{\cos 4x}{8} - \frac{\cos 2x}{2} + \frac{3}{8} $$
The integral...
$$ \int \sin^4 x dx = \frac{\sin 4x}{32} - \frac{\sin 2x}{4} + \frac{3x}{8} $$
I note that you did not combine the two $x$  terms in your last line
A: An alternative approach: A complex variable identity reduces the problem to an exercise in the Binomial Theorem.
$$\begin{align}
\sin^4 x &= \left( \frac{1}{2i} (e^{ix}-e^{-ix})\right)^4 \\
&= \frac{1}{16} \left( e^{4ix} -4 e^{2ix} +6 -4 e^{-2ix} + e^{-4ix} \right)
\end{align}$$
so
$$\begin{align}
\int \sin^4 x \;dx &= \frac{1}{16} \left( \frac{1}{4i} e^{4ix} - \frac{4}{2i} e^{2ix} + 6x + \frac{4}{2i} e^{2ix} - \frac{1}{4i} e^{4ix} \right) + C \\
&= \frac{1}{16} \left( \frac{1}{4i} (e^{4ix}-e^{-4ix}) -\frac{4}{2i}(e^{2ix}-e^{-2ix}) +6x \right) + C \\
&=\frac{1}{16} \left( \frac{1}{2} \sin 4x -4 \sin 2x +6x \right) + C \\
&= \frac{1}{32} \sin 4x -\frac{1}{4} \sin 2x +\frac{3}{8} x + C
\end{align}$$
