\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 := e^{\varepsilon \cdot b} - 1\\
t_1 := \varepsilon \cdot \left(e^{\varepsilon \cdot \left(a + b\right)} - 1\right)\\
t_2 := e^{\varepsilon \cdot a} - 1\\
t_3 := t_2 \cdot t_0\\
t_4 := \frac{t_1}{t_3}\\
\mathbf{if}\;t_4 \leq -0.321337824977454:\\
\;\;\;\;\frac{t_1}{\left(\varepsilon \cdot a\right) \cdot t_0}\\
\mathbf{elif}\;t_4 \leq 3.4699057758429277 \cdot 10^{-47}:\\
\;\;\;\;\frac{t_1}{\log \left(e^{t_3}\right)}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_5 := \sqrt[3]{t_2}\\
\frac{t_1}{\left(t_5 \cdot t_5\right) \cdot \left(t_5 \cdot \left(b \cdot \left(\varepsilon + b \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \left(b \cdot 0.16666666666666666\right) + 0.5\right)\right)\right)\right)\right)}
\end{array}\\
\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 (- (exp (* eps b)) 1.0))
(t_1 (* eps (- (exp (* eps (+ a b))) 1.0)))
(t_2 (- (exp (* eps a)) 1.0))
(t_3 (* t_2 t_0))
(t_4 (/ t_1 t_3)))
(if (<= t_4 -0.321337824977454)
(/ t_1 (* (* eps a) t_0))
(if (<= t_4 3.4699057758429277e-47)
(/ t_1 (log (exp t_3)))
(let* ((t_5 (cbrt t_2)))
(/
t_1
(*
(* t_5 t_5)
(*
t_5
(*
b
(+
eps
(*
b
(*
(* eps eps)
(+ (* eps (* b 0.16666666666666666)) 0.5)))))))))))))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 = exp(eps * b) - 1.0;
double t_1 = eps * (exp(eps * (a + b)) - 1.0);
double t_2 = exp(eps * a) - 1.0;
double t_3 = t_2 * t_0;
double t_4 = t_1 / t_3;
double tmp;
if (t_4 <= -0.321337824977454) {
tmp = t_1 / ((eps * a) * t_0);
} else if (t_4 <= 3.4699057758429277e-47) {
tmp = t_1 / log(exp(t_3));
} else {
double t_5 = cbrt(t_2);
tmp = t_1 / ((t_5 * t_5) * (t_5 * (b * (eps + (b * ((eps * eps) * ((eps * (b * 0.16666666666666666)) + 0.5)))))));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus eps
Results
| Original | 60.2 |
|---|---|
| Target | 14.7 |
| Herbie | 49.7 |
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))) < -0.321337824977454Initial program 63.9
Taylor expanded around 0 20.6
if -0.321337824977454 < (/.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.46990577584292773e-47Initial program 4.3
rmApplied add-log-exp_binary645.0
if 3.46990577584292773e-47 < (/.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.6
Taylor expanded around 0 57.7
Simplified57.4
rmApplied add-cube-cbrt_binary6457.5
Applied associate-*l*_binary6457.5
Simplified57.3
rmApplied *-un-lft-identity_binary6457.3
Applied cbrt-prod_binary6457.3
Applied associate-*r*_binary6457.3
Simplified57.3
Final simplification49.7
herbie shell --seed 2021198
(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))))