\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \leq -5.425669128900141 \cdot 10^{-55} \lor \neg \left(x \leq 1.5761969805659057 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot \left(y - z\right)}{z}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z) :precision binary64 (if (or (<= x -5.425669128900141e-55) (not (<= x 1.5761969805659057e-27))) (/ x (/ z (+ (- y z) 1.0))) (/ (+ x (* x (- y z))) z)))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.425669128900141e-55) || !(x <= 1.5761969805659057e-27)) {
tmp = x / (z / ((y - z) + 1.0));
} else {
tmp = (x + (x * (y - z))) / z;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.7 |
|---|---|
| Target | 0.4 |
| Herbie | 0.2 |
if x < -5.4256691289001412e-55 or 1.57619698056590572e-27 < x Initial program 22.2
rmApplied associate-/l*_binary64_160500.2
if -5.4256691289001412e-55 < x < 1.57619698056590572e-27Initial program 0.1
rmApplied distribute-rgt-in_binary64_160550.1
Simplified0.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2020344
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))