\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 -\infty:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y + 1\right) - z}}\\
\mathbf{elif}\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq 9.834395912560455 \cdot 10^{-47}:\\
\;\;\;\;\left(\frac{x}{z} + \frac{x \cdot y}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\left(y + 1\right) \cdot \frac{x}{z} - x\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (<= (/ (* x (+ (- y z) 1.0)) z) (- INFINITY))
(/ x (/ z (- (+ y 1.0) z)))
(if (<= (/ (* x (+ (- y z) 1.0)) z) 9.834395912560455e-47)
(- (+ (/ x z) (/ (* x y) z)) x)
(- (* (+ y 1.0) (/ x z)) x))))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) <= -((double) INFINITY)) {
tmp = x / (z / ((y + 1.0) - z));
} else if (((x * ((y - z) + 1.0)) / z) <= 9.834395912560455e-47) {
tmp = ((x / z) + ((x * y) / z)) - x;
} else {
tmp = ((y + 1.0) * (x / z)) - x;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -inf.0Initial program 64.0
rmApplied associate-/l*_binary64_177550.0
Simplified0.0
if -inf.0 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 9.8343959125604555e-47Initial program 0.1
Taylor expanded around 0 0.1
if 9.8343959125604555e-47 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 15.1
Taylor expanded around 0 5.1
Simplified0.2
Taylor expanded around 0 5.1
Simplified0.2
Final simplification0.1
herbie shell --seed 2021027
(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))