# Changing the integration limits takes a long time to evaluate

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?

• Some folks here prefer the quoted environment (> 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. – Michael E2 Jan 29 at 13:34
• @J.M. In the first case Integrate uses by-parts to get an integral in terms of ArcTan[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. – Michael E2 Jan 29 at 14:17
• I suspect branch cut checking has gotten more extensive and careful over time. – Michael E2 Jan 29 at 14:29
• 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.... – Michael E2 Jan 30 at 1:05
• @QuantumDot, will edit later; just leaving it up for a while for fun ;) – J. M.'s technical difficulties May 28 at 16:24

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}$$