\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\
\;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\
\mathbf{elif}\;y \cdot z - z \cdot t \leq -1.7542876780262188 \cdot 10^{-189}:\\
\;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{elif}\;y \cdot z - z \cdot t \leq 1.494963151258016 \cdot 10^{-125} \lor \neg \left(y \cdot z - z \cdot t \leq 2.0363037439895763 \cdot 10^{+189}\right):\\
\;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{y \cdot z - z \cdot 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)) (- INFINITY))
(/ (* 2.0 (/ x (- y t))) z)
(if (<= (- (* y z) (* z t)) -1.7542876780262188e-189)
(* 2.0 (/ x (* z (- y t))))
(if (or (<= (- (* y z) (* z t)) 1.494963151258016e-125)
(not (<= (- (* y z) (* z t)) 2.0363037439895763e+189)))
(/ (* 2.0 (/ x (- y t))) z)
(/ (* 2.0 x) (- (* y z) (* z 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)) <= -((double) INFINITY)) {
tmp = (2.0 * (x / (y - t))) / z;
} else if (((y * z) - (z * t)) <= -1.7542876780262188e-189) {
tmp = 2.0 * (x / (z * (y - t)));
} else if ((((y * z) - (z * t)) <= 1.494963151258016e-125) || !(((y * z) - (z * t)) <= 2.0363037439895763e+189)) {
tmp = (2.0 * (x / (y - t))) / z;
} else {
tmp = (2.0 * x) / ((y * z) - (z * t));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.7 |
|---|---|
| Target | 2.3 |
| Herbie | 0.5 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0 or -1.7542876780262188e-189 < (-.f64 (*.f64 y z) (*.f64 t z)) < 1.4949631512580159e-125 or 2.03630374398957635e189 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 16.7
Simplified13.2
rmApplied *-un-lft-identity_binary64_1337713.2
Applied add-cube-cbrt_binary64_1341213.5
Applied *-un-lft-identity_binary64_1337713.5
Applied times-frac_binary64_1338313.5
Applied times-frac_binary64_1338313.5
Applied associate-*r*_binary64_133173.5
Simplified3.5
rmApplied pow1_binary64_134383.5
Applied pow1_binary64_134383.5
Applied pow-prod-down_binary64_134483.5
Simplified0.9
if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < -1.7542876780262188e-189Initial program 0.2
Simplified0.3
Taylor expanded around 0 0.2
if 1.4949631512580159e-125 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.03630374398957635e189Initial program 0.3
Final simplification0.5
herbie shell --seed 2021044
(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))))