\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -2.80898223204847208 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.1817900146375154 \cdot 10^{-146}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{elif}\;y \le 4.78768032214213612 \cdot 10^{-164}:\\
\;\;\;\;\frac{x - y}{x - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\end{array}double f(double x, double y) {
double r123077 = x;
double r123078 = y;
double r123079 = r123077 - r123078;
double r123080 = r123077 + r123078;
double r123081 = r123079 * r123080;
double r123082 = r123077 * r123077;
double r123083 = r123078 * r123078;
double r123084 = r123082 + r123083;
double r123085 = r123081 / r123084;
return r123085;
}
double f(double x, double y) {
double r123086 = y;
double r123087 = -2.808982232048472e+153;
bool r123088 = r123086 <= r123087;
double r123089 = -1.0;
double r123090 = -1.1817900146375154e-146;
bool r123091 = r123086 <= r123090;
double r123092 = x;
double r123093 = r123092 - r123086;
double r123094 = r123092 + r123086;
double r123095 = r123093 * r123094;
double r123096 = r123092 * r123092;
double r123097 = r123086 * r123086;
double r123098 = r123096 + r123097;
double r123099 = r123095 / r123098;
double r123100 = 4.787680322142136e-164;
bool r123101 = r123086 <= r123100;
double r123102 = r123093 / r123093;
double r123103 = r123101 ? r123102 : r123099;
double r123104 = r123091 ? r123099 : r123103;
double r123105 = r123088 ? r123089 : r123104;
return r123105;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.4 |
|---|---|
| Target | 0.0 |
| Herbie | 5.4 |
if y < -2.808982232048472e+153Initial program 63.7
Taylor expanded around 0 0
if -2.808982232048472e+153 < y < -1.1817900146375154e-146 or 4.787680322142136e-164 < y Initial program 0.2
if -1.1817900146375154e-146 < y < 4.787680322142136e-164Initial program 28.9
rmApplied associate-/l*29.9
Simplified29.9
Taylor expanded around inf 15.9
Final simplification5.4
herbie shell --seed 2020033
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (< 0.0 x 1) (< y 1))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1 (/ 2 (+ 1 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))