\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_1 := \frac{x}{\mathsf{fma}\left(0.5, \frac{x}{y}, -0.5\right)}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -4.9413458312946296 \cdot 10^{-293}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 3.172930057284486 \cdot 10^{-84}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (* x 2.0) y) (- x y))) (t_1 (/ x (fma 0.5 (/ x y) -0.5))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -4.9413458312946296e-293)
t_0
(if (<= t_0 0.0) t_1 (if (<= t_0 3.172930057284486e-84) t_0 t_1))))))double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
double code(double x, double y) {
double t_0 = ((x * 2.0) * y) / (x - y);
double t_1 = x / fma(0.5, (x / y), -0.5);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -4.9413458312946296e-293) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 3.172930057284486e-84) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 15.2 |
|---|---|
| Target | 0.3 |
| Herbie | 1.0 |
if (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < -inf.0 or -4.94134583129462956e-293 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < 0.0 or 3.1729300572844862e-84 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) Initial program 37.7
Simplified1.7
if -inf.0 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < -4.94134583129462956e-293 or 0.0 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < 3.1729300572844862e-84Initial program 0.6
Final simplification1.0
herbie shell --seed 2022077
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
:herbie-target
(if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))
(/ (* (* x 2.0) y) (- x y)))