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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 9.8 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if z < -3.95991621114105785e36Initial program 17.4
rmApplied *-un-lft-identity_binary64_1508217.4
Applied times-frac_binary64_150880.1
Simplified0.1
Simplified0.1
rmApplied div-sub_binary64_150870.1
Simplified0.1
if -3.95991621114105785e36 < z < 3554052558.67814207Initial program 0.3
Taylor expanded around 0 0.3
Simplified0.2
Taylor expanded around 0 0.3
if 3554052558.67814207 < z Initial program 16.9
rmApplied *-un-lft-identity_binary64_1508216.9
Applied times-frac_binary64_150880.1
Simplified0.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2021042
(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))