\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
t_2 := \frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{if}\;t_1 \leq -7.346581112776964 \cdot 10^{+246}:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\
\mathbf{elif}\;t_1 \leq -4.510519146821146 \cdot 10^{-157}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{2}{y - t} \cdot \left(x \cdot \frac{1}{z}\right)\\
\mathbf{elif}\;t_1 \leq 3.3690673652284793 \cdot 10^{+210}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \frac{1}{z}}{\frac{y - t}{x}}\\
\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 (/ (* x 2.0) (* z (- y t)))))
(if (<= t_1 -7.346581112776964e+246)
(* (/ x (- y t)) (/ 2.0 z))
(if (<= t_1 -4.510519146821146e-157)
t_2
(if (<= t_1 0.0)
(* (/ 2.0 (- y t)) (* x (/ 1.0 z)))
(if (<= t_1 3.3690673652284793e+210)
t_2
(/ (* 2.0 (/ 1.0 z)) (/ (- y t) x))))))))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 = (x * 2.0) / (z * (y - t));
double tmp;
if (t_1 <= -7.346581112776964e+246) {
tmp = (x / (y - t)) * (2.0 / z);
} else if (t_1 <= -4.510519146821146e-157) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (2.0 / (y - t)) * (x * (1.0 / z));
} else if (t_1 <= 3.3690673652284793e+210) {
tmp = t_2;
} else {
tmp = (2.0 * (1.0 / z)) / ((y - t) / x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.9 |
|---|---|
| Target | 2.1 |
| Herbie | 0.4 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -7.346581112776964e246Initial program 14.5
Simplified13.4
Applied egg-rr0.2
Taylor expanded in x around 0 0.2
Applied egg-rr0.2
if -7.346581112776964e246 < (-.f64 (*.f64 y z) (*.f64 t z)) < -4.5105191468211463e-157 or 0.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 3.36906736522847935e210Initial program 0.3
Simplified0.5
Applied egg-rr0.3
if -4.5105191468211463e-157 < (-.f64 (*.f64 y z) (*.f64 t z)) < 0.0Initial program 19.0
Simplified19.9
Applied egg-rr2.6
Applied egg-rr3.1
if 3.36906736522847935e210 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 18.6
Simplified12.2
Applied egg-rr0.2
Taylor expanded in x around 0 0.2
Applied egg-rr0.9
Applied egg-rr0.3
Final simplification0.4
herbie shell --seed 2022130
(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))))