\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \leq -1.8104924256738275 \cdot 10^{-84} \lor \neg \left(x \leq 7.274545131975547 \cdot 10^{-145}\right):\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 + \left(y - z\right)\right)}{z}\\
\end{array}double code(double x, double y, double z) {
return (((double) (x * ((double) (((double) (y - z)) + 1.0)))) / z);
}
double code(double x, double y, double z) {
double VAR;
if (((x <= -1.8104924256738275e-84) || !(x <= 7.274545131975547e-145))) {
VAR = ((double) (((double) ((x / z) * ((double) (y + 1.0)))) - x));
} else {
VAR = (((double) (x * ((double) (1.0 + ((double) (y - z)))))) / z);
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.0 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if x < -1.81049242567382748e-84 or 7.2745451319755472e-145 < x Initial program 16.4
Simplified1.1
rmApplied *-un-lft-identity1.1
Applied add-cube-cbrt1.4
Applied times-frac1.4
Applied associate-*r*3.3
Simplified3.3
Taylor expanded around 0 5.2
Simplified0.3
if -1.81049242567382748e-84 < x < 7.2745451319755472e-145Initial program 0.2
Final simplification0.2
herbie shell --seed 2020196
(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))