\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 -5.023586869686589 \cdot 10^{-29} \lor \neg \left(\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq 1.220166170638923 \cdot 10^{-62}\right):\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right) - x\\
\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 (or (<= (/ (* x (+ (- y z) 1.0)) z) -5.023586869686589e-29)
(not (<= (/ (* x (+ (- y z) 1.0)) z) 1.220166170638923e-62)))
(- (* (/ x z) (+ y 1.0)) x)
(* 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 ((((x * ((y - z) + 1.0)) / z) <= -5.023586869686589e-29) || !(((x * ((y - z) + 1.0)) / z) <= 1.220166170638923e-62)) {
tmp = ((x / z) * (y + 1.0)) - x;
} 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.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -5.02358686968658921e-29 or 1.220166170638923e-62 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 14.9
rmApplied *-un-lft-identity_binary6414.9
Applied times-frac_binary645.1
Simplified5.1
Taylor expanded around 0 5.4
Simplified0.2
if -5.02358686968658921e-29 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 1.220166170638923e-62Initial program 0.1
rmApplied *-un-lft-identity_binary640.1
Applied times-frac_binary640.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2020224
(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))