\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.1564294007415584 \cdot 10^{+23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -4.9781449920664 \cdot 10^{-177}:\\
\;\;\;\;\log \left(e^{\frac{x - y}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot y\right)\right)}{y + x}}}\right)\\
\mathbf{elif}\;y \le 1.0919689144745608 \cdot 10^{-199}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{x - y}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot y\right)\right)}{y + x}}}\right)\\
\end{array}double f(double x, double y) {
double r19187147 = x;
double r19187148 = y;
double r19187149 = r19187147 - r19187148;
double r19187150 = r19187147 + r19187148;
double r19187151 = r19187149 * r19187150;
double r19187152 = r19187147 * r19187147;
double r19187153 = r19187148 * r19187148;
double r19187154 = r19187152 + r19187153;
double r19187155 = r19187151 / r19187154;
return r19187155;
}
double f(double x, double y) {
double r19187156 = y;
double r19187157 = -1.1564294007415584e+23;
bool r19187158 = r19187156 <= r19187157;
double r19187159 = -1.0;
double r19187160 = -4.9781449920664e-177;
bool r19187161 = r19187156 <= r19187160;
double r19187162 = x;
double r19187163 = r19187162 - r19187156;
double r19187164 = r19187156 * r19187156;
double r19187165 = fma(r19187162, r19187162, r19187164);
double r19187166 = r19187156 + r19187162;
double r19187167 = r19187165 / r19187166;
double r19187168 = r19187163 / r19187167;
double r19187169 = exp(r19187168);
double r19187170 = log(r19187169);
double r19187171 = 1.0919689144745608e-199;
bool r19187172 = r19187156 <= r19187171;
double r19187173 = 1.0;
double r19187174 = r19187172 ? r19187173 : r19187170;
double r19187175 = r19187161 ? r19187170 : r19187174;
double r19187176 = r19187158 ? r19187159 : r19187175;
return r19187176;
}




Bits error versus x




Bits error versus y
| Original | 20.3 |
|---|---|
| Target | 0.1 |
| Herbie | 5.4 |
if y < -1.1564294007415584e+23Initial program 35.3
Simplified35.3
rmApplied add-log-exp35.3
rmApplied associate-/l*34.5
Taylor expanded around 0 0
if -1.1564294007415584e+23 < y < -4.9781449920664e-177 or 1.0919689144745608e-199 < y Initial program 4.2
Simplified4.2
rmApplied add-log-exp4.2
rmApplied associate-/l*4.7
if -4.9781449920664e-177 < y < 1.0919689144745608e-199Initial program 30.0
Simplified30.0
Taylor expanded around inf 13.1
Final simplification5.4
herbie shell --seed 2019120 +o rules:numerics
(FPCore (x y)
:name "Kahan p9 Example"
:pre (and (< 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))))