x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \leq 5.875674242652246 \cdot 10^{-297}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\
\mathbf{elif}\;x \leq 3.325314396267599 \cdot 10^{-150}:\\
\;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{\frac{t}{y}}{z - x}}\\
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
:precision binary64
(if (<= x 5.875674242652246e-297)
(fma (/ y t) (- z x) x)
(if (<= x 3.325314396267599e-150)
(+ x (/ (* y (- z x)) t))
(+ x (/ 1.0 (/ (/ t y) (- z x)))))))double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 5.875674242652246e-297) {
tmp = fma((y / t), (z - x), x);
} else if (x <= 3.325314396267599e-150) {
tmp = x + ((y * (z - x)) / t);
} else {
tmp = x + (1.0 / ((t / y) / (z - x)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 6.3 |
|---|---|
| Target | 2.2 |
| Herbie | 2.3 |
if x < 5.87567424265224604e-297Initial program 5.9
Simplified6.6
Taylor expanded in y around 0 5.9
Simplified2.5
if 5.87567424265224604e-297 < x < 3.325314396267599e-150Initial program 5.6
if 3.325314396267599e-150 < x Initial program 7.3
Applied clear-num_binary647.3
Applied associate-/r*_binary640.7
Final simplification2.3
herbie shell --seed 2022077
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:herbie-target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))