I really can't figure out why my code sometimes is not working. My integrals involve two variables (k and kz). The integration range for both of them are from zero to infinity. I found out that in some cases (not often) when the working precision is in some specific range, Mathematica gives me an error message saying that "the integrand has evaluated to non-numerical values...". However, if I change WorkingPrecision to higher or lower value, it works just fine. I am not sure why. Hope you can help me with this.
I copy my code here. Thanks a lot!
Clear[sofindmassz];
sofindmassz[λ_, T_, μ_, Δ_, opt : OptionsPattern[{workprec -> 16}]] :=
Module[{wp, ϵ, ξ, E, dϵ, ddϵ, fBCSE, fBCSξ, f1d, mInth, mInt},
wp = OptionValue[workprec]; ϵ[h_] := k^2 + kz^2 + 2 λ h k; ξ[h_] := ϵ[h] - μ;
E[h_] := √(ξ[h]^2 + Δ^2);
dϵ[h_] := 2 kz; ddϵ = 2;
f1d[h_] := -Exp[ξ[h]/T]/(T (Exp[ξ[h]/T] + 1)^2);
fBCSE[h_] := Tanh[E[h]/(2 T)];
fBCSξ[h_] := Tanh[ξ[h]/(2 T)];
mInth[h_] := k ((2 f1d[h] + E[h]/Δ^2 ((1 + ξ[h]^2/E[h]^2) (fBCSE[h] - fBCSξ[h]) +
(1 - ξ[h]/E[h])^2 fBCSξ[h])) (dϵ[h])^2 - 1/2 (fBCSξ[h] - ξ[h]/E[h] fBCSE[h]) ddϵ);
mInt = mInth[1] + mInth[-1];
Return[-Quiet[
NIntegrate[
NIntegrate[mInt, {k, 0, kz},
Method -> {Automatic, "SymbolicProcessing" -> 0},
WorkingPrecision -> wp], {kz, 0, ∞},
Method -> {Automatic, "SymbolicProcessing" -> 0},
WorkingPrecision -> wp]] -
Quiet[NIntegrate[
NIntegrate[mInt, {kz, 0, k},
Method -> {Automatic, "SymbolicProcessing" -> 0},
WorkingPrecision -> wp], {k, 0, ∞},
Method -> {Automatic, "SymbolicProcessing" -> 0},
WorkingPrecision -> wp]]]]
For this code, if I run the following values,
sofindmassz[0, 0.14921714620005236`, 0.07455393513003296`, 1.016522853606922`, workprec -> 15]
the error messages pops up.
If I change workprec to 14. It works! Don't know what's wrong.

NIntegrate. See 69638. Why it singles outworkprec -> 15is unclear to me, although it may be related to shifting from double precision to higher. – bbgodfrey Dec 25 '14 at 03:22WorkingPrecisionproduce warning messages too, butQuietsuppresses them. – bbgodfrey Dec 25 '14 at 12:48