\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.3434000592863123 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -8.556032821094931 \cdot 10^{-156}:\\
\;\;\;\;\log \left(e^{\frac{\left(x - y\right) \cdot \left(y + x\right)}{\mathsf{fma}\left(x, x, \left(y \cdot y\right)\right)}}\right)\\
\mathbf{elif}\;y \le 2.1804237440776019 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{\left(x - y\right) \cdot \left(y + x\right)}{\mathsf{fma}\left(x, x, \left(y \cdot y\right)\right)}}\right)\\
\end{array}double f(double x, double y) {
double r2065801 = x;
double r2065802 = y;
double r2065803 = r2065801 - r2065802;
double r2065804 = r2065801 + r2065802;
double r2065805 = r2065803 * r2065804;
double r2065806 = r2065801 * r2065801;
double r2065807 = r2065802 * r2065802;
double r2065808 = r2065806 + r2065807;
double r2065809 = r2065805 / r2065808;
return r2065809;
}
double f(double x, double y) {
double r2065810 = y;
double r2065811 = -1.3434000592863123e+154;
bool r2065812 = r2065810 <= r2065811;
double r2065813 = -1.0;
double r2065814 = -8.556032821094931e-156;
bool r2065815 = r2065810 <= r2065814;
double r2065816 = x;
double r2065817 = r2065816 - r2065810;
double r2065818 = r2065810 + r2065816;
double r2065819 = r2065817 * r2065818;
double r2065820 = r2065810 * r2065810;
double r2065821 = fma(r2065816, r2065816, r2065820);
double r2065822 = r2065819 / r2065821;
double r2065823 = exp(r2065822);
double r2065824 = log(r2065823);
double r2065825 = 2.1804237440776019e-162;
bool r2065826 = r2065810 <= r2065825;
double r2065827 = 1.0;
double r2065828 = r2065826 ? r2065827 : r2065824;
double r2065829 = r2065815 ? r2065824 : r2065828;
double r2065830 = r2065812 ? r2065813 : r2065829;
return r2065830;
}




Bits error versus x




Bits error versus y
| Original | 20.2 |
|---|---|
| Target | 0.0 |
| Herbie | 5.1 |
if y < -1.3434000592863123e+154Initial program 63.6
Simplified63.6
Taylor expanded around 0 63.6
Simplified63.6
rmApplied add-log-exp63.6
Taylor expanded around 0 0
if -1.3434000592863123e+154 < y < -8.556032821094931e-156 or 2.1804237440776019e-162 < y Initial program 0.0
Simplified0.0
Taylor expanded around 0 0.0
Simplified0.0
rmApplied add-log-exp0.0
if -8.556032821094931e-156 < y < 2.1804237440776019e-162Initial program 29.2
Simplified29.2
Taylor expanded around 0 29.2
Simplified29.2
rmApplied add-log-exp29.2
Taylor expanded around inf 15.7
Final simplification5.1
herbie shell --seed 2019133 +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))))