\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \leq -2.348422580235895 \cdot 10^{-102}:\\
\;\;\;\;\left(\frac{x}{z} + \frac{x}{z} \cdot y\right) - x\\
\mathbf{elif}\;x \leq 2.9893049285506444 \cdot 10^{-16}:\\
\;\;\;\;\left(\frac{x}{z} + \frac{x \cdot y}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y + 1\right) - z}}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (<= x -2.348422580235895e-102)
(- (+ (/ x z) (* (/ x z) y)) x)
(if (<= x 2.9893049285506444e-16)
(- (+ (/ x z) (/ (* x y) z)) x)
(/ x (/ z (- (+ y 1.0) 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 <= -2.348422580235895e-102) {
tmp = ((x / z) + ((x / z) * y)) - x;
} else if (x <= 2.9893049285506444e-16) {
tmp = ((x / z) + ((x * y) / z)) - x;
} else {
tmp = x / (z / ((y + 1.0) - z));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.0 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
if x < -2.34842258023589519e-102Initial program 17.1
Taylor expanded around 0 5.6
Simplified0.2
if -2.34842258023589519e-102 < x < 2.9893049285506444e-16Initial program 0.2
Taylor expanded around 0 0.1
if 2.9893049285506444e-16 < x Initial program 23.4
rmApplied associate-/l*_binary64_180960.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2021019
(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))