\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \leq -1.791135204728718 \cdot 10^{+16}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right) - x\\
\mathbf{elif}\;x \leq 1.3367631851331907 \cdot 10^{-118}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y + 1}{z} - x\\
\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.791135204728718e+16)) {
VAR = ((double) (((double) ((x / z) * ((double) (y + 1.0)))) - x));
} else {
double VAR_1;
if ((x <= 1.3367631851331907e-118)) {
VAR_1 = ((double) ((((double) (x * ((double) (y + 1.0)))) / z) - x));
} else {
VAR_1 = ((double) (((double) (x * (((double) (y + 1.0)) / z))) - x));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.6 |
|---|---|
| Target | 0.5 |
| Herbie | 0.4 |
if x < -17911352047287180Initial program Error: 28.2 bits
SimplifiedError: 0.1 bits
rmApplied *-un-lft-identityError: 0.1 bits
Applied add-cube-cbrtError: 0.3 bits
Applied times-fracError: 0.3 bits
Applied associate-*r*Error: 5.5 bits
SimplifiedError: 5.5 bits
Taylor expanded around 0 Error: 9.8 bits
SimplifiedError: 0.1 bits
if -17911352047287180 < x < 1.3367631851331907e-118Initial program Error: 0.2 bits
SimplifiedError: 6.4 bits
rmApplied associate-*r/Error: 0.1 bits
if 1.3367631851331907e-118 < x Initial program Error: 16.8 bits
SimplifiedError: 1.1 bits
Final simplificationError: 0.4 bits
herbie shell --seed 2020200
(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))