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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.6 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
if z < -217568101.4586677Initial program 18.1
rmApplied associate-/l*_binary64_172240.1
if -217568101.4586677 < z < 7.3129920367782152e-46Initial program 0.1
if 7.3129920367782152e-46 < z Initial program 15.4
rmApplied *-un-lft-identity_binary64_1727915.4
Applied times-frac_binary64_172850.2
Simplified0.2
Final simplification0.1
herbie shell --seed 2020292
(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))