\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;z \le -3149.6947709486194:\\
\;\;\;\;\frac{\frac{x \cdot \left(-2\right)}{-\left(y - t\right)}}{z}\\
\mathbf{elif}\;z \le -7.1620056551756794 \cdot 10^{-309}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\
\mathbf{elif}\;z \le 2.4161758237400621 \cdot 10^{-244}:\\
\;\;\;\;\frac{\left(x \cdot \left(-2\right)\right) \cdot \frac{-1}{y - t}}{z}\\
\mathbf{elif}\;z \le 2.78048176862088268 \cdot 10^{-47}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot \left(-2\right)}{-\left(y - t\right)}}{z}\\
\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 ((z <= -3149.6947709486194)) {
VAR = (((x * -2.0) / -(y - t)) / z);
} else {
double VAR_1;
if ((z <= -7.16200565517568e-309)) {
VAR_1 = (x / ((z * (y - t)) / 2.0));
} else {
double VAR_2;
if ((z <= 2.416175823740062e-244)) {
VAR_2 = (((x * -2.0) * (-1.0 / (y - t))) / z);
} else {
double VAR_3;
if ((z <= 2.7804817686208827e-47)) {
VAR_3 = (x / ((z * (y - t)) / 2.0));
} else {
VAR_3 = (((x * -2.0) / -(y - t)) / z);
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.6 |
|---|---|
| Target | 2.1 |
| Herbie | 2.6 |
if z < -3149.6947709486194 or 2.7804817686208827e-47 < z Initial program 10.0
Simplified8.1
rmApplied div-inv8.2
Simplified8.2
rmApplied *-commutative8.2
Applied associate-/r*7.5
Applied associate-*r/2.0
rmApplied frac-2neg2.0
Applied associate-*r/2.0
if -3149.6947709486194 < z < -7.16200565517568e-309 or 2.416175823740062e-244 < z < 2.7804817686208827e-47Initial program 2.0
Simplified2.1
if -7.16200565517568e-309 < z < 2.416175823740062e-244Initial program 5.6
Simplified5.6
rmApplied div-inv6.2
Simplified6.2
rmApplied *-commutative6.2
Applied associate-/r*6.1
Applied associate-*r/18.3
rmApplied frac-2neg18.3
Applied associate-*r/18.2
rmApplied div-inv18.3
Simplified18.3
Final simplification2.6
herbie shell --seed 2020071 +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))))