\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -5.351376453551335025298421937367139214806 \cdot 10^{150}:\\
\;\;\;\;\log \left(e^{-1}\right)\\
\mathbf{elif}\;y \le -6.671301972241293882608101356321744148883 \cdot 10^{-163}:\\
\;\;\;\;\log \left(e^{\frac{\left(y + x\right) \cdot \left(x - y\right)}{x \cdot x + y \cdot y}}\right)\\
\mathbf{elif}\;y \le -6.640367748625040373106765238414079239901 \cdot 10^{-188}:\\
\;\;\;\;\log \left(e^{-1}\right)\\
\mathbf{elif}\;y \le 2.495375493781523854915214205899519972995 \cdot 10^{-161}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{\left(y + x\right) \cdot \left(x - y\right)}{x \cdot x + y \cdot y}}\right)\\
\end{array}double f(double x, double y) {
double r114539 = x;
double r114540 = y;
double r114541 = r114539 - r114540;
double r114542 = r114539 + r114540;
double r114543 = r114541 * r114542;
double r114544 = r114539 * r114539;
double r114545 = r114540 * r114540;
double r114546 = r114544 + r114545;
double r114547 = r114543 / r114546;
return r114547;
}
double f(double x, double y) {
double r114548 = y;
double r114549 = -5.351376453551335e+150;
bool r114550 = r114548 <= r114549;
double r114551 = -1.0;
double r114552 = exp(r114551);
double r114553 = log(r114552);
double r114554 = -6.671301972241294e-163;
bool r114555 = r114548 <= r114554;
double r114556 = x;
double r114557 = r114548 + r114556;
double r114558 = r114556 - r114548;
double r114559 = r114557 * r114558;
double r114560 = r114556 * r114556;
double r114561 = r114548 * r114548;
double r114562 = r114560 + r114561;
double r114563 = r114559 / r114562;
double r114564 = exp(r114563);
double r114565 = log(r114564);
double r114566 = -6.64036774862504e-188;
bool r114567 = r114548 <= r114566;
double r114568 = 2.495375493781524e-161;
bool r114569 = r114548 <= r114568;
double r114570 = 1.0;
double r114571 = r114569 ? r114570 : r114565;
double r114572 = r114567 ? r114553 : r114571;
double r114573 = r114555 ? r114565 : r114572;
double r114574 = r114550 ? r114553 : r114573;
return r114574;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.4 |
|---|---|
| Target | 0.0 |
| Herbie | 5.1 |
if y < -5.351376453551335e+150 or -6.671301972241294e-163 < y < -6.64036774862504e-188Initial program 59.1
Simplified57.5
rmApplied add-log-exp57.5
Taylor expanded around 0 4.5
if -5.351376453551335e+150 < y < -6.671301972241294e-163 or 2.495375493781524e-161 < y Initial program 0.1
Simplified0.6
rmApplied add-log-exp0.7
rmApplied associate-*l/0.1
Simplified0.1
if -6.64036774862504e-188 < y < 2.495375493781524e-161Initial program 30.1
Simplified30.8
rmApplied add-log-exp30.7
rmApplied associate-*l/30.1
Simplified30.1
Taylor expanded around 0 14.2
Final simplification5.1
herbie shell --seed 2019208
(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))))