\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}{b} + \frac{1}{a}\\
\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 3.532953766656584 \cdot 10^{-13}:\\
\;\;\;\;\frac{\varepsilon \cdot \mathsf{expm1}\left(t_0\right)}{\mathsf{expm1}\left(\varepsilon \cdot a\right) \cdot \mathsf{expm1}\left(\varepsilon \cdot b\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 b) (/ 1.0 a))))
(if (<= t_1 (- INFINITY))
(fma 0.08333333333333333 (* a (* eps eps)) t_2)
(if (<= t_1 3.532953766656584e-13)
(/ (* eps (expm1 t_0)) (* (expm1 (* eps a)) (expm1 (* eps b))))
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 / b) + (1.0 / a);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(0.08333333333333333, (a * (eps * eps)), t_2);
} else if (t_1 <= 3.532953766656584e-13) {
tmp = (eps * expm1(t_0)) / (expm1(eps * a) * expm1(eps * b));
} else {
tmp = t_2;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus eps
| Original | 60.2 |
|---|---|
| Target | 15.1 |
| 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.0Initial program 64.0
Simplified15.8
Taylor expanded in eps around 0 10.1
Simplified10.1
Taylor expanded in b around 0 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))) < 3.5329537666565839e-13Initial program 3.9
Simplified0.1
Applied *-un-lft-identity_binary640.1
if 3.5329537666565839e-13 < (/.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.8
Simplified47.6
Taylor expanded in eps around 0 1.9
Simplified1.9
Taylor expanded in eps around 0 0.2
Final simplification0.1
herbie shell --seed 2022103
(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))))