0

I wrote this little function

i[V_, d1_, d2_, T_] := Module[{eps, x},
  eps = 0.005;
  NIntegrate[
   Re[Abs[x - V]/Sqrt[(x + I eps - V)^2 - d1^2]] Re[Abs[x]/
     Sqrt[(x + I eps)^2 - d2^2]] (1/(Exp[(x - V)/T] + 1) - 1/(
      Exp[x/T] + 1)), {x, -10 T - Abs[V], 10 T + Abs[V]}, 
   WorkingPrecision -> 50, PrecisionGoal -> 10, MaxRecursion -> 50]
  ]

To calculate the IV characteristic of a SIS' junction.

When I request

i[0.75, 0.2, 0.4, 0.1]

I get a bunch of errors (NIntegrate::precw, NIntegrate::inumri) without a result (weirdly, it does that for these values specifically), the same as

With[{V = 0.75, d1 = 0.2, d2 = 0.4, T = 0.1, eps = 0.005}, 
 NIntegrate[
  Re[Abs[x - V]/Sqrt[(x + I eps - V)^2 - d1^2]] Re[Abs[x]/
    Sqrt[(x + I eps)^2 - d2^2]] (1/(Exp[(x - V)/T] + 1) - 1/(
     Exp[x/T] + 1)), {x, -10 T - Abs[V], 10 T + Abs[V]}, 
  WorkingPrecision -> 50, PrecisionGoal -> 10, MaxRecursion -> 50]]

However, if I remove the WorkingPrecision, PrecisionGoal and MaxRecursion, I get the result of 0.588058 + 0. I. Why is that so?

Michael E2
  • 235,386
  • 17
  • 334
  • 747
user16320
  • 2,396
  • 15
  • 25
  • 2
    Any constant with a decimal point will have "MachinePrecision" which is about 16 digits. These won't be transformed into something with 50 digits of precision for your WorkingPrecision. If you change all your decimal constants to exact fractions then those have "infinite" precision and almost all your warning and error messages go away. It looks like your complex values are also involved with decimals and so are only "approximately zero" which doesn't silently get truncated to "exactly zero". You can use the Chop function to tell it to turn approximate zero to exact zero. Does this explain? – Bill Dec 10 '18 at 06:16
  • There are more complicated ways to tell it that a constant has more precision, but that may be a little more than you are ready for at the moment, but when you are ready there is stuff like that. – Bill Dec 10 '18 at 06:20
  • 1
    You could apply SetPrecision[f, Infinity] or Rationalize[f, 0] to the integrand f. – Michael E2 Dec 10 '18 at 12:32
  • @MichaelE2 Setting precision to infinity works! However, I would like to know why MMA pretends that the function itself evaluates to indeterminate itself (that was one of the errors), if there's no singularities... – user16320 Dec 10 '18 at 19:03
  • I get an error that says it evaluates to Overflow, Indeterminate, or Infinity -- not necessarily Indeterminate. One might have numerical overflow or underflow even if there are no singularities. One clue is that that error goes away if you add the option Method -> {"GlobalAdaptive", "SymbolicProcessing" -> 0}. Perhaps IntegrationMonitor would give more clues. It seems that it will take some time to debug it. – Michael E2 Dec 10 '18 at 20:10

0 Answers0