\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -2.14107292843783933 \cdot 10^{-275}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\
\mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 2.22545972557674268 \cdot 10^{45}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \frac{\frac{y - t}{2}}{x}}\\
\end{array}double code(double x, double y, double z, double t) {
return ((x * 2.0) / ((y * z) - (t * z)));
}
double code(double x, double y, double z, double t) {
double VAR;
if ((((x * 2.0) / ((y * z) - (t * z))) <= -2.1410729284378393e-275)) {
VAR = ((x * 2.0) / ((y * z) - (t * z)));
} else {
double VAR_1;
if ((((x * 2.0) / ((y * z) - (t * z))) <= 2.2254597255767427e+45)) {
VAR_1 = ((x / z) / ((y - t) / 2.0));
} else {
VAR_1 = (1.0 / (z * (((y - t) / 2.0) / x)));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.9 |
|---|---|
| Target | 2.0 |
| Herbie | 1.7 |
if (/ (* x 2.0) (- (* y z) (* t z))) < -2.1410729284378393e-275Initial program 1.5
if -2.1410729284378393e-275 < (/ (* x 2.0) (- (* y z) (* t z))) < 2.2254597255767427e+45Initial program 7.9
Simplified7.9
rmApplied *-un-lft-identity7.9
Applied times-frac7.9
Applied associate-/r*1.3
Simplified1.3
if 2.2254597255767427e+45 < (/ (* x 2.0) (- (* y z) (* t z))) Initial program 14.1
Simplified6.0
rmApplied *-un-lft-identity6.0
Applied times-frac6.0
Applied *-un-lft-identity6.0
Applied times-frac3.4
Simplified3.4
rmApplied associate-*l/3.3
Simplified3.3
rmApplied clear-num3.4
rmApplied associate-/l/3.2
Final simplification1.7
herbie shell --seed 2020102 +o rules:numerics
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:precision binary64
:herbie-target
(if (< (/ (* x 2) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2) (if (< (/ (* x 2) (- (* y z) (* t z))) 1.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))
(/ (* x 2) (- (* y z) (* t z))))