\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 -1.448487285633533 \cdot 10^{+67} \lor \neg \left(\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq 2.241693807638564 \cdot 10^{-39}\right):\\
\;\;\;\;\left(\frac{x}{z} + y \cdot \frac{x}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y + 1\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 (+ (- y z) 1.0)) z) -1.448487285633533e+67)
(not (<= (/ (* x (+ (- y z) 1.0)) z) 2.241693807638564e-39)))
(- (+ (/ x z) (* y (/ x z))) x)
(/ x (/ z (- (+ y 1.0) 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 * ((y - z) + 1.0)) / z) <= -1.448487285633533e+67) || !(((x * ((y - z) + 1.0)) / z) <= 2.241693807638564e-39)) {
tmp = ((x / z) + (y * (x / z))) - x;
} else {
tmp = x / (z / ((y + 1.0) - z));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.4 |
|---|---|
| Target | 0.4 |
| Herbie | 0.2 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -1.44848728563353314e67 or 2.241693807638564e-39 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 17.9
Taylor expanded around 0 6.4
Simplified0.1
if -1.44848728563353314e67 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 2.241693807638564e-39Initial program 0.1
rmApplied associate-/l*_binary64_167320.2
Simplified0.2
Final simplification0.2
herbie shell --seed 2021015
(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))