\frac{\varepsilon \cdot \left(e^{\left(a + b\right) \cdot \varepsilon} - 1\right)}{\left(e^{a \cdot \varepsilon} - 1\right) \cdot \left(e^{b \cdot \varepsilon} - 1\right)}
\begin{array}{l}
t_0 := \varepsilon \cdot \left(a + b\right)\\
t_1 := \frac{\varepsilon \cdot \left(e^{t_0} - 1\right)}{\left(e^{\varepsilon \cdot a} - 1\right) \cdot \left(e^{\varepsilon \cdot b} - 1\right)}\\
t_2 := \frac{1}{a} + \frac{1}{b}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(0.08333333333333333, a \cdot \left(\varepsilon \cdot \varepsilon\right), t_2\right)\\
\mathbf{elif}\;t_1 \leq 2.8347809522572864 \cdot 10^{-70}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{expm1}\left(\varepsilon \cdot a\right) \cdot \mathsf{expm1}\left(\varepsilon \cdot b\right)}{\varepsilon \cdot \mathsf{expm1}\left(t_0\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
(FPCore (a b eps) :precision binary64 (/ (* eps (- (exp (* (+ a b) eps)) 1.0)) (* (- (exp (* a eps)) 1.0) (- (exp (* b eps)) 1.0))))
(FPCore (a b eps)
:precision binary64
(let* ((t_0 (* eps (+ a b)))
(t_1
(/
(* eps (- (exp t_0) 1.0))
(* (- (exp (* eps a)) 1.0) (- (exp (* eps b)) 1.0))))
(t_2 (+ (/ 1.0 a) (/ 1.0 b))))
(if (<= t_1 (- INFINITY))
(fma 0.08333333333333333 (* a (* eps eps)) t_2)
(if (<= t_1 2.8347809522572864e-70)
(/ 1.0 (/ (* (expm1 (* eps a)) (expm1 (* eps b))) (* eps (expm1 t_0))))
t_2))))double code(double a, double b, double eps) {
return (eps * (exp((a + b) * eps) - 1.0)) / ((exp(a * eps) - 1.0) * (exp(b * eps) - 1.0));
}
double code(double a, double b, double eps) {
double t_0 = eps * (a + b);
double t_1 = (eps * (exp(t_0) - 1.0)) / ((exp(eps * a) - 1.0) * (exp(eps * b) - 1.0));
double t_2 = (1.0 / a) + (1.0 / b);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(0.08333333333333333, (a * (eps * eps)), t_2);
} else if (t_1 <= 2.8347809522572864e-70) {
tmp = 1.0 / ((expm1(eps * a) * expm1(eps * b)) / (eps * expm1(t_0)));
} else {
tmp = t_2;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus eps
| Original | 60.0 |
|---|---|
| Target | 15.1 |
| Herbie | 1.3 |
if (/.f64 (*.f64 eps (-.f64 (exp.f64 (*.f64 (+.f64 a b) eps)) 1)) (*.f64 (-.f64 (exp.f64 (*.f64 a eps)) 1) (-.f64 (exp.f64 (*.f64 b eps)) 1))) < -inf.0Initial program 64.0
Simplified17.6
Taylor expanded in eps around 0 12.4
Simplified12.4
Taylor expanded in b around 0 6.0
Simplified6.0
if -inf.0 < (/.f64 (*.f64 eps (-.f64 (exp.f64 (*.f64 (+.f64 a b) eps)) 1)) (*.f64 (-.f64 (exp.f64 (*.f64 a eps)) 1) (-.f64 (exp.f64 (*.f64 b eps)) 1))) < 2.834780952257286e-70Initial program 2.7
Simplified0.1
Applied clear-num_binary640.1
if 2.834780952257286e-70 < (/.f64 (*.f64 eps (-.f64 (exp.f64 (*.f64 (+.f64 a b) eps)) 1)) (*.f64 (-.f64 (exp.f64 (*.f64 a eps)) 1) (-.f64 (exp.f64 (*.f64 b eps)) 1))) Initial program 63.3
Simplified47.6
Taylor expanded in eps around 0 14.8
Taylor expanded in a around 0 0.7
Final simplification1.3
herbie shell --seed 2021344
(FPCore (a b eps)
:name "expq3 (problem 3.4.2)"
:precision binary64
:pre (and (< -1.0 eps) (< eps 1.0))
:herbie-target
(/ (+ a b) (* a b))
(/ (* eps (- (exp (* (+ a b) eps)) 1.0)) (* (- (exp (* a eps)) 1.0) (- (exp (* b eps)) 1.0))))