\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;z \leq -2.025964934226397 \cdot 10^{-05} \lor \neg \left(z \leq 2033294.3313340866\right):\\
\;\;\;\;x \cdot \frac{1 + \left(y - z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot \left(y - z\right)}{z}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z) :precision binary64 (if (or (<= z -2.025964934226397e-05) (not (<= z 2033294.3313340866))) (* x (/ (+ 1.0 (- y z)) z)) (/ (+ x (* x (- y z))) 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 <= -2.025964934226397e-05) || !(z <= 2033294.3313340866)) {
tmp = x * ((1.0 + (y - z)) / z);
} else {
tmp = (x + (x * (y - z))) / z;
}
return tmp;
}















Bits error versus x















Bits error versus y















Bits error versus z
Results
| Original | 10.4 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
| Alternative 1 | |
|---|---|
| Error | 1.7 |
| Cost | 576 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 904 |
| Alternative 3 | |
|---|---|
| Error | 1.8 |
| Cost | 904 |
| Alternative 4 | |
|---|---|
| Error | 2.4 |
| Cost | 776 |
| Alternative 5 | |
|---|---|
| Error | 9.7 |
| Cost | 1090 |
| Alternative 6 | |
|---|---|
| Error | 9.5 |
| Cost | 1090 |
| Alternative 7 | |
|---|---|
| Error | 11.8 |
| Cost | 648 |
| Alternative 8 | |
|---|---|
| Error | 24.3 |
| Cost | 648 |
| Alternative 9 | |
|---|---|
| Error | 24.1 |
| Cost | 648 |
| Alternative 10 | |
|---|---|
| Error | 32.8 |
| Cost | 128 |
| Alternative 11 | |
|---|---|
| Error | 61.8 |
| Cost | 64 |

if z < -2.025964934226397e-5 or 2033294.3313340866 < z Initial program 17.0
rmApplied *-un-lft-identity_binary64_1917417.0
Applied times-frac_binary64_191800.1
Simplified0.1
Simplified0.1
if -2.025964934226397e-5 < z < 2033294.3313340866Initial program 0.1
rmApplied distribute-rgt-in_binary64_191240.1
Simplified0.1
Simplified0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2021044
(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))