In contrast to earlier versions, Mathematica 11.3 and 12.0 generate lots of underflow errors from my code, e.g.
"General::munfl: Exp[-11250.] is too small to represent as a normalized machine number; precision may be lost."
A minimal working example:
sigma=0.01;
gaussian=Function[x,1/(Sqrt[2Pi] sigma) Exp[-1/2(x/sigma)^2]]
gaussianP[x_]=D[gaussian[x],x]
gaussianP[1.5]
The background of this error is discussed in:
New General::munfl error and loss of precision How to flush machine underflows to zero and prevent conversion to arbitrary precision?
In short: Mathematica still detects MachineNumber underflows, but it does no longer switch to arbitrary precision mode. Instead, it produces a result with less digits if any.
The solution proposed in question 170416 does not solve my problem since Exp[x] expressions are converted to E^x upon evaluation, cf. https://reference.wolfram.com/language/ref/Exp.html. Thus it is not sufficient to only modify Exp[].
Question 1: How can I restore the behavior of previous versions?
Considering the solution in 170416, how can I tell Mathematica to treat E^MachineNumber in the same way as Exp[MachineNumber]?
There are already attempts to rewrite E^x expressions in terms of Exp[x]: Format Exp[] in output Function to Expand exponentials
How can these be used in my case?
Question 2: How can I handle underflow manually?
I feel uncomfortable with Mathematica producing results of unknown precision. Instead, I would like to define locally a threshold by myself, below which the outcome of Exp[] is set to zero at MachinePrecision.
I would be grateful for any help.
Check
$\endgroup$