x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{if}\;z - t \leq -2.544404770474763 \cdot 10^{-65}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z - t \leq 6.825613452492701 \cdot 10^{-109}:\\
\;\;\;\;x + \frac{\left(z - t\right) \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- z t) (/ y a) x)))
(if (<= (- z t) -2.544404770474763e-65)
t_1
(if (<= (- z t) 6.825613452492701e-109) (+ x (/ (* (- z t) y) a)) t_1))))double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z - t), (y / a), x);
double tmp;
if ((z - t) <= -2.544404770474763e-65) {
tmp = t_1;
} else if ((z - t) <= 6.825613452492701e-109) {
tmp = x + (((z - t) * y) / a);
} else {
tmp = t_1;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 6.0 |
|---|---|
| Target | 0.7 |
| Herbie | 1.6 |
if (-.f64 z t) < -2.5444047704747631e-65 or 6.8256134524927015e-109 < (-.f64 z t) Initial program 7.1
Simplified6.8
Taylor expanded in y around 0 7.1
Simplified1.8
if -2.5444047704747631e-65 < (-.f64 z t) < 6.8256134524927015e-109Initial program 0.7
Final simplification1.6
herbie shell --seed 2022130
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:herbie-target
(if (< y -1.0761266216389975e-10) (+ x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))
(+ x (/ (* y (- z t)) a)))