\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq -4.948046662777581 \cdot 10^{-25} \lor \neg \left(\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq 3.433483833260939 \cdot 10^{+65}\right):\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1}}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (or (<= (/ (* x (+ (- y z) 1.0)) z) -4.948046662777581e-25)
(not (<= (/ (* x (+ (- y z) 1.0)) z) 3.433483833260939e+65)))
(- (* (/ x z) (+ y 1.0)) x)
(/ x (/ z (+ (- y z) 1.0)))))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 * ((y - z) + 1.0)) / z) <= -4.948046662777581e-25) || !(((x * ((y - z) + 1.0)) / z) <= 3.433483833260939e+65)) {
tmp = ((x / z) * (y + 1.0)) - x;
} else {
tmp = x / (z / ((y - z) + 1.0));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.5 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -4.94804666277758115e-25 or 3.43348383326093882e65 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 18.3
rmApplied associate-/l*_binary64_133224.8
Simplified4.8
Taylor expanded around 0 5.9
Simplified0.1
if -4.94804666277758115e-25 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 3.43348383326093882e65Initial program 0.1
rmApplied associate-/l*_binary64_133220.3
Final simplification0.2
herbie shell --seed 2021014
(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))