For your Bernoulli function
|
inline double bern ( double x ) |
The C++ math libraries, have an expm1 function that is easier to use when calculating exp(x)-1.
Please see:
https://en.cppreference.com/w/cpp/numeric/math/expm1
So that the Bernoulli function can be something like this:
y = expm1(x);
if (y != x)
{
bern = x / expm(x);
}
else
{
bern = 1.0/(1.0 + 0.5*x);
}
For your Bernoulli function
Genius-TCAD-Open/include/math/mathfunc.h
Line 78 in c76ade9
The C++ math libraries, have an
expm1function that is easier to use when calculatingexp(x)-1.Please see:
https://en.cppreference.com/w/cpp/numeric/math/expm1
So that the Bernoulli function can be something like this: