\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.6756213551274553 \cdot 10^{151}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.78621350836968853 \cdot 10^{-162}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{y \cdot y + x \cdot x}\\
\mathbf{elif}\;y \le 5.3431862292807695 \cdot 10^{-166}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log \left({e}^{\left(\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\right)}\right)\\
\end{array}double f(double x, double y) {
double r120687 = x;
double r120688 = y;
double r120689 = r120687 - r120688;
double r120690 = r120687 + r120688;
double r120691 = r120689 * r120690;
double r120692 = r120687 * r120687;
double r120693 = r120688 * r120688;
double r120694 = r120692 + r120693;
double r120695 = r120691 / r120694;
return r120695;
}
double f(double x, double y) {
double r120696 = y;
double r120697 = -1.6756213551274553e+151;
bool r120698 = r120696 <= r120697;
double r120699 = -1.0;
double r120700 = -1.7862135083696885e-162;
bool r120701 = r120696 <= r120700;
double r120702 = x;
double r120703 = r120702 - r120696;
double r120704 = r120702 + r120696;
double r120705 = r120703 * r120704;
double r120706 = r120696 * r120696;
double r120707 = r120702 * r120702;
double r120708 = r120706 + r120707;
double r120709 = r120705 / r120708;
double r120710 = 5.3431862292807695e-166;
bool r120711 = r120696 <= r120710;
double r120712 = 1.0;
double r120713 = exp(1.0);
double r120714 = r120707 + r120706;
double r120715 = r120705 / r120714;
double r120716 = pow(r120713, r120715);
double r120717 = log(r120716);
double r120718 = r120711 ? r120712 : r120717;
double r120719 = r120701 ? r120709 : r120718;
double r120720 = r120698 ? r120699 : r120719;
return r120720;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.2 |
|---|---|
| Target | 0.1 |
| Herbie | 4.9 |
if y < -1.6756213551274553e+151Initial program 62.6
Taylor expanded around 0 0
if -1.6756213551274553e+151 < y < -1.7862135083696885e-162Initial program 0.0
rmApplied +-commutative0.0
if -1.7862135083696885e-162 < y < 5.3431862292807695e-166Initial program 30.3
rmApplied add-log-exp30.3
rmApplied *-un-lft-identity30.3
Applied exp-prod30.3
Simplified30.3
Taylor expanded around inf 15.7
if 5.3431862292807695e-166 < y Initial program 0.5
rmApplied add-log-exp0.5
rmApplied *-un-lft-identity0.5
Applied exp-prod0.5
Simplified0.5
Final simplification4.9
herbie shell --seed 2020034
(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))))