\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -8.970176524587994 \cdot 10^{+114}:\\
\;\;\;\;x \cdot \frac{\left(1 + y\right) - z}{z}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := 1 + \left(y - z\right)\\
\mathbf{if}\;z \leq 5.246984068361077 \cdot 10^{-119}:\\
\;\;\;\;\frac{x}{z} \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (<= z -8.970176524587994e+114)
(* x (/ (- (+ 1.0 y) z) z))
(let* ((t_0 (+ 1.0 (- y z))))
(if (<= z 5.246984068361077e-119) (* (/ x z) t_0) (/ x (/ z t_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 <= -8.970176524587994e+114) {
tmp = x * (((1.0 + y) - z) / z);
} else {
double t_0 = 1.0 + (y - z);
double tmp_1;
if (z <= 5.246984068361077e-119) {
tmp_1 = (x / z) * t_0;
} else {
tmp_1 = x / (z / t_0);
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.4 |
|---|---|
| Target | 0.4 |
| Herbie | 0.7 |
if z < -8.970176524587994e114Initial program 20.1
Applied *-un-lft-identity_binary6420.1
Applied times-frac_binary640.0
Simplified0.0
Simplified0.0
if -8.970176524587994e114 < z < 5.24698406836107669e-119Initial program 1.1
Applied associate-/l*_binary644.4
Applied associate-/r/_binary641.1
if 5.24698406836107669e-119 < z Initial program 10.7
Applied associate-/l*_binary640.6
Final simplification0.7
herbie shell --seed 2022068
(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))