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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 9.9 |
|---|---|
| Target | 0.4 |
| Herbie | 1.7 |
if z < -6.0935779274211301e-51Initial program 14.7
Simplified14.7
Taylor expanded in y around 0 5.0
Simplified2.0
Taylor expanded in z around 0 5.0
Applied *-un-lft-identity_binary645.0
Applied distribute-rgt-out_binary645.0
Applied associate-/l*_binary640.2
if -6.0935779274211301e-51 < z Initial program 7.4
Simplified7.4
Taylor expanded in y around 0 2.5
Simplified1.1
Taylor expanded in z around 0 2.5
Taylor expanded in x around 0 2.5
Final simplification1.7
herbie shell --seed 2022067
(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))