\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;z \le -3.7870085792068665 \cdot 10^{29}:\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\
\mathbf{elif}\;z \le 2.1693266226356799 \cdot 10^{65}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\
\end{array}double code(double x, double y, double z, double t) {
return (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z)))));
}
double code(double x, double y, double z, double t) {
double VAR;
if ((z <= -3.7870085792068665e+29)) {
VAR = (((double) (x * (2.0 / ((double) (y - t))))) / z);
} else {
double VAR_1;
if ((z <= 2.16932662263568e+65)) {
VAR_1 = ((double) (x * ((2.0 / ((double) (y - t))) / z)));
} else {
VAR_1 = ((double) (((double) (x * (2.0 / ((double) (y - t))))) * (1.0 / z)));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 7.3 |
|---|---|
| Target | 2.2 |
| Herbie | 2.5 |
if z < -3.7870085792068665e29Initial program 12.2
Simplified10.5
rmApplied add-sqr-sqrt10.8
Applied times-frac9.8
rmApplied associate-*l/9.8
Applied associate-*r/2.5
Simplified2.3
if -3.7870085792068665e29 < z < 2.1693266226356799e65Initial program 2.4
Simplified2.6
rmApplied add-sqr-sqrt3.4
Applied times-frac2.9
rmApplied associate-*l/2.9
Simplified2.5
if 2.1693266226356799e65 < z Initial program 13.7
Simplified11.3
rmApplied add-sqr-sqrt11.6
Applied times-frac10.6
rmApplied associate-*l/10.6
Simplified10.4
rmApplied div-inv10.4
Applied associate-*r*2.6
Final simplification2.5
herbie shell --seed 2020182
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:precision binary64
:herbie-target
(if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.0450278273301259e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))
(/ (* x 2.0) (- (* y z) (* t z))))