\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -9.821782313314639955086003839853747327964 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.937646393364570937539099703487067921288 \cdot 10^{-161}:\\
\;\;\;\;\frac{\frac{x \cdot x - y \cdot y}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}}{\left(x + y\right) \cdot \left(x - y\right)}\\
\mathbf{elif}\;y \le 1.828260016637030233456157191815862132037 \cdot 10^{-162}:\\
\;\;\;\;1\\
\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 r97003 = x;
double r97004 = y;
double r97005 = r97003 - r97004;
double r97006 = r97003 + r97004;
double r97007 = r97005 * r97006;
double r97008 = r97003 * r97003;
double r97009 = r97004 * r97004;
double r97010 = r97008 + r97009;
double r97011 = r97007 / r97010;
return r97011;
}
double f(double x, double y) {
double r97012 = y;
double r97013 = -9.82178231331464e+153;
bool r97014 = r97012 <= r97013;
double r97015 = -1.0;
double r97016 = -1.937646393364571e-161;
bool r97017 = r97012 <= r97016;
double r97018 = x;
double r97019 = r97018 * r97018;
double r97020 = r97012 * r97012;
double r97021 = r97019 - r97020;
double r97022 = r97019 + r97020;
double r97023 = r97018 - r97012;
double r97024 = r97018 + r97012;
double r97025 = r97023 * r97024;
double r97026 = r97022 / r97025;
double r97027 = r97021 / r97026;
double r97028 = r97024 * r97023;
double r97029 = r97027 / r97028;
double r97030 = 1.8282600166370302e-162;
bool r97031 = r97012 <= r97030;
double r97032 = 1.0;
double r97033 = r97025 / r97022;
double r97034 = r97031 ? r97032 : r97033;
double r97035 = r97017 ? r97029 : r97034;
double r97036 = r97014 ? r97015 : r97035;
return r97036;
}




Bits error versus x




Bits error versus y
Results
| Original | 19.9 |
|---|---|
| Target | 0.1 |
| Herbie | 4.6 |
if y < -9.82178231331464e+153Initial program 63.9
rmApplied clear-num63.9
rmApplied flip-+63.9
Applied flip--63.9
Applied frac-times64.0
Applied associate-/r/64.0
Applied associate-/r*64.0
Simplified63.9
Taylor expanded around 0 0
if -9.82178231331464e+153 < y < -1.937646393364571e-161Initial program 0.0
rmApplied clear-num0.0
rmApplied flip-+0.0
Applied flip--0.1
Applied frac-times27.9
Applied associate-/r/28.0
Applied associate-/r*28.0
Simplified0.0
if -1.937646393364571e-161 < y < 1.8282600166370302e-162Initial program 29.7
rmApplied clear-num29.7
Taylor expanded around inf 14.6
if 1.8282600166370302e-162 < y Initial program 0.1
Final simplification4.6
herbie shell --seed 2019303
(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))))