\frac{x \cdot 2}{y \cdot z - t \cdot z}\begin{array}{l}
\mathbf{if}\;z \leq -2.4796712913962077 \cdot 10^{+133}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\
\mathbf{elif}\;z \leq 1.00293945317054 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \frac{2}{\sqrt{z}}\right) \cdot \frac{\frac{1}{y - t}}{\sqrt{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 -2.4796712913962077e+133)
(/ (/ (* x 2.0) (- y t)) z)
(if (<= z 1.00293945317054e-310)
(* x (/ (/ 2.0 (- y t)) z))
(* (* x (/ 2.0 (sqrt z))) (/ (/ 1.0 (- y t)) (sqrt 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 <= -2.4796712913962077e+133) {
tmp = ((x * 2.0) / (y - t)) / z;
} else if (z <= 1.00293945317054e-310) {
tmp = x * ((2.0 / (y - t)) / z);
} else {
tmp = (x * (2.0 / sqrt(z))) * ((1.0 / (y - t)) / sqrt(z));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 7.0 |
|---|---|
| Target | 2.1 |
| Herbie | 3.6 |
if z < -2.4796712913962077e133Initial program 15.7
Simplified11.5
rmApplied *-un-lft-identity_binary6411.5
Applied add-cube-cbrt_binary6411.8
Applied *-un-lft-identity_binary6411.8
Applied times-frac_binary6411.8
Applied times-frac_binary6411.8
Applied associate-*r*_binary644.7
Simplified4.7
rmApplied associate-*r/_binary642.7
Simplified2.3
if -2.4796712913962077e133 < z < 1.00293945317054e-310Initial program 3.7
Simplified3.6
if 1.00293945317054e-310 < z Initial program 6.6
Simplified5.5
rmApplied add-sqr-sqrt_binary645.6
Applied div-inv_binary645.6
Applied times-frac_binary645.6
Applied associate-*r*_binary644.1
Final simplification3.6
herbie shell --seed 2020220
(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))))