\frac{\left(x \cdot 2\right) \cdot y}{x - y}\begin{array}{l}
\mathbf{if}\;y \le -2.63292485784489089 \cdot 10^{-6} \lor \neg \left(y \le 5.04809076225120711 \cdot 10^{-38}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - y} \cdot \left(2 \cdot y\right)\\
\end{array}double code(double x, double y) {
return (((double) (((double) (x * 2.0)) * y)) / ((double) (x - y)));
}
double code(double x, double y) {
double VAR;
if (((y <= -2.632924857844891e-06) || !(y <= 5.048090762251207e-38))) {
VAR = (((double) (x * 2.0)) / ((double) ((x / y) - 1.0)));
} else {
VAR = ((double) ((x / ((double) (x - y))) * ((double) (2.0 * y))));
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 14.9 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
if y < -2.63292485784489089e-6 or 5.04809076225120711e-38 < y Initial program 15.2
rmApplied associate-/l*0.2
rmApplied div-sub0.2
Simplified0.2
if -2.63292485784489089e-6 < y < 5.04809076225120711e-38Initial program 14.6
rmApplied associate-/l*16.8
rmApplied div-inv16.9
Applied times-frac0.2
Simplified0.0
Final simplification0.1
herbie shell --seed 2020182
(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 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))
(/ (* (* x 2.0) y) (- x y)))