\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \leq -3.2664811044545367 \cdot 10^{+243}:\\
\;\;\;\;\frac{x \cdot \frac{2}{z}}{y - t}\\
\mathbf{elif}\;y \cdot z - z \cdot t \leq -2.2702182992859946 \cdot 10^{-82}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{elif}\;y \cdot z - z \cdot t \leq 4.1364563040059193 \cdot 10^{-187}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\mathbf{elif}\;y \cdot z - z \cdot t \leq 7.838488152591629 \cdot 10^{+126}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\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 (<= (- (* y z) (* z t)) -3.2664811044545367e+243)
(/ (* x (/ 2.0 z)) (- y t))
(if (<= (- (* y z) (* z t)) -2.2702182992859946e-82)
(/ (* x 2.0) (* z (- y t)))
(if (<= (- (* y z) (* z t)) 4.1364563040059193e-187)
(* (/ 2.0 z) (/ x (- y t)))
(if (<= (- (* y z) (* z t)) 7.838488152591629e+126)
(/ (* x 2.0) (* z (- y t)))
(/ (/ (* 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 (((y * z) - (z * t)) <= -3.2664811044545367e+243) {
tmp = (x * (2.0 / z)) / (y - t);
} else if (((y * z) - (z * t)) <= -2.2702182992859946e-82) {
tmp = (x * 2.0) / (z * (y - t));
} else if (((y * z) - (z * t)) <= 4.1364563040059193e-187) {
tmp = (2.0 / z) * (x / (y - t));
} else if (((y * z) - (z * t)) <= 7.838488152591629e+126) {
tmp = (x * 2.0) / (z * (y - t));
} 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 | 7.0 |
|---|---|
| Target | 2.2 |
| Herbie | 1.1 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -3.2664811044545367e243Initial program 14.2
Simplified0.3
if -3.2664811044545367e243 < (-.f64 (*.f64 y z) (*.f64 t z)) < -2.2702182992859946e-82 or 4.13645630400591931e-187 < (-.f64 (*.f64 y z) (*.f64 t z)) < 7.83848815259162875e126Initial program 0.3
Simplified0.3
if -2.2702182992859946e-82 < (-.f64 (*.f64 y z) (*.f64 t z)) < 4.13645630400591931e-187Initial program 9.6
Simplified4.3
Taylor expanded around 0 9.6
Simplified4.5
if 7.83848815259162875e126 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 13.6
Simplified1.6
Final simplification1.1
herbie shell --seed 2021176
(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))))