double f(double x, double y) {
double r31478121 = x;
double r31478122 = y;
double r31478123 = r31478121 - r31478122;
double r31478124 = r31478121 + r31478122;
double r31478125 = r31478123 * r31478124;
double r31478126 = r31478121 * r31478121;
double r31478127 = r31478122 * r31478122;
double r31478128 = r31478126 + r31478127;
double r31478129 = r31478125 / r31478128;
return r31478129;
}
double f(double x, double y) {
double r31478130 = y;
double r31478131 = -1.366618915167733e+154;
bool r31478132 = r31478130 <= r31478131;
double r31478133 = -1.0;
double r31478134 = -2.70713010924186e-162;
bool r31478135 = r31478130 <= r31478134;
double r31478136 = x;
double r31478137 = r31478136 - r31478130;
double r31478138 = r31478130 + r31478136;
double r31478139 = r31478137 * r31478138;
double r31478140 = r31478130 * r31478130;
double r31478141 = r31478136 * r31478136;
double r31478142 = r31478140 + r31478141;
double r31478143 = r31478139 / r31478142;
double r31478144 = 3.060862139420529e-162;
bool r31478145 = r31478130 <= r31478144;
double r31478146 = 1.0;
double r31478147 = r31478145 ? r31478146 : r31478143;
double r31478148 = r31478135 ? r31478143 : r31478147;
double r31478149 = r31478132 ? r31478133 : r31478148;
return r31478149;
}
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.366618915167733 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -2.70713010924186 \cdot 10^{-162}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(y + x\right)}{y \cdot y + x \cdot x}\\
\mathbf{elif}\;y \le 3.060862139420529 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(y + x\right)}{y \cdot y + x \cdot x}\\
\end{array}



Bits error versus x




Bits error versus y
| Original | 19.4 |
|---|---|
| Target | 0.1 |
| Herbie | 4.9 |
if y < -1.366618915167733e+154Initial program 63.6
Taylor expanded around 0 0
if -1.366618915167733e+154 < y < -2.70713010924186e-162 or 3.060862139420529e-162 < y Initial program 0.1
if -2.70713010924186e-162 < y < 3.060862139420529e-162Initial program 29.0
rmApplied *-un-lft-identity29.0
Applied times-frac29.6
Simplified29.6
Taylor expanded around -inf 15.2
Final simplification4.9
herbie shell --seed 2019102
(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))))