# 0 vs 0.0 in numerical integrand- bug?

1. Aug 13, 2012

### muppet

Hi All,

A slight problem I've had with a function defined by a numerical integral. The definition is
f[q_,c_,n_]:=NIntegrate[\[Beta]*BesselJ[0,q*\[Beta]]*(E^(I*c*((\[Beta] BesselK[1,\[Beta]] HypergeometricPFQ[{1},{1+n/2,1+n/2},\[Beta]^2/4]+n BesselK[0,\[Beta]] HypergeometricPFQ[{1},{1+n/2,n/2},\[Beta]^2/4])/n^2))-1),{\[Beta],0,Infinity},Method->"ExtrapolatingOscillatory"]

I can evaluate this at q=0 without problems. But I've been filling out tables of values with the intent of constructing interpolating functions, and getting this error message:
Power::infy: Infinite expression 1/0. encountered. >>
\[Infinity]::indet:Indeterminate expression ComplexInfinity encountered.
NIntegrate::nlim: \beta=Indeterminate is not a valid limit of integration.

Looking at the results this seems to be occuring when q vanishes; I'm getting results like

NIntegrate[\[Beta]*BesselJ[0, 0.*\[Beta]]*(E^(I*7.976042329074821*((\[Beta]*BesselK[1, \[Beta]]*HypergeometricPFQ[{1}, {1 + 3/2, 1 + 3/2}, \[Beta]^2/4] + 3*BesselK[0, \[Beta]]*HypergeometricPFQ[{1}, {1 + 3/2, 3/2}, \[Beta]^2/4])/3^2)) - 1), {\[Beta], 0, Infinity}, Method -> "ExtrapolatingOscillatory"]

Sure enough, evaluating f[0.00,18,4] reproduces these messages, wheras f[0,18,4] gives me a nice answer. Can someone explain to me what's going on here? Is this actually a bug or am I missing something about how Mathematica is handling the decimals?

2. Aug 13, 2012

### gsal

Don't know anything about Mathematica...just a quick awareness note....are you aware of integral division? does mathematica use it?

3.0/2 = 1.5
3/2.0 = 1.5

3/2 = 1

3.0/4 = 0.75
3/4.0 = 0.75
3/4 = 0

just checking

3. Aug 13, 2012

### muppet

Thanks for your reply- I am aware of it, and Mathematica doesn't as far as I'm aware use it- it gives 3/2 as a fraction by default.

4. Aug 13, 2012

### Bill Simpson

In Mathematica
0. or 0.0 or 0.000 or 0.0000 will all be displayed as 0. and are approximately zero with MachinePrecision of about 15.9546 digits and Accuracy of about 307.653. Read the help on this.
With more digits after the decimal point or with other tricks I think I remember you can force even zero to have additional precision, but Precision[0.000000000000000000000000000000000000000000000000] still says it is MachinePrecision.

1/0. is approximately infinity but displays as ComplexInfinity.
1/0 is exactly ComplexInfinity, I think.
ComplexInfinity and DirectedInfinity and Indeterminate are all documented in the help pages.

Accuracy and precision are at least as big a tar pit in Mathematica as they are in numerical analysis, and probably bigger.

5. Aug 13, 2012

### muppet

Thanks for your reply. I don't see how I'm dividing by zero anywhere! I have absolutely no idea why mathematica is generating that message. I have even less of a clue why the problem arises if my 0 is a machine precision number, but not if it's exactly zero.

6. Aug 13, 2012

### Staff: Mentor

Which version of Mathematica are you using? I evaluated f[0,18,4] and f[0.00,18,4] and got -2.85044 + 5.52726 I each time with no error messages in either case. I use 8.0.1.0 on 32-bit Windows.

7. Aug 13, 2012

### muppet

Thanks DaleSpam. I'm using mathematica 7.0.1.0 on Ubuntu 12.04. That's the result I got for f[0,18,4] . Bug?

8. Aug 14, 2012

### Staff: Mentor

Looks like it. Apparently a bug that they found and fixed in version 8.

9. Aug 14, 2012

### muppet

Ah well, integrating from 0.0001 it is... thanks for your help.