Integrate[x*Sin[x]/(1 + Cos[x]^2), {x, 0, π}]
π^2/4
But
Integrate[x*Sin[x]/(1 + Cos[x]^2), {x, 0, 2 π}]
takes much more time to do.
Why?
I suppose that discontinuity of the antiderivative at $3/2\pi$ and $5/2\pi$ is the reason.
It is interesting to notice that the raw answer to the second integral is enormous, but FullSimplify
reduces it to
$$-\frac{\pi^2}{2}$$
> output
) for output. (I don't because it doesn't format properly is less readable.) Others prefer quoted-code (> `output`
), which is how I altered it, because it formats correctly; some dislike the two-tone formatting. (I prefer commented code,(* output *)
, because I can copy the input and output, and switch to M to run it without editing, and I have the output to compare with there in M. But some seem to prefer the look of the other styles over the functionality of this one.) To each their own. $\endgroup$Integrate
uses by-parts to get an integral in terms ofArcTan[Cos[x]]
, which is 1-1 over{x, 0, Pi}
but not over{x, 0, 2 Pi}
. I can't tell if that's the reason or not that a different approach is used. Nonetheless more extensive checking is done in the second case. $\endgroup$Integrate[x*Sin[x]/(1 + Cos[x]^2), {x, Pi, 2 Pi}]
is slow, too. So my 1-1 comment is probably not relevant.Integrate[x*Sin[x]/(1 + Cos[x]^2), {x, -Pi, 0}]
is fast, and the integral over{x, -Pi/2, Pi/2}
is medium-slow, about half the time as over{x, Pi, 2 Pi}
. I'm thinking at this point it's not worth going much deeper into why.... $\endgroup$