# Math Help - Integration calculator error? doubt it.

1. ## Integration calculator error? doubt it.

Hi,
When integrating 2sin(x)cos(x), I used a simple u sub and got sin^2(x), no big deal. However when I pop this into wolfram, it results in (-1/2)cos(2x). This is the link Wolfram Mathematica Online Integrator
I take the derivative of what wolfram gives me and it certainly is not 2sin(x)cos(x). Can someone tell me what I did wrong please?

2. you didn't do anything wrong.

graph $y = \sin^2{x}$ and $y = -\frac{\cos(2x)}{2}$

... what do you see?

3. Originally Posted by pberardi
Hi,
When integrating 2sin(x)cos(x), I used a simple u sub and got sin^2(x), no big deal. However when I pop this into wolfram, it results in (-1/2)cos(2x). This is the link Wolfram Mathematica Online Integrator
I take the derivative of what wolfram gives me and it certainly is not 2sin(x)cos(x). Can someone tell me what I did wrong please?
Both are correct.

Differentiate your solution, and you get $2\sin x\cos x$

However, when you differentiate $-\tfrac{1}{2}\cos(2x)$, you get $\sin(2x)$

But from trig, $\sin(2x)=2\sin x\cos x$.

This shows that both solutions are the same

Does this clarify things?

EDIT: Skeeter beat me....

4. Hello, pberardi!

When integrating $2\sin x\cos x$, I used a simple u sub and got $\sin^2\!x$

However when I pop this into wolfram, it results in: . $-\tfrac{1}{2}\cos(2x)$
This is a classic problem/puzzle . . .

You had: . $2\int\sin x(\cos x\,dx)$

. . You let: $u \,=\,\sin x\quad\Rightarrow\quad du \,=\,\cos x\,dx$

. . Substitute: . $2\int u\,du \:=\:u^2+C$

. . Back-substitute: . $\boxed{\sin^2\!x + C}$

We also have: . $2\int \cos x(\sin x\,dx)$

. . Let: $u \,=\,\cos x\quad\Rightarrow\quad du \,=\,-\sin x\,dx \quad\Rightarrow\quad \sin x\,dx \,=\,-du$

. . Substitute: . $2\int u(-du) \:=\:-\int u\,du \:=\:-u^2 + C$

. . Back-substitute: . $\boxed{-\cos^2\!x + C}$

We have the identity: . $2\sin\theta\cos\theta \:=\:\sin2\theta$

So: . $\int2\sin x\cos x\,dx \:=\:\int\sin2x\,dx \:=\:\boxed{-\tfrac{1}{2}\cos2x + C}$

And all three answers are correct!

5. Ok that all makes sense, so they are the same function. But why is it that when I plug in pi/4 in sin^2(x) I get 1/2 and when I plug in pi/4 into (-1/2)cos(2x), I get 0? Shouldn't they give me the same answer? I know this is silly and I am probably just making a stupid error somewhere but I dont know where.

6. Originally Posted by pberardi
Ok that all makes sense, so they are the same function. But why is it that when I plug in pi/4 in sin^2(x) I get 1/2 and when I plug in pi/4 into (-1/2)cos(2x), I get 0? Shouldn't they give me the same answer? I know this is silly and I am probably just making a stupid error somewhere but I dont know where.
If you're using the anti-derivative to evaluate a definite integral, then you will be substituting two numbers (the upper terminal and the lower terminal). Then you will get the same answer, assuming you perform the calculation correctly.

7. Originally Posted by pberardi
Ok that all makes sense, so they are the same function. But why is it that when I plug in pi/4 in sin^2(x) I get 1/2 and when I plug in pi/4 into (-1/2)cos(2x), I get 0? Shouldn't they give me the same answer? I know this is silly and I am probably just making a stupid error somewhere but I dont know where.
they are not the same function ... did you look at their graphs as I recommended?

graph them. what do you see?