\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \le -1.193248155890783 \cdot 10^{-195}:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1}}\\
\mathbf{elif}\;x \le 4.5156620335976036 \cdot 10^{-265}:\\
\;\;\;\;\frac{1}{\frac{z}{x \cdot \left(\left(y - z\right) + 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + y\right) - x\\
\end{array}double code(double x, double y, double z) {
return ((x * ((y - z) + 1.0)) / z);
}
double code(double x, double y, double z) {
double VAR;
if ((x <= -1.193248155890783e-195)) {
VAR = (x / (z / ((y - z) + 1.0)));
} else {
double VAR_1;
if ((x <= 4.5156620335976036e-265)) {
VAR_1 = (1.0 / (z / (x * ((y - z) + 1.0))));
} else {
VAR_1 = (((x / z) * (1.0 + y)) - x);
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.5 |
|---|---|
| Target | 0.5 |
| Herbie | 1.4 |
if x < -1.193248155890783e-195Initial program 13.7
rmApplied associate-/l*2.0
if -1.193248155890783e-195 < x < 4.5156620335976036e-265Initial program 0.2
rmApplied clear-num0.3
if 4.5156620335976036e-265 < x Initial program 11.4
rmApplied associate-/l*2.8
rmApplied associate-/r/7.3
Taylor expanded around 0 3.8
Simplified1.2
Final simplification1.4
herbie shell --seed 2020103
(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 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1)) z))