e^{a \cdot x} - 1\begin{array}{l}
\mathbf{if}\;a \cdot x \le -1.3848736434257956 \cdot 10^{-5}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot x + \frac{1}{2} \cdot {\left(a \cdot x\right)}^{2}\\
\end{array}double code(double a, double x) {
return ((double) (((double) exp(((double) (a * x)))) - 1.0));
}
double code(double a, double x) {
double VAR;
if ((((double) (a * x)) <= -1.3848736434257956e-05)) {
VAR = ((double) log(((double) exp(((double) (((double) exp(((double) (a * x)))) - 1.0))))));
} else {
VAR = ((double) (((double) (a * x)) + ((double) (0.5 * ((double) pow(((double) (a * x)), 2.0))))));
}
return VAR;
}




Bits error versus a




Bits error versus x
Results
| Original | 29.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.4 |
if (* a x) < -1.3848736434257956e-5Initial program 0.1
rmApplied add-log-exp0.1
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.1
if -1.3848736434257956e-5 < (* a x) Initial program 45.1
rmApplied add-log-exp45.1
Applied add-log-exp45.2
Applied diff-log45.3
Simplified45.2
Taylor expanded around 0 15.4
Simplified8.1
Taylor expanded around 0 8.9
rmApplied pow-prod-down0.6
Final simplification0.4
herbie shell --seed 2020182
(FPCore (a x)
:name "expax (section 3.5)"
:precision binary64
:herbie-expected 14
:herbie-target
(if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1.0 (+ (/ (* a x) 2.0) (/ (pow (* a x) 2.0) 6.0)))) (- (exp (* a x)) 1.0))
(- (exp (* a x)) 1.0))