\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}\\
\mathbf{if}\;t_0 \leq -1.6794345349847786 \cdot 10^{-18} \lor \neg \left(t_0 \leq -2.596886978949595 \cdot 10^{-276}\right) \land \left(t_0 \leq 0 \lor \neg \left(t_0 \leq 5.6718949189646674 \cdot 10^{-24}\right)\right):\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(0.5, \frac{x}{y}, -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\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))))
(if (or (<= t_0 -1.6794345349847786e-18)
(and (not (<= t_0 -2.596886978949595e-276))
(or (<= t_0 0.0) (not (<= t_0 5.6718949189646674e-24)))))
(/ x (fma 0.5 (/ x y) -0.5))
t_0)))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 tmp;
if ((t_0 <= -1.6794345349847786e-18) || (!(t_0 <= -2.596886978949595e-276) && ((t_0 <= 0.0) || !(t_0 <= 5.6718949189646674e-24)))) {
tmp = x / fma(0.5, (x / y), -0.5);
} else {
tmp = t_0;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 15.1 |
|---|---|
| Target | 0.4 |
| Herbie | 1.1 |
if (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < -1.6794345349847786e-18 or -2.5968869789495951e-276 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < -0.0 or 5.6718949189646674e-24 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) Initial program 35.0
Simplified1.8
if -1.6794345349847786e-18 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < -2.5968869789495951e-276 or -0.0 < (/.f64 (*.f64 (*.f64 x 2) y) (-.f64 x y)) < 5.6718949189646674e-24Initial program 0.6
Final simplification1.1
herbie shell --seed 2021280
(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)))