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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.8 |
|---|---|
| Target | 2.3 |
| Herbie | 2.5 |
if z < -5.4934368200861185e45Initial program 11.8
Simplified8.8
rmApplied associate-*r/_binary642.9
rmApplied associate-*r/_binary642.8
rmApplied div-inv_binary642.9
if -5.4934368200861185e45 < z < 4.63146271697406693e-61Initial program 2.8
Simplified2.9
rmApplied associate-*r/_binary649.7
rmApplied associate-*r/_binary649.7
Applied associate-/l/_binary642.8
Simplified2.8
if 4.63146271697406693e-61 < z Initial program 9.0
Simplified6.8
rmApplied associate-*r/_binary641.9
rmApplied associate-*r/_binary642.0
Final simplification2.5
herbie shell --seed 2020231
(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))))