\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.785532773814616831863731014933445423349 \cdot 10^{140}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.558923983411081976150022496277695268694 \cdot 10^{-162}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}\\
\mathbf{elif}\;y \le 3.047723682413627022763368644019132647617 \cdot 10^{-169}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{\sqrt{x \cdot x + y \cdot y}} \cdot \frac{x + y}{\sqrt{x \cdot x + y \cdot y}}\\
\end{array}double f(double x, double y) {
double r98562 = x;
double r98563 = y;
double r98564 = r98562 - r98563;
double r98565 = r98562 + r98563;
double r98566 = r98564 * r98565;
double r98567 = r98562 * r98562;
double r98568 = r98563 * r98563;
double r98569 = r98567 + r98568;
double r98570 = r98566 / r98569;
return r98570;
}
double f(double x, double y) {
double r98571 = y;
double r98572 = -1.7855327738146168e+140;
bool r98573 = r98571 <= r98572;
double r98574 = -1.0;
double r98575 = -1.558923983411082e-162;
bool r98576 = r98571 <= r98575;
double r98577 = 1.0;
double r98578 = x;
double r98579 = r98578 * r98578;
double r98580 = r98571 * r98571;
double r98581 = r98579 + r98580;
double r98582 = r98578 - r98571;
double r98583 = r98578 + r98571;
double r98584 = r98582 * r98583;
double r98585 = r98581 / r98584;
double r98586 = r98577 / r98585;
double r98587 = 3.047723682413627e-169;
bool r98588 = r98571 <= r98587;
double r98589 = sqrt(r98581);
double r98590 = r98582 / r98589;
double r98591 = r98583 / r98589;
double r98592 = r98590 * r98591;
double r98593 = r98588 ? r98577 : r98592;
double r98594 = r98576 ? r98586 : r98593;
double r98595 = r98573 ? r98574 : r98594;
return r98595;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.3 |
|---|---|
| Target | 0.0 |
| Herbie | 5.1 |
if y < -1.7855327738146168e+140Initial program 58.1
Taylor expanded around 0 0
if -1.7855327738146168e+140 < y < -1.558923983411082e-162Initial program 0.0
rmApplied clear-num0.0
if -1.558923983411082e-162 < y < 3.047723682413627e-169Initial program 30.6
rmApplied clear-num30.6
Taylor expanded around inf 15.9
if 3.047723682413627e-169 < y Initial program 1.1
rmApplied add-sqr-sqrt1.1
Applied times-frac1.6
Final simplification5.1
herbie shell --seed 2020001
(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))))