I want it to be stable near $f(0) = 1$. Is there a nice function that does this already, like maybe a hyperbolic trig function or something like expm1, or should I just check if $x$ is near zero and then use a polynomial approximation?
What is a nice way to compute $f(x) = x / (\exp(x) - 1)$?
6
$\begingroup$
numerical-methods
exponential-function
computational-mathematics
approximation-theory
-
1Once you use `expm1` to compute $\exp(x)-1$, there's no further loss of significance in dividing $x$ by it, is there? – 2012-08-21
-
1@Rahul: You are suggesting to use x/expm1(x) but with a single extra check for 0/0 when x is exactly 0? – 2012-08-21
-
0Suggesting, yes, (though to be clear, not with a great deal of authority). – 2012-08-21
-
1Why not Bernoulli numbers? – 2012-08-22
-
0$$f(x)={e^{-x/2}\over{\rm sinc}(i x/2)}\ .$$ – 2012-08-22