Consider the following code:
r = 30; a = 95/100; q = (r Sqrt[1 - a^2]/a)^2/4; m = 4;
ce[m_, q_, x_] :=
MathieuC[MathieuCharacteristicA[m, q], q, x];
1/Pi NIntegrate[Cos[x] Sin[r /a Cos[x]] ce[m, q, x], {x, 0, 2 Pi},
Method -> "GaussKronrodRule"]
When I "hit" the shift+enter the first time, the result is:-0.0426046; the second "hit" gives -0.0673913. None of them is equal to the analytical result: -0.055116186075968306.
Note that to reproduce the bizarre behavior, you need change m to other integers and then change back to 4. If you make a fresh startup of Mathematica, it will give the right results no matter how many times you "hit". However, as long as you change m to other values and then change back, it will have the problem I described.
When $m\neq 4$, the numerical integration gives the right results.
MM version: 10.4.1.0
osx:10.11.6 EI Capitan
I also tried it on Linux with version 10.4.1, same problem.
-0.0551162using "11.1.1 for Linux x86 (64-bit) (April 18, 2017)". Can you give your precise version number and OS? – mikado Jun 16 '17 at 18:35mback and forth ? – an offer can't refuse Jun 17 '17 at 01:02-0.0551162is returned instantly for the first time, but if I changemback and forth and retry, the calculation never finishes then. – xzczd Jun 17 '17 at 03:16-0.0551162; then changem, evaluate, change back tom =4and get-0.0426046; finallyClearSystemCache[]and get-0.0615031. If I changemback and forth again, I get-0.0426046. And whenever I evaluateClearSystemCache[], I get-0.0615031. – Michael E2 Jun 17 '17 at 04:20mback and forth, and just like @MichaelE2, got the numbers changing. – march Jun 20 '17 at 03:31