x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
t_1 \leq -\infty \lor \neg \left(t_1 \leq 2.829056611898327 \cdot 10^{+229}\right)
\end{array}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
:precision binary64
(if (let* ((t_1 (* y (- z t))))
(or (<= t_1 (- INFINITY)) (not (<= t_1 2.829056611898327e+229))))
(+ x (* (- z t) (/ y a)))
(+ x (/ (- (* y z) (* y t)) a))))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 = y * (z - t);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2.829056611898327e+229)) {
tmp = x + ((z - t) * (y / a));
} else {
tmp = x + (((y * z) - (y * t)) / a);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
Results
| Original | 5.8 |
|---|---|
| Target | 0.7 |
| Herbie | 0.3 |
if (*.f64 y (-.f64 z t)) < -inf.0 or 2.8290566118983271e229 < (*.f64 y (-.f64 z t)) Initial program 45.3
Taylor expanded in z around 0 45.3
Taylor expanded in y around 0 0.6
Simplified0.3
if -inf.0 < (*.f64 y (-.f64 z t)) < 2.8290566118983271e229Initial program 0.3
Applied sub-neg_binary640.3
Applied distribute-rgt-in_binary640.3
Final simplification0.3
herbie shell --seed 2021275
(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)))