\frac{e^{x} - 1.0}{x}\begin{array}{l}
\mathbf{if}\;x \le -0.00017882867482842777:\\
\;\;\;\;\frac{\left(\sqrt{1.0} + \sqrt{e^{x}}\right) \cdot \frac{\sqrt{e^{x}} - \sqrt{1.0}}{2} + \log \left(\sqrt{e^{e^{x} - 1.0}}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), 1\right)\\
\end{array}double f(double x) {
double r3114255 = x;
double r3114256 = exp(r3114255);
double r3114257 = 1.0;
double r3114258 = r3114256 - r3114257;
double r3114259 = r3114258 / r3114255;
return r3114259;
}
double f(double x) {
double r3114260 = x;
double r3114261 = -0.00017882867482842777;
bool r3114262 = r3114260 <= r3114261;
double r3114263 = 1.0;
double r3114264 = sqrt(r3114263);
double r3114265 = exp(r3114260);
double r3114266 = sqrt(r3114265);
double r3114267 = r3114264 + r3114266;
double r3114268 = r3114266 - r3114264;
double r3114269 = 2.0;
double r3114270 = r3114268 / r3114269;
double r3114271 = r3114267 * r3114270;
double r3114272 = r3114265 - r3114263;
double r3114273 = exp(r3114272);
double r3114274 = sqrt(r3114273);
double r3114275 = log(r3114274);
double r3114276 = r3114271 + r3114275;
double r3114277 = r3114276 / r3114260;
double r3114278 = 0.16666666666666666;
double r3114279 = 0.5;
double r3114280 = fma(r3114260, r3114278, r3114279);
double r3114281 = 1.0;
double r3114282 = fma(r3114260, r3114280, r3114281);
double r3114283 = r3114262 ? r3114277 : r3114282;
return r3114283;
}




Bits error versus x
| Original | 39.1 |
|---|---|
| Target | 39.4 |
| Herbie | 0.3 |
if x < -0.00017882867482842777Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.1
rmApplied add-sqr-sqrt0.1
Applied log-prod0.1
rmApplied add-sqr-sqrt0.1
Applied add-sqr-sqrt0.1
Applied difference-of-squares0.1
Applied exp-prod0.1
Applied sqrt-pow10.1
Applied log-pow0.1
Simplified0.1
if -0.00017882867482842777 < x Initial program 60.0
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019165 +o rules:numerics
(FPCore (x)
:name "Kahan's exp quotient"
:herbie-target
(if (and (< x 1.0) (> x -1.0)) (/ (- (exp x) 1.0) (log (exp x))) (/ (- (exp x) 1.0) x))
(/ (- (exp x) 1.0) x))