Mathematica session

Integrate[x*Sin[x]/(1 + Cos[x]^2), {x, 0, π}]



Integrate[x*Sin[x]/(1 + Cos[x]^2), {x, 0, 2 π}]

takes much more time to do.


  • $\begingroup$ 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. $\endgroup$
    – Michael E2
    Jan 29, 2020 at 13:34
  • 2
    $\begingroup$ @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. $\endgroup$
    – Michael E2
    Jan 29, 2020 at 14:17
  • 1
    $\begingroup$ I suspect branch cut checking has gotten more extensive and careful over time. $\endgroup$
    – Michael E2
    Jan 29, 2020 at 14:29
  • 1
    $\begingroup$ 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$
    – Michael E2
    Jan 30, 2020 at 1:05
  • 1
    $\begingroup$ @QuantumDot, will edit later; just leaving it up for a while for fun ;) $\endgroup$ May 28, 2020 at 16:24

1 Answer 1


I suppose that discontinuity of the antiderivative at $3/2\pi$ and $5/2\pi$ is the reason. enter image description here

It is interesting to notice that the raw answer to the second integral is enormous, but FullSimplify reduces it to $$-\frac{\pi^2}{2}$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.