4
$\begingroup$

Bug introduced in 10 and persists through 12.0 or later


I created this InterpolatingFunction, and NIntegrate gives an absurd result

I load the function and plot its derivative:

intfunc = << "intfunc2.m"
Plot[intfunc'[t], {t, 0, 1627577.2}, PlotRange -> All]

function derivative plot

From the curve, the maximum value of the plot is of the order of $10^{-8}$

When I try to integrate this function over the interval, I would've expected a quantity of about an order of $10^{-1}$. Instead I get something very different:

NIntegrate[intfunc'[tt], {tt, 0, 1627577.2}]

This gives me $-2.6 \times 10^{69}$! Clearly something is wrong in my interpolating function. Any idea what is causing this weird result?

$\endgroup$
9
  • $\begingroup$ may be it is a bug. But to be able to make sure, someone needs to see your input file there. $\endgroup$
    – Nasser
    Dec 24, 2015 at 23:01
  • $\begingroup$ It is in the link in the first line of the post $\endgroup$
    – lurscher
    Dec 24, 2015 at 23:44
  • $\begingroup$ Your link is to a site that is blocked by Norton Security as a malicious web site. $\endgroup$
    – Bob Hanlon
    Dec 24, 2015 at 23:48
  • $\begingroup$ ugh. Is a file upload site. What would be a suggested place to upload this? $\endgroup$
    – lurscher
    Dec 24, 2015 at 23:49
  • 1
    $\begingroup$ is the m file so large that you can't simply post the relevant plain source code here? myself do not download attachment from strange web sites. $\endgroup$
    – Nasser
    Dec 24, 2015 at 23:57

1 Answer 1

5
$\begingroup$

It seems there is a bug in symbolic processing code of NIntegrate and Integrate in version 10 (the same bug appears with Integrate). One workaround is to disable symbolic processing by integrating a "black-box" function instead of the actual function:

intfunc = Import["http://pastebin.com/raw/vQK1U0xZ", "Package"];
f[t_Real] = intfunc'[t];
NIntegrate[f[tt], {tt, 0, 1627577.2}, Method -> "Oscillatory", WorkingPrecision -> 50]
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in tt near {tt} = {349671.99051049186008855806291520295494990982872420}. NIntegrate obtained 0.057331917380647974851033238907542786073579734962061`50. and 4.5174922699302067733913885651850484430861561149963`50.*^-9 for the integral and error estimates. >>
0.057331917380647974851033238907542786073579734962061

The same result can be achieved by switching off symbolic processing via the Method option:

NIntegrate[intfunc'[tt], {tt, 0, 1627577.2}, 
 Method -> {Automatic, "SymbolicProcessing" -> 0}, WorkingPrecision -> 50]

It is interesting that explicit Method -> "Oscillatory" is sufficient to avoid the bug:

NIntegrate[intfunc'[tt], {tt, 0, 1627577.2}, Method -> "Oscillatory"]
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in tt near {tt} = {352828.}. NIntegrate obtained 0.05733276909199948` and 7.840132211343309`*^-7 for the integral and error estimates. >>
0.0573328
$\endgroup$
1
  • $\begingroup$ whoa! I didn't knew you could import pastebin samples directly into Mathematica. So smooth $\endgroup$
    – lurscher
    Dec 26, 2015 at 17:20

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .