\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)\\
\mathbf{if}\;\begin{array}{l}
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_1 \leq -\infty \lor \neg \left(t_1 \leq 4.734337888788163 \cdot 10^{-12}\right)
\end{array}:\\
\;\;\;\;\frac{1}{b} + \frac{1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon}{\mathsf{expm1}\left(\varepsilon \cdot a\right)} \cdot \frac{\mathsf{expm1}\left(t_0\right)}{\mathsf{expm1}\left(\varepsilon \cdot b\right)}\\
\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))))
(if (let* ((t_1
(/
(* eps (- (exp t_0) 1.0))
(* (- (exp (* eps a)) 1.0) (- (exp (* eps b)) 1.0)))))
(or (<= t_1 (- INFINITY)) (not (<= t_1 4.734337888788163e-12))))
(+ (/ 1.0 b) (/ 1.0 a))
(* (/ eps (expm1 (* eps a))) (/ (expm1 t_0) (expm1 (* eps b)))))))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 tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 4.734337888788163e-12)) {
tmp = (1.0 / b) + (1.0 / a);
} else {
tmp = (eps / expm1(eps * a)) * (expm1(t_0) / expm1(eps * b));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus eps
Results
| Original | 60.2 |
|---|---|
| Target | 15.4 |
| Herbie | 0.1 |
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.0 or 4.73433788878816315e-12 < (/.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.9
Simplified43.3
Taylor expanded in eps around 0 3.1
Simplified3.1
Taylor expanded in eps around 0 0.1
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))) < 4.73433788878816315e-12Initial program 3.6
Simplified0.1
Applied times-frac_binary640.1
Final simplification0.1
herbie shell --seed 2022024
(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))))