\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.28151121097985566 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 3.3825854527583296 \cdot 10^{81}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r585383 = x;
double r585384 = r585383 * r585383;
double r585385 = y;
double r585386 = r585384 + r585385;
double r585387 = sqrt(r585386);
return r585387;
}
double f(double x, double y) {
double r585388 = x;
double r585389 = -1.2815112109798557e+154;
bool r585390 = r585388 <= r585389;
double r585391 = y;
double r585392 = r585391 / r585388;
double r585393 = -0.5;
double r585394 = r585392 * r585393;
double r585395 = r585394 - r585388;
double r585396 = 3.3825854527583296e+81;
bool r585397 = r585388 <= r585396;
double r585398 = r585388 * r585388;
double r585399 = r585398 + r585391;
double r585400 = sqrt(r585399);
double r585401 = 0.5;
double r585402 = r585401 * r585392;
double r585403 = r585388 + r585402;
double r585404 = r585397 ? r585400 : r585403;
double r585405 = r585390 ? r585395 : r585404;
return r585405;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.4 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if x < -1.2815112109798557e+154Initial program 63.9
Taylor expanded around -inf 0.0
Simplified0.0
if -1.2815112109798557e+154 < x < 3.3825854527583296e+81Initial program 0.0
if 3.3825854527583296e+81 < x Initial program 44.2
Taylor expanded around inf 1.1
Final simplification0.3
herbie shell --seed 2020046
(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)))