# Integral (sin x/2 - cos x/2)^2

1. Dec 26, 2011

### b0rsuk

1. The problem statement, all variables and given/known data

I'm unable to solve this integral. I get a result, but it doesn't match the solution.

\int(sin \frac{x}{2} - cos \frac{x}{2})^2 \mathrm{dx}
$$\int(sin \frac{x}{2} - cos \frac{x}{2})^2 \mathrm{dx}$$

3. The attempt at a solution

(attachment?)
I'd be grateful for highligting my errors.

#### Attached Files:

• ###### CodeCogsEqn.gif
File size:
5.9 KB
Views:
1,004
2. Dec 26, 2011

### Thaakisfox

You didnt do the substitution properly.
And there is no need for substitution. Note the identity: $\sin(2x)=2\sin x \cos x$

3. Dec 26, 2011

### Harrisonized

2sin(x)cos(x) = sin(2x)dx

∫ [2sin(x)] [cos(x)dx] = sin2(x)
∫ [-2cos(x)] [-sin(x)dx] = -cos2(x)
∫ sin(2x)dx = -(1/2)cos(2x)

4. Dec 26, 2011

### Curious3141

Hint: simplify with the double-angle formula first.
sin(2z) = 2(sinz)(cosz)

Now put z = (1/2)x and see what you get on the RHS. What do you get on the LHS? Integrate that.

5. Dec 26, 2011

### SammyS

Staff Emeritus
Hello b0rsuk. Welcome to PF !

6. Dec 26, 2011

### b0rsuk

Hmm. In such case,
$$2 \int \sin \frac{x}{2} \cos \frac{x}{2} dx = \int 2 \sin \frac{x}{2} \cos \frac{x}{2} dx = \int \sin x dx = -\cos x + C_1$$

But what about the first integral ? I know:
$$\sin^2 x + \cos^2 x = 1$$
But I have:
$$\int\sin^2 \frac{x}{2} + \cos^2\frac{x}{2} dx$$
Can I simply get around that with substitution ? Say,
$$\frac{x}{2} = t, \frac{1}{2} = dt$$
Then I get
$$\frac{1}{2}(\sin^2 t + \cos^2 t)$$
Does it equal 1 (or, actually, 1/2) ?
--------------------------

The solution, according to the book:
$$x + \cos x + C$$
Yes, that's a plus.

---------------
You people are scary. I'm a CS graduate and I came here to defeat my arch-nemesis, math. This time, without time pressure. You rob me of any excuses I might have to procrastinate solving examples.

7. Dec 26, 2011

### Curious3141

$\sin^2x + \cos^2x = 1$ is an identity. Meaning the value of x can be *anything*. Even if you replace the x with x/2, it still holds (just to be clear, that means $\sin^2 \frac{x}{2} + \cos^2 \frac{x}{2} = 1$). Don't bother with substitution, etc. Just recognise this and reduce the integrand to 1 first.

So the first integrand is 1, and the integral is x.

The second integrand is $-\sin x$ (you correctly reflected the minus sign in your first post, but then you must have forgotten it in your most recent one). The integral is $\cos x$.

So the final answer is $x + \cos x + C$.

Last edited: Dec 26, 2011
8. Dec 26, 2011

### D H

Staff Emeritus
In this case, simple trig substitutions are all you need.
$$\left(\sin\frac x 2 - \cos \frac x 2\right)^2 = 1 - \sin x$$
This is an identity, so $\int (\sin x/2 - \cos x/2)^2 dx = \int (1-\sin x)\,dx$. The right hand side obviously integrates to $x+\cos x + c$.

So how to arrive at that identity?

One way is to expand the square,
$$\left(\sin\frac x 2 - \cos \frac x 2\right)^2 = \sin^2 \frac x 2 - 2 \sin \frac x 2 \cos \frac x 2 + \cos^2 \frac x 2$$
Now use the identities $\sin^2 \theta + \cos^2\theta = 1$ and $\sin(2\theta) = 2 \sin\theta\cos\theta$ to arrive at the desired identity
$$\left(\sin\frac x 2 - \cos \frac x 2\right)^2 = 1 - \sin x$$

Another way is to use the identity $\sin\theta- \cos \theta = \sqrt 2 \sin(\theta-\pi/4)$. This comes in handy at times, but doesn't quite fall into the camp of identities you should just "know". With this,
$$\left(\sin\frac x 2 - \cos \frac x 2\right)^2 = 2\sin^2\left(\frac x 2 - \frac \pi 4\right) = 2\sin^2\left(\frac 1 2(x-\pi/2)\right)$$
Now use the half-angle formulae $2\sin^2(u/2) = 1-\cos u$. The half-angle formulae come into play quite often. With this,
$$\left(\sin\frac x 2 - \cos \frac x 2\right)^2 = 1-\cos\left(x-\frac{\pi} 2\right) = 1 - \sin x$$

9. Dec 26, 2011

### SammyS

Staff Emeritus
After splitting this up into two integrals, the first one is fine.

$\displaystyle -2\int\left(\sin\left(\frac{x}{2}\right)\cos\left( \frac{x}{2}\right)\right)dx=-4\int\left(\frac{1}{2}\sin\left(\frac{x}{2}\right)cos\left(\frac{x}{2}\right)\right)dx$
$\displaystyle=-4\int\left(\sin(t)\cos(t)\right)dt$​
After that you dropped a minus sign.

So, the final answer should be $\displaystyle x-2\sin^2\left(\frac{x}{2}\right)+C$

I know that's not the book's answer, but notice that
$1-2\sin^2(\theta)=\cos(2\theta)$

So substituting x/2 for θ and doing a bit of algebra gives

$\displaystyle -2\sin^2\left(\frac{x}{2}\right)=\cos(x)-1$​

Therefore, $\displaystyle x-2\sin^2\left(\frac{x}{2}\right)+C=x+\cos(x)-1+C$

-1+C is just a constant, one unit less than C.