\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;x \cdot 2 \leq -1.1749622850726272 \cdot 10^{-27} \lor \neg \left(x \cdot 2 \leq 3737.5144130491194\right):\\
\;\;\;\;\frac{x \cdot 2}{y - t} \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\
\end{array}(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
:precision binary64
(if (or (<= (* x 2.0) -1.1749622850726272e-27)
(not (<= (* x 2.0) 3737.5144130491194)))
(* (/ (* x 2.0) (- y t)) (/ 1.0 z))
(/ (/ (* x 2.0) z) (- y t))))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 (((x * 2.0) <= -1.1749622850726272e-27) || !((x * 2.0) <= 3737.5144130491194)) {
tmp = ((x * 2.0) / (y - t)) * (1.0 / z);
} else {
tmp = ((x * 2.0) / z) / (y - t);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.8 |
|---|---|
| Target | 2.2 |
| Herbie | 2.3 |
if (*.f64 x 2) < -1.1749622850726272e-27 or 3737.51441304911941 < (*.f64 x 2) Initial program 10.5
Simplified8.9
rmApplied associate-*r/_binary642.7
rmApplied associate-*r/_binary642.6
rmApplied div-inv_binary642.7
if -1.1749622850726272e-27 < (*.f64 x 2) < 3737.51441304911941Initial program 3.4
Simplified2.3
rmApplied associate-*r/_binary648.3
rmApplied associate-*r/_binary648.2
rmApplied div-inv_binary648.3
rmApplied associate-*l/_binary641.9
Simplified1.9
Final simplification2.3
herbie shell --seed 2020233
(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))))