e^{a \cdot x} - 1\begin{array}{l}
\mathbf{if}\;a \cdot x \le -0.00103720060762227677:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \left|x \cdot a\right| \cdot \left|x \cdot a\right|, \mathsf{fma}\left(\frac{1}{6}, {\left(x \cdot a\right)}^{3}, a \cdot x\right)\right)\\
\end{array}double f(double a, double x) {
double r508 = a;
double r509 = x;
double r510 = r508 * r509;
double r511 = exp(r510);
double r512 = 1.0;
double r513 = r511 - r512;
return r513;
}
double f(double a, double x) {
double r514 = a;
double r515 = x;
double r516 = r514 * r515;
double r517 = -0.0010372006076222768;
bool r518 = r516 <= r517;
double r519 = exp(r516);
double r520 = 1.0;
double r521 = r519 - r520;
double r522 = exp(r521);
double r523 = log(r522);
double r524 = 0.5;
double r525 = r515 * r514;
double r526 = fabs(r525);
double r527 = r526 * r526;
double r528 = 0.16666666666666666;
double r529 = 3.0;
double r530 = pow(r525, r529);
double r531 = fma(r528, r530, r516);
double r532 = fma(r524, r527, r531);
double r533 = r518 ? r523 : r532;
return r533;
}




Bits error versus a




Bits error versus x
| Original | 29.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.4 |
if (* a x) < -0.0010372006076222768Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.0
Applied diff-log0.0
Simplified0.0
if -0.0010372006076222768 < (* a x) Initial program 44.4
Taylor expanded around 0 14.7
Simplified14.7
rmApplied pow-prod-down8.3
Simplified8.3
rmApplied add-sqr-sqrt8.3
Simplified8.3
Simplified0.6
Final simplification0.4
herbie shell --seed 2020025 +o rules:numerics
(FPCore (a x)
:name "expax (section 3.5)"
:precision binary64
:herbie-expected 14
:herbie-target
(if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6)))) (- (exp (* a x)) 1))
(- (exp (* a x)) 1))