\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
t_2 := \sqrt[3]{y - t}\\
\mathbf{if}\;t_1 \leq -1.7486352694326628 \cdot 10^{+296}:\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\
\mathbf{elif}\;t_1 \leq -7.916846244685067 \cdot 10^{-304}:\\
\;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(t_2 \cdot t_2\right)} \cdot \frac{\frac{2}{t_2}}{\sqrt[3]{z}}\\
\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y z) (* z t))) (t_2 (cbrt (- y t))))
(if (<= t_1 -1.7486352694326628e+296)
(/ (* x (/ 2.0 (- y t))) z)
(if (<= t_1 -7.916846244685067e-304)
(* 2.0 (/ x (* z (- y t))))
(*
(/ x (* (* (cbrt z) (cbrt z)) (* t_2 t_2)))
(/ (/ 2.0 t_2) (cbrt 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 t_1 = (y * z) - (z * t);
double t_2 = cbrt((y - t));
double tmp;
if (t_1 <= -1.7486352694326628e+296) {
tmp = (x * (2.0 / (y - t))) / z;
} else if (t_1 <= -7.916846244685067e-304) {
tmp = 2.0 * (x / (z * (y - t)));
} else {
tmp = (x / ((cbrt(z) * cbrt(z)) * (t_2 * t_2))) * ((2.0 / t_2) / cbrt(z));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.6 |
|---|---|
| Target | 2.0 |
| Herbie | 1.2 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -1.74863526943266277e296Initial program 17.8
Simplified16.4
Applied associate-*r/_binary640.1
if -1.74863526943266277e296 < (-.f64 (*.f64 y z) (*.f64 t z)) < -7.91684624468506695e-304Initial program 0.2
Simplified0.3
Taylor expanded in x around 0 0.2
if -7.91684624468506695e-304 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 8.9
Simplified6.6
Applied add-cube-cbrt_binary647.3
Applied add-cube-cbrt_binary647.4
Applied *-un-lft-identity_binary647.4
Applied times-frac_binary647.4
Applied times-frac_binary647.4
Applied associate-*r*_binary641.9
Simplified2.1
Final simplification1.2
herbie shell --seed 2022125
(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.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))
(/ (* x 2.0) (- (* y z) (* t z))))