x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t_1 \leq -1.3081143333777745 \cdot 10^{+273}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, \mathsf{fma}\left(-1, z, t\right), x\right)\\
\mathbf{elif}\;t_1 \leq 2.847792730771011 \cdot 10^{+148}:\\
\;\;\;\;x - \frac{y \cdot z - y \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - z}{a}, x\right)\\
\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 (* y (- z t))))
(if (<= t_1 -1.3081143333777745e+273)
(fma (/ y a) (fma -1.0 z t) x)
(if (<= t_1 2.847792730771011e+148)
(- x (/ (- (* y z) (* y t)) a))
(fma y (/ (- t z) a) x)))))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 <= -1.3081143333777745e+273) {
tmp = fma((y / a), fma(-1.0, z, t), x);
} else if (t_1 <= 2.847792730771011e+148) {
tmp = x - (((y * z) - (y * t)) / a);
} else {
tmp = fma(y, ((t - z) / a), x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 5.9 |
|---|---|
| Target | 0.7 |
| Herbie | 0.6 |
if (*.f64 y (-.f64 z t)) < -1.30811433337777452e273Initial program 48.9
Taylor expanded in x around 0 48.9
Simplified0.2
if -1.30811433337777452e273 < (*.f64 y (-.f64 z t)) < 2.84779273077101127e148Initial program 0.4
Applied sub-neg_binary640.4
Applied distribute-lft-in_binary640.4
if 2.84779273077101127e148 < (*.f64 y (-.f64 z t)) Initial program 20.4
Simplified2.0
Final simplification0.6
herbie shell --seed 2022068
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
: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)))