\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -7.97560835483767313443274064459131142554 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.033522684534884437001190823053512215602 \cdot 10^{-155}:\\
\;\;\;\;\frac{-1}{\frac{x \cdot x + y \cdot y}{y \cdot y - x \cdot x}}\\
\mathbf{elif}\;y \le 1.497237818899669451923578244569587493317 \cdot 10^{-159}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x \cdot x + y \cdot y}{y \cdot y - x \cdot x}}\\
\end{array}double f(double x, double y) {
double r4649140 = x;
double r4649141 = y;
double r4649142 = r4649140 - r4649141;
double r4649143 = r4649140 + r4649141;
double r4649144 = r4649142 * r4649143;
double r4649145 = r4649140 * r4649140;
double r4649146 = r4649141 * r4649141;
double r4649147 = r4649145 + r4649146;
double r4649148 = r4649144 / r4649147;
return r4649148;
}
double f(double x, double y) {
double r4649149 = y;
double r4649150 = -7.975608354837673e+153;
bool r4649151 = r4649149 <= r4649150;
double r4649152 = -1.0;
double r4649153 = -1.0335226845348844e-155;
bool r4649154 = r4649149 <= r4649153;
double r4649155 = x;
double r4649156 = r4649155 * r4649155;
double r4649157 = r4649149 * r4649149;
double r4649158 = r4649156 + r4649157;
double r4649159 = r4649157 - r4649156;
double r4649160 = r4649158 / r4649159;
double r4649161 = r4649152 / r4649160;
double r4649162 = 1.4972378188996695e-159;
bool r4649163 = r4649149 <= r4649162;
double r4649164 = 1.0;
double r4649165 = r4649163 ? r4649164 : r4649161;
double r4649166 = r4649154 ? r4649161 : r4649165;
double r4649167 = r4649151 ? r4649152 : r4649166;
return r4649167;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.6 |
|---|---|
| Target | 0.0 |
| Herbie | 5.3 |
if y < -7.975608354837673e+153Initial program 63.9
Simplified63.9
Taylor expanded around inf 0
if -7.975608354837673e+153 < y < -1.0335226845348844e-155 or 1.4972378188996695e-159 < y Initial program 0.0
Simplified0.0
rmApplied difference-of-squares0.0
Applied associate-/l*0.2
rmApplied clear-num0.2
Simplified0.0
if -1.0335226845348844e-155 < y < 1.4972378188996695e-159Initial program 29.0
Simplified29.0
Taylor expanded around 0 16.2
Final simplification5.3
herbie shell --seed 2019170
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 0.0 x 1.0) (< y 1.0))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2.0) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))