\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{x \cdot x + y \cdot y}{y + x}}}\right)\\
\mathbf{elif}\;y \le 1.0919689144745608 \cdot 10^{-199}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{x - y}{\frac{x \cdot x + y \cdot y}{y + x}}}\right)\\
\end{array}double f(double x, double y) {
double r14399147 = x;
double r14399148 = y;
double r14399149 = r14399147 - r14399148;
double r14399150 = r14399147 + r14399148;
double r14399151 = r14399149 * r14399150;
double r14399152 = r14399147 * r14399147;
double r14399153 = r14399148 * r14399148;
double r14399154 = r14399152 + r14399153;
double r14399155 = r14399151 / r14399154;
return r14399155;
}
double f(double x, double y) {
double r14399156 = y;
double r14399157 = -1.1564294007415584e+23;
bool r14399158 = r14399156 <= r14399157;
double r14399159 = -1.0;
double r14399160 = -4.9781449920664e-177;
bool r14399161 = r14399156 <= r14399160;
double r14399162 = x;
double r14399163 = r14399162 - r14399156;
double r14399164 = r14399162 * r14399162;
double r14399165 = r14399156 * r14399156;
double r14399166 = r14399164 + r14399165;
double r14399167 = r14399156 + r14399162;
double r14399168 = r14399166 / r14399167;
double r14399169 = r14399163 / r14399168;
double r14399170 = exp(r14399169);
double r14399171 = log(r14399170);
double r14399172 = 1.0919689144745608e-199;
bool r14399173 = r14399156 <= r14399172;
double r14399174 = 1.0;
double r14399175 = r14399173 ? r14399174 : r14399171;
double r14399176 = r14399161 ? r14399171 : r14399175;
double r14399177 = r14399158 ? r14399159 : r14399176;
return r14399177;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.3 |
|---|---|
| Target | 0.1 |
| Herbie | 5.4 |
if y < -1.1564294007415584e+23Initial program 35.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
rmApplied add-log-exp4.2
rmApplied associate-/l*4.7
if -4.9781449920664e-177 < y < 1.0919689144745608e-199Initial program 30.0
rmApplied add-log-exp30.0
Taylor expanded around -inf 13.1
Final simplification5.4
herbie shell --seed 2019120
(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))))