\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.3614720717698548 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 7.40557002165322956 \cdot 10^{112}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r628836 = x;
double r628837 = r628836 * r628836;
double r628838 = y;
double r628839 = r628837 + r628838;
double r628840 = sqrt(r628839);
return r628840;
}
double f(double x, double y) {
double r628841 = x;
double r628842 = -1.3614720717698548e+154;
bool r628843 = r628841 <= r628842;
double r628844 = y;
double r628845 = r628844 / r628841;
double r628846 = -0.5;
double r628847 = r628845 * r628846;
double r628848 = r628847 - r628841;
double r628849 = 7.4055700216532296e+112;
bool r628850 = r628841 <= r628849;
double r628851 = r628841 * r628841;
double r628852 = r628851 + r628844;
double r628853 = sqrt(r628852);
double r628854 = 0.5;
double r628855 = r628854 * r628845;
double r628856 = r628841 + r628855;
double r628857 = r628850 ? r628853 : r628856;
double r628858 = r628843 ? r628848 : r628857;
return r628858;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if x < -1.3614720717698548e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3614720717698548e+154 < x < 7.4055700216532296e+112Initial program 0.0
if 7.4055700216532296e+112 < x Initial program 50.1
Taylor expanded around inf 0.4
Final simplification0.1
herbie shell --seed 2020042
(FPCore (x y)
:name "Linear.Quaternion:$clog from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< x -1.5097698010472593e+153) (- (+ (* 0.5 (/ y x)) x)) (if (< x 5.582399551122541e+57) (sqrt (+ (* x x) y)) (+ (* 0.5 (/ y x)) x)))
(sqrt (+ (* x x) y)))