5
$\begingroup$

I have an expression which has an analytical integral. But NIntegrate and Integrate gives different values. Why?

Mathematica version 11.2

Code and results:

w = 1 + 2/3 I; 
t0 = 1; 
n = 15; 
int1 = Integrate[Exp[I w t]/Sqrt[t^2 - t0^2] t^(-2 (n + 1)), {t, t0, ∞}]

(* 1/2 MeijerG[{{-15, 1/2, 1}, {}}, {{}, {-(31/2)}}, 1296/169 E^(4 I ArcTan[3/2]), 2] *)

N[int1, 30]

(* 0.0629985988586534758877615553402 - 0.0506478034220383880351981581571 I*)

int2 = 
  NIntegrate[Exp[I w t]/Sqrt[t^2 - t0^2] t^(-2 (n + 1)), {t, t0, ∞}, 
    WorkingPrecision -> 30]

(* 0.0597416653055238422645694709489 + 0.0963766277967734573626260768145 I *)
$\endgroup$

1 Answer 1

10
$\begingroup$

When NIntegrate doesn't issue errors, and using higher precision converges, than the most likely issue is that Integrate couldn't figure out how to handle branch cut issues correctly. One trick that I like to use in such cases is to replace a problematic parameter with a constant, integrate, and then replace the constant with the parameter after the integration. This approach works for your example:

int = Integrate[
    Exp[I EulerGamma t]/Sqrt[t^2 - t0^2] t^(-2(n+1)),
    {t, t0, Infinity}
];
int //TeXForm

$\frac{1}{2} \pi G_{1,3}^{2,0}\left(\frac{\gamma ^2}{4}| \begin{array}{c} \frac{33}{2} \\ 0,16,\frac{1}{2} \\ \end{array} \right)+\frac{i \gamma \pi \left(-1187907847944849195179530749609375 \gamma \pi \pmb{H}_0(\gamma )+204811697921525723306815646484375 \gamma ^3 \pi \pmb{H}_0(\gamma )-10619865818153185652945996484375 \gamma ^5 \pi \pmb{H}_0(\gamma )+262968105973316978072948484375 \gamma ^7 \pi \pmb{H}_0(\gamma )-3811131970627782290912296875 \gamma ^9 \pi \pmb{H}_0(\gamma )+36296494958359831342021875 \gamma ^{11} \pi \pmb{H}_0(\gamma )-244915620501753247921875 \gamma ^{13} \pi \pmb{H}_0(\gamma )+1234868674798755871875 \gamma ^{15} \pi \pmb{H}_0(\gamma )-4842622254112768125 \gamma ^{17} \pi \pmb{H}_0(\gamma )+15248922977413125 \gamma ^{19} \pi \pmb{H}_0(\gamma )-39607592149125 \gamma ^{21} \pi \pmb{H}_0(\gamma )+86973193125 \gamma ^{23} \pi \pmb{H}_0(\gamma )-165663225 \gamma ^{25} \pi \pmb{H}_0(\gamma )+283185 \gamma ^{27} \pi \pmb{H}_0(\gamma )-465 \gamma ^{29} \pi \pmb{H}_0(\gamma )+\gamma ^{31} \pi \pmb{H}_0(\gamma )+3672223350604861716931018752000000-439555539574028925954719543981250 \gamma ^2+21860810199430579221603421162500 \gamma ^4-534364371662614944284197113750 \gamma ^6+7699969665250582145431005000 \gamma ^8-73107664089026909823731250 \gamma ^{10}+492396088595579434129500 \gamma ^{12}-2479717198178026269750 \gamma ^{14}+9716498724447673200 \gamma ^{16}-30578708495906550 \gamma ^{18}+79392252095100 \gamma ^{20}-174283041330 \gamma ^{22}+331901640 \gamma ^{24}-567318 \gamma ^{26}+932 \gamma ^{28}-2 \gamma ^{30}\right) J_1(\gamma )}{32891354616711691270902251520000000}-\frac{i \gamma ^2 \pi \left(\gamma ^{28} (928-465 \pi \pmb{H}_1(\gamma ))+\gamma ^{30} (\pi \pmb{H}_1(\gamma )-2)+9 \gamma ^{26} (31465 \pi \pmb{H}_1(\gamma )-62826)-225 \gamma ^{24} (736281 \pi \pmb{H}_1(\gamma )-1470032)-61425 \gamma ^{20} (644812245 \pi \pmb{H}_1(\gamma )-1286776016)+45 \gamma ^{22} (1932737625 \pi \pmb{H}_1(\gamma )-3858073682)+326025 \gamma ^{18} (46772250525 \pi \pmb{H}_1(\gamma )-93299878898)-20539575 \gamma ^{16} (235770324075 \pi \pmb{H}_1(\gamma )-470043834848)+40186125 \gamma ^{14} (30728732237775 \pi \pmb{H}_1(\gamma )-61214081542046)-3656937375 \gamma ^{12} (66972877954125 \pi \pmb{H}_1(\gamma )-133262038442432)+201131555625 \gamma ^{10} (180461463869115 \pi \pmb{H}_1(\gamma )-358448255769854)-19912024006875 \gamma ^8 (191398522285425 \pi \pmb{H}_1(\gamma )-379070999744432)+139384168048125 \gamma ^6 (1886642576813475 \pi \pmb{H}_1(\gamma )-3716840811465638)-407698691540765625 (2913690606794775 \pi \pmb{H}_1(\gamma )-4503599627370496)+27179912769384375 \gamma ^2 (7535406741710625 \pi \pmb{H}_1(\gamma )-14210240345493274)-1294281560446875 \gamma ^4 (8205220674307125 \pi \pmb{H}_1(\gamma )-15982961194617584)\right) J_0(\gamma )}{32891354616711691270902251520000000}+\frac{9694845 i \gamma \left(1-\frac{5 \gamma ^2}{29}+\frac{7 \gamma ^4}{783}-\frac{13 \gamma ^6}{58725}+\frac{13 \gamma ^8}{4052025}-\frac{13 \gamma ^{10}}{425462625}+\frac{\gamma ^{12}}{4850273925}-\frac{\gamma ^{14}}{961970995125}+\frac{\gamma ^{16}}{245302603756875}-\frac{\gamma ^{18}}{77901098307361875}+\frac{\gamma ^{20}}{29991922848334321875}-\frac{\gamma ^{22}}{13658321665131450181875}+\frac{\gamma ^{24}}{7170618874194011345484375}-\frac{\gamma ^{26}}{4194812041403496637108359375}+\frac{\gamma ^{28}}{2554640533214729451998990859375}-\frac{\gamma ^{30}}{1187907847944849195179530749609375}\right) \pi }{134217728}$

Assuming that all instances of EulerGamma come from my insertion of EulerGamma into the integral, we can do:

N[int /. EulerGamma -> w, 30]

0.0597416653055238422640336356729 + 0.0963766277967734573617915628157 I

which reproduces the NIntegrate result.

$\endgroup$
3
  • $\begingroup$ Interesting! That was not a result I was expecting. $\endgroup$ Commented Feb 4, 2018 at 22:21
  • $\begingroup$ Note: people usually use Zeta[3] instead of EulerGamma (because the latter appears much more often than the former). $\endgroup$ Commented Feb 5, 2018 at 0:53
  • $\begingroup$ Thanks for very fast answer. It is really interesting solution. $\endgroup$ Commented Feb 5, 2018 at 6:13

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.