\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \leq -3.9126001633745477 \cdot 10^{-11} \lor \neg \left(x \leq 2.944504131166995 \cdot 10^{-212}\right):\\
\;\;\;\;\left(\frac{x}{z} + \frac{x}{z} \cdot y\right) - x\\
\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 (<= x -3.9126001633745477e-11) (not (<= x 2.944504131166995e-212))) (- (+ (/ x z) (* (/ x z) y)) x) (/ (+ 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 ((x <= -3.9126001633745477e-11) || !(x <= 2.944504131166995e-212)) {
tmp = ((x / z) + ((x / z) * y)) - x;
} else {
tmp = (x + (x * (y - z))) / z;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 9.8 |
|---|---|
| Target | 0.4 |
| Herbie | 0.3 |
if x < -3.91260016337454765e-11 or 2.94450413116699479e-212 < x Initial program 16.0
Taylor expanded around 0 5.6
Simplified0.5
if -3.91260016337454765e-11 < x < 2.94450413116699479e-212Initial program 0.2
rmApplied distribute-rgt-in_binary64_111500.2
Simplified0.2
Simplified0.2
Final simplification0.3
herbie shell --seed 2020281
(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))