\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.37787330356564457 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 1.29225661239445747 \cdot 10^{80}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r537914 = x;
double r537915 = r537914 * r537914;
double r537916 = y;
double r537917 = r537915 + r537916;
double r537918 = sqrt(r537917);
return r537918;
}
double f(double x, double y) {
double r537919 = x;
double r537920 = -1.3778733035656446e+154;
bool r537921 = r537919 <= r537920;
double r537922 = y;
double r537923 = r537922 / r537919;
double r537924 = -0.5;
double r537925 = r537923 * r537924;
double r537926 = r537925 - r537919;
double r537927 = 1.2922566123944575e+80;
bool r537928 = r537919 <= r537927;
double r537929 = r537919 * r537919;
double r537930 = r537929 + r537922;
double r537931 = sqrt(r537930);
double r537932 = 0.5;
double r537933 = r537932 * r537923;
double r537934 = r537919 + r537933;
double r537935 = r537928 ? r537931 : r537934;
double r537936 = r537921 ? r537926 : r537935;
return r537936;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.3 |
|---|---|
| Target | 0.6 |
| Herbie | 0.4 |
if x < -1.3778733035656446e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3778733035656446e+154 < x < 1.2922566123944575e+80Initial program 0.0
if 1.2922566123944575e+80 < x Initial program 44.1
Taylor expanded around inf 1.5
Final simplification0.4
herbie shell --seed 2020047
(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)))