\frac{x \cdot \left(y - z\right)}{y}\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq 5.178726587552157 \cdot 10^{-14}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 7.305374277848311 \cdot 10^{+296}:\\
\;\;\;\;\frac{x \cdot y - x \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{x}{y}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(if (<= (/ (* x (- y z)) y) 5.178726587552157e-14)
(/ x (/ y (- y z)))
(if (<= (/ (* x (- y z)) y) 7.305374277848311e+296)
(/ (- (* x y) (* x z)) y)
(- x (* z (/ x y))))))double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double tmp;
if (((x * (y - z)) / y) <= 5.178726587552157e-14) {
tmp = x / (y / (y - z));
} else if (((x * (y - z)) / y) <= 7.305374277848311e+296) {
tmp = ((x * y) - (x * z)) / y;
} else {
tmp = x - (z * (x / y));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.7 |
|---|---|
| Target | 3.4 |
| Herbie | 1.9 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < 5.1787265875521573e-14Initial program 11.4
rmApplied associate-/l*_binary64_177552.4
if 5.1787265875521573e-14 < (/.f64 (*.f64 x (-.f64 y z)) y) < 7.30537427784831114e296Initial program 0.2
rmApplied sub-neg_binary64_178030.2
Applied distribute-rgt-in_binary64_177600.2
Simplified0.2
Simplified0.2
if 7.30537427784831114e296 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 59.9
rmApplied associate-/l*_binary64_177550.9
Taylor expanded around 0 21.9
Simplified2.4
Final simplification1.9
herbie shell --seed 2021007
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))