# How do you evaluate \int ( \sin x + \cos x ) ^ { 2} d x ?

Nov 6, 2017

$x - {\cos}^{2} \left(x\right) + C$

or

$x + {\sin}^{2} \left(x\right) + C$

#### Explanation:

You can't tackle this integral as it is. To solve it, you'll need to break it down into something you can work with. The best course of action is to foil out the ${\left(\sin x + \cos x\right)}^{2}$:

$\int \left({\sin}^{2} x + {\cos}^{2} x + 2 \sin x \cos x\right) \mathrm{dx}$

Now, there's something we can work with. Recall that ${\sin}^{2} x + {\cos}^{2} x = 1$. Therefore, we can break the above up into two separate indefinite integrals:

$\int \left({\sin}^{2} x + {\cos}^{2} x\right) \mathrm{dx} + \int \left(2 \sin x \cos x\right) \mathrm{dx}$

Applying our identity:

$\int \left(1\right) \mathrm{dx} + \int \left(2 \sin x \cos x\right) \mathrm{dx}$

$\int \left(1\right) \mathrm{dx}$ is just $x + C$. The second piece, however, will require $u$-substitution to solve. Recall the steps of $u$-substitution:

• Set $u = \text{some value}$.
• Set it to something that will cancel out other $x$ terms in the integral.
• Take the derivative of both sides of that equation with respect to $x$.
• Solve for $\mathrm{dx}$ in terms of something "* du
• Plug that in for $\mathrm{dx}$ in your original integral.

Note that you can pick either $\cos \left(x\right)$ or $\sin \left(x\right)$ to be your $u$, and still be able to solve the problem. Your final answer will look slightly different in each case, but the process is more or less the same. I picked $u = \cos \left(x\right)$:

Let $u = \cos \left(x\right)$
$\frac{\mathrm{du}}{\mathrm{dx}} = - \sin \left(x\right)$
$\mathrm{dx} = \frac{- \mathrm{du}}{\sin} \left(x\right)$

Plug back in:

$\implies - 2 \int \cancel{\sin \left(x\right)} u \frac{\mathrm{du}}{\cancel{\sin \left(x\right)}}$
$\implies - 2 \int \left(u\right) \mathrm{du}$

Now, we just evaluate the indefinite integral in terms of $u$:

$\implies - 2 {u}^{2} / 2 + C$
$\implies - {u}^{2} + C$

Since we started with $x$, we should plug back in our substituted value for $u$:

$\implies - {\left[\cos \left(x\right)\right]}^{2} + C$

Now we tag on the answer from the other part of the integral:

$\implies x - {\cos}^{2} x + C$

And that's your final answer. If you want to check if it is correct, just take a derivative, and you should be able to get back to your original expression.

Also note that if you had substituted $u = \sin \left(x\right)$, you'd have got a slightly different final answer. However, if you took the derivatives of both expressions, you'd find that you still get the same original expression.

Hope that helped :)