e^{a \cdot x} - 1\begin{array}{l}
\mathbf{if}\;a \cdot x \le -0.001626719355739147552727952295015256822808:\\
\;\;\;\;\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|, a \cdot x\right)\\
\end{array}double f(double a, double x) {
double r93859 = a;
double r93860 = x;
double r93861 = r93859 * r93860;
double r93862 = exp(r93861);
double r93863 = 1.0;
double r93864 = r93862 - r93863;
return r93864;
}
double f(double a, double x) {
double r93865 = a;
double r93866 = x;
double r93867 = r93865 * r93866;
double r93868 = -0.0016267193557391476;
bool r93869 = r93867 <= r93868;
double r93870 = exp(r93867);
double r93871 = 1.0;
double r93872 = r93870 - r93871;
double r93873 = exp(r93872);
double r93874 = log(r93873);
double r93875 = 0.5;
double r93876 = r93866 * r93865;
double r93877 = fabs(r93876);
double r93878 = r93877 * r93877;
double r93879 = fma(r93875, r93878, r93867);
double r93880 = r93869 ? r93874 : r93879;
return r93880;
}




Bits error versus a




Bits error versus x
| Original | 30.0 |
|---|---|
| Target | 0.2 |
| Herbie | 0.5 |
if (* a x) < -0.0016267193557391476Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.0
Applied diff-log0.0
Simplified0.0
if -0.0016267193557391476 < (* a x) Initial program 44.7
Taylor expanded around 0 14.7
Simplified14.7
Taylor expanded around 0 8.4
Simplified8.4
rmApplied add-sqr-sqrt8.4
Simplified8.4
Simplified0.7
Final simplification0.5
herbie shell --seed 2020001 +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))