\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \leq -4.934159841637241 \cdot 10^{-149} \lor \neg \left(x \leq 2.1558912601142047 \cdot 10^{+23}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \frac{x}{z}\right) - 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 (or (<= x -4.934159841637241e-149) (not (<= x 2.1558912601142047e+23))) (- (fma (/ x z) y (/ x z)) 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 ((x <= -4.934159841637241e-149) || !(x <= 2.1558912601142047e+23)) {
tmp = fma((x / z), y, (x / z)) - x;
} else {
tmp = ((x * (y + 1.0)) / z) - x;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.4 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if x < -4.93415984163724069e-149 or 2.1558912601142047e23 < x Initial program 20.2
Simplified20.2
Taylor expanded in y around 0 6.5
Simplified0.4
if -4.93415984163724069e-149 < x < 2.1558912601142047e23Initial program 0.2
Simplified0.2
Taylor expanded in y around 0 0.1
Simplified3.0
Taylor expanded in x around 0 5.6
Taylor expanded in z around 0 0.1
Final simplification0.3
herbie shell --seed 2021313
(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))