7

I found some of the values remained unevaluated using the following code

Table[NIntegrate[Sin[i x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}], {i,70, 90}]

Pick them out, the unevaluated ones remain unevaluated. For example,

NIntegrate[Sin[81 x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}]

returns unevaluated. However, using simple trigonometry expansion formula,

NIntegrate[(Sin[80 x] Cos[x] + Cos[80 x] Sin[x])/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}]

gives the correct result.

Is it a bug?

vapor
  • 7,911
  • 2
  • 22
  • 55

1 Answers1

9

Using the Method option with the following settings seems to work:

NIntegrate[Sin[81 x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2},  
           Method -> "LevinRule"]
NIntegrate[Sin[81 x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2},
           Method -> "LocalAdaptive"]
NIntegrate[Sin[81 x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}, 
           Method -> {Automatic, "SymbolicProcessing" -> False}]
NIntegrate[Sin[81 x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}, 
           Method -> {"SymbolicPreprocessing", "OscillatorySelection" -> False}]

all give

(* 1.5708 *)

So does using an explicit setting for WorkingPrecision option:

NIntegrate[Sin[81 x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}, WorkingPrecision -> 10]
(* 1.570796327 *)

To check all the entries in your table:

Table[{i, NIntegrate[Sin[i x]/((2^x + 1) (Sin[x])), {x, -Pi/2, Pi/2}, 
      Method -> "LevinRule"]}, {i, 70, 90}] // Grid[#, Dividers -> All] &

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
  • Thank you, I got the values. I am still a little bit curious about why the default method didn't work for some very specific values. – vapor Mar 10 '15 at 09:15
  • @Felix, The error message says NIntegrate::errprec: Catastrophic loss of precision in the global error estimate due to insufficient WorkingPrecision or divergent integral. A "local" method is able to deal with the oscilattion around the origin. – kglr Mar 10 '15 at 09:23
  • I see. Interestingly, I am not getting any error messages. – vapor Mar 10 '15 at 09:28
  • @felix, maybe version/os difference; i am using version 9.0.1.0 (windows 8 x64) – kglr Mar 10 '15 at 09:29
  • but both are the same function. So both have the same oscillation around origin. Screen shot: Mathematica graphics that is what strange about this. I get the same NIntegrate::errprec: Catastrophic loss of precision in V 10.02 on the bad integral also. – Nasser Mar 10 '15 at 09:30
  • @kguler I am using 10.0.2 at OS X. Since Nasser got the same error message, I would expect a problem with my copy of Mathematica. – vapor Mar 10 '15 at 09:33
  • @Nasser, good point. – kglr Mar 10 '15 at 09:54
  • presumably the different form causes NIntegrate to choose a different method – george2079 Mar 10 '15 at 11:22
  • WorkingPrecision worked. I was thinking about MaxRecursion and AccuracyGoal – vapor Mar 10 '15 at 13:07
  • @Felix, thank you for the Accept. – kglr Mar 10 '15 at 13:43