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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.5 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if z < -4.02560978749946445e45Initial program 19.2
rmApplied *-un-lft-identity_binary6419.2
Applied times-frac_binary640.1
Simplified0.1
if -4.02560978749946445e45 < z < 10774447.6587929782Initial program 0.4
rmApplied associate-/l*_binary647.3
rmApplied div-inv_binary647.4
Applied associate-/r*_binary640.4
if 10774447.6587929782 < z Initial program 17.9
rmApplied associate-/l*_binary640.1
Final simplification0.2
herbie shell --seed 2020288
(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))