e^{a \cdot x} - 1\begin{array}{l}
\mathbf{if}\;a \cdot x \le -2.126354662771189659841580832377871956851 \cdot 10^{-4}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{elif}\;a \cdot x \le 7.692055924467544744602805206092219669968 \cdot 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(a, x, \log \left({\left(e^{x}\right)}^{\left(x \cdot \mathsf{fma}\left(a \cdot a, \frac{1}{2}, {a}^{3} \cdot \left(\frac{1}{6} \cdot x\right)\right)\right)}\right)\right)\\
\mathbf{elif}\;a \cdot x \le 7.182914139653070480268595225980441913815 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(a, x, \mathsf{fma}\left(\frac{1}{2}, a \cdot a, \frac{1}{6} \cdot \left({a}^{3} \cdot x\right)\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{e^{a \cdot x}}, \sqrt{e^{a \cdot x}}, -1\right)\\
\end{array}double f(double a, double x) {
double r74055 = a;
double r74056 = x;
double r74057 = r74055 * r74056;
double r74058 = exp(r74057);
double r74059 = 1.0;
double r74060 = r74058 - r74059;
return r74060;
}
double f(double a, double x) {
double r74061 = a;
double r74062 = x;
double r74063 = r74061 * r74062;
double r74064 = -0.00021263546627711897;
bool r74065 = r74063 <= r74064;
double r74066 = exp(r74063);
double r74067 = 1.0;
double r74068 = r74066 - r74067;
double r74069 = exp(r74068);
double r74070 = log(r74069);
double r74071 = 7.692055924467545e-34;
bool r74072 = r74063 <= r74071;
double r74073 = exp(r74062);
double r74074 = r74061 * r74061;
double r74075 = 0.5;
double r74076 = 3.0;
double r74077 = pow(r74061, r74076);
double r74078 = 0.16666666666666666;
double r74079 = r74078 * r74062;
double r74080 = r74077 * r74079;
double r74081 = fma(r74074, r74075, r74080);
double r74082 = r74062 * r74081;
double r74083 = pow(r74073, r74082);
double r74084 = log(r74083);
double r74085 = fma(r74061, r74062, r74084);
double r74086 = 7.18291413965307e-18;
bool r74087 = r74063 <= r74086;
double r74088 = r74077 * r74062;
double r74089 = r74078 * r74088;
double r74090 = fma(r74075, r74074, r74089);
double r74091 = r74062 * r74062;
double r74092 = r74090 * r74091;
double r74093 = fma(r74061, r74062, r74092);
double r74094 = sqrt(r74066);
double r74095 = -r74067;
double r74096 = fma(r74094, r74094, r74095);
double r74097 = r74087 ? r74093 : r74096;
double r74098 = r74072 ? r74085 : r74097;
double r74099 = r74065 ? r74070 : r74098;
return r74099;
}




Bits error versus a




Bits error versus x
| Original | 29.6 |
|---|---|
| Target | 0.2 |
| Herbie | 3.4 |
if (* a x) < -0.00021263546627711897Initial program 0.1
rmApplied add-sqr-sqrt0.1
Applied fma-neg0.1
rmApplied add-log-exp0.1
Simplified0.1
if -0.00021263546627711897 < (* a x) < 7.692055924467545e-34Initial program 44.2
Taylor expanded around 0 12.7
Simplified9.6
rmApplied add-log-exp9.8
Simplified3.7
if 7.692055924467545e-34 < (* a x) < 7.18291413965307e-18Initial program 61.9
Taylor expanded around 0 35.4
Simplified29.6
if 7.18291413965307e-18 < (* a x) Initial program 23.7
rmApplied add-sqr-sqrt24.9
Applied fma-neg24.7
Final simplification3.4
herbie shell --seed 2019195 +o rules:numerics
(FPCore (a x)
:name "expax (section 3.5)"
: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))