13
$\begingroup$

Bug introduced in 5.0 or earlier and fixed in 11.3


It looks like this.

NIntegrate[1/(2 + Sin[x + y]), {x, 0, 2 Pi}, {y, 0, 2 Pi}]
22.7929
Integrate[1/(2 + Sin[x + y]), {x, 0, 2 Pi}, {y, 0, 2 Pi}]
0

Zero result is wrong since the denominator is nonsingular and always positive. Why is this or just a bug?

I noticed this more than three years ago (Version 9) and found it persisting till Version 11.2.

$\endgroup$
1
  • 3
    $\begingroup$ The reason for the exception is not a pole (which is absent in the region of integration) but a discontinuity in the indefinite integral. A simplified case is $\int \frac{1}{\sin (x)+2} \, dx = \frac{2}{\sqrt{3}} \tan ^{-1}\left(\frac{2 \tan \left(\frac{x}{2}\right)+1}{\sqrt{3}}\right)$. Dealing correctly with discontinuous antiderivatives has been widely discussed in this forum. $\endgroup$ Commented Nov 21, 2017 at 19:49

2 Answers 2

13
$\begingroup$

Using

Integrate[1/(2 + Sin[x + y]), {x, 0, 2 Pi}, {y, 0, 2 Pi}, PrincipalValue -> True]

Mathematica graphics

N[%]

Mathematica graphics

From help

Mathematica graphics

Mathematica sees a simple pole in the integrand. That is why it says

 Integrate[1/(2+Sin[x+y]),{x,0,2 Pi}]

Mathematica graphics

I actually do not see the pole myself. Since $\sin()$ can only be between $-1\dots1$, so integrand denominator can't be zero. But Mathematica says there is a pole there! Needs more investigation to find why Mathematica wants $y$ to be only between $-\pi\dots\pi$.

Update


I had to go back to version 2.2 to get Mathematica to give the same result as Integrate without using any options. (I could not test this on version 5 and 6 at this time)

Here is screen shot from version 2.2 on windows XP

Mathematica graphics

$\endgroup$
2
  • 1
    $\begingroup$ Shifting either or both intervals to {-Pi, Pi} works. Integrate[1/(2 + Sin[x + y]), {x, 0, 2 Pi}, {y, -Pi, Pi}], Integrate[1/(2 + Sin[x + y]), {x, -Pi, Pi}, {y, 0, 2 Pi}], and Integrate[1/(2 + Sin[x + y]), {x, -Pi, Pi}, {y, -Pi, Pi}] each evaluates to (4*Pi^2)/Sqrt[3]. $\endgroup$
    – Bob Hanlon
    Commented Nov 20, 2017 at 18:25
  • 1
    $\begingroup$ Nasser, Bob, please see my comment to the OP. $\endgroup$ Commented Nov 21, 2017 at 19:54
2
$\begingroup$

On new Mathematica 11.3:

Integrate[1/(2 + Sin[x + y]), {x, 0, 2 Pi}, {y, 0, 2 Pi}]

$$\frac{4 \pi ^2}{\sqrt{3}}$$

$\endgroup$

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.