Stand-alone C# code for exp(x) – 1

See the corresponding page for C++ for an explanation of the problem and the solution.

The Python code is trivial:

using System;

double expm1(double x)
{
    if (Math.Abs(x) < 1e-5)
        return x + 0.5*x*x;
    else
        return Math.Exp(x) - 1.0;
}

More stand-alone numerical code