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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if z < -18726034.1761924289Initial program 17.2
Applied *-un-lft-identity_binary6417.2
Applied times-frac_binary640.1
Simplified0.1
Simplified0.1
Applied div-sub_binary640.1
Simplified0.1
Applied sub-neg_binary640.1
Applied distribute-lft-in_binary640.1
if -18726034.1761924289 < z < 2.3894198743051582e-56Initial program 0.1
if 2.3894198743051582e-56 < z Initial program 14.2
Applied *-un-lft-identity_binary6414.2
Applied times-frac_binary640.2
Simplified0.2
Simplified0.2
Applied div-sub_binary640.2
Simplified0.2
Applied clear-num_binary640.2
Simplified0.2
Final simplification0.1
herbie shell --seed 2022024
(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))