0
$\begingroup$

Edit: So, while trying to figure out a minimal exmaple, I found out that my main problem was actually unrelated to this and it just happened to be that giant pile of warnings and error messages coming from this were hiding the real problem (which was just an index mismatch). Interestingly as you can see by running the following :

\[Omega]stepsize = 10/1000;
\[Omega]offset = -\[Omega]stepsize * 10^(-5) ;
\[Omega]max = 2
astep = 0.1;
aoffset = 0.0999;
maxa = 0.999;
maxj = Ceiling[(ArcTanh[maxa] + aoffset)/astep];
af[j_] = Tanh[astep j - aoffset];
\[Omega]p[i_, j_, k_] := \[Omega]stepsize i + \[Omega]offset + (
  k af[j])/(2 (1 + Sqrt[1 - af[j]^2]))
\[Kappa][j_] := 
 2 Pi (Sqrt[1 - af[j]^2]/(af[j]^2 + (1 + Sqrt[1 - af[j]^2])^2))^(-1)
testExponent[i_, j_, k_] := \[Omega]p[i, j, k] \[Kappa][j]
k = 10;
j = 29; testF[\[Omega]_] = 
 Interpolation[
   Table[{(i)*\[Omega]stepsize + \[Omega]offset, 
     1/(2 Pi) Sign[\[Omega]p[i, j, k]] 1/
      Internal`Expm1[testExponent[i, j, k]]}, {i, 1, 
     Ceiling[\[Omega]max/\[Omega]stepsize]}]][\[Omega]]
Plot[testF[\[Omega]], {\[Omega], \[Omega]stepsize + \[Omega]offset, 
  0.1}]
NIntegrate[
 testF[\[Omega]], {\[Omega], \[Omega]stepsize + \[Omega]offset, 2}]

for some reason it no longer likes the endpoint (despite finding an interpolating function up to w=2, the NIntegrate returns InterpolatingFunction::dmvali: The integration endpoint 2 in dimension 1 lies outside the range of data in the interpolating function. Extrapolation will be used.. I was doing a lot of integrals in parallel kernels and I hadn't yet turned that warning off, so I missed the real issue. I am very confused as to why this warning is firing though, it also seems to fire for some other endpoints in the range [0.01,2], though I couldn't find any that happen to work for the above example.

So I have a table of values, T, let's say we parmetrize it by a,b and c. I'm trying to make an interpolating function, F, in a. Schematically:

F[a_]=Table[
Interpolation[
Table[
{a,T[[a,b,c]]/(Exp[exponent[a,b,c]]-1)}
,{a,{avalues}]
,{b,{bvalues}},{c,{cvalues}}]

The exponent, exponent, goes through a large range of values from very negative to very positive, and T and E both go to 0 at the same point (in a way with a double sided limit for F). The problem I'm having though is not to do with any numerical instability of this point but when the denominator is very large. I am getting the error General::munfl when F is very close to 0 (with some examples below). I've looked at some other answers:

Underflow error General::munfl from E^x instead of Exp[x]

Asymmetric precision warnings with Plot[]. Cannot be fixed with Rationalize[] or WorkingPrecision

Underflow error General::munfl from E^x instead of Exp[x]

but I've not been able to successfully implement any of the suggested fixes. All I want to do is set these things to 0.

General::munfl: 3.79545*10^-308 0.31831 is too small to represent as a normalized machine number; precision may be lost.

General::munfl: 1/1.19906*10^308 is too small to represent as a normalized machine number; precision may be lost.

General::munfl: 1.00001 9.162856558197*10^-310 is too small to represent as a normalized machine number; precision may be lost.

General::stop: Further output of General::munfl will be suppressed during this calculation.
$\endgroup$
12
  • $\begingroup$ What happens if you compute T[[a,b,c]]/Internal`Expm1[E[a,b,c]] instead? $\endgroup$ Apr 20, 2020 at 12:14
  • $\begingroup$ Exactly the same errors $\endgroup$
    – user70153
    Apr 20, 2020 at 12:27
  • $\begingroup$ Then perhaps you could mention what T[[a,b,c]] is supposed to be. (I also forgot to say this, but E is that famous constant in Mathematica, so you aren't supposed to use it as a name of a function.) $\endgroup$ Apr 20, 2020 at 12:35
  • 1
    $\begingroup$ Then I think setting "these things" to zero is not what you want to do, OR, "these things" are not what I think they are. What are they? (Can't really help with NIntegrate without code to reproduce the problem.) $\endgroup$
    – Michael E2
    Apr 20, 2020 at 12:47
  • 1
    $\begingroup$ "while trying to figure out a minimal example, I found out that my main problem was actually unrelated to this" - at least you (hopefully) now understand why people should always try to find a minimal example before asking questions. ;) $\endgroup$ Apr 20, 2020 at 14:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.