\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;z \leq -0.04502376810770514:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{z} + y \cdot \frac{x}{z}\right) - x\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z) :precision binary64 (if (<= z -0.04502376810770514) (/ x (/ z (+ (- y z) 1.0))) (- (+ (/ x z) (* y (/ 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 (z <= -0.04502376810770514) {
tmp = x / (z / ((y - z) + 1.0));
} else {
tmp = ((x / z) + (y * (x / z))) - x;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 9.8 |
|---|---|
| Target | 0.4 |
| Herbie | 0.9 |
if z < -0.045023768107705142Initial program 15.8
rmApplied associate-/l*_binary640.1
if -0.045023768107705142 < z Initial program 7.2
Taylor expanded around 0 2.5
Simplified1.3
Final simplification0.9
herbie shell --seed 2021118
(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))