\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.334986932601493855851749327767836382071 \cdot 10^{154}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{y}{x} - x\\
\mathbf{elif}\;x \le 1.438893453520727542249422121009742042751 \cdot 10^{123}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r345433 = x;
double r345434 = r345433 * r345433;
double r345435 = y;
double r345436 = r345434 + r345435;
double r345437 = sqrt(r345436);
return r345437;
}
double f(double x, double y) {
double r345438 = x;
double r345439 = -1.3349869326014939e+154;
bool r345440 = r345438 <= r345439;
double r345441 = -0.5;
double r345442 = y;
double r345443 = r345442 / r345438;
double r345444 = r345441 * r345443;
double r345445 = r345444 - r345438;
double r345446 = 1.4388934535207275e+123;
bool r345447 = r345438 <= r345446;
double r345448 = r345438 * r345438;
double r345449 = r345448 + r345442;
double r345450 = sqrt(r345449);
double r345451 = 0.5;
double r345452 = r345451 * r345443;
double r345453 = r345438 + r345452;
double r345454 = r345447 ? r345450 : r345453;
double r345455 = r345440 ? r345445 : r345454;
return r345455;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.1 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if x < -1.3349869326014939e+154Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied sqrt-prod64.0
Taylor expanded around -inf 0
Simplified0
if -1.3349869326014939e+154 < x < 1.4388934535207275e+123Initial program 0.0
if 1.4388934535207275e+123 < x Initial program 53.4
Taylor expanded around inf 0.2
Final simplification0.1
herbie shell --seed 2019326
(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)))