\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.36496554640706019677869997344330658994 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 3.588070708117172201716955628167087287626 \cdot 10^{111}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r959410 = x;
double r959411 = r959410 * r959410;
double r959412 = y;
double r959413 = r959411 + r959412;
double r959414 = sqrt(r959413);
return r959414;
}
double f(double x, double y) {
double r959415 = x;
double r959416 = -1.3649655464070602e+154;
bool r959417 = r959415 <= r959416;
double r959418 = y;
double r959419 = r959418 / r959415;
double r959420 = -0.5;
double r959421 = r959419 * r959420;
double r959422 = r959421 - r959415;
double r959423 = 3.588070708117172e+111;
bool r959424 = r959415 <= r959423;
double r959425 = r959415 * r959415;
double r959426 = r959425 + r959418;
double r959427 = sqrt(r959426);
double r959428 = 0.5;
double r959429 = r959428 * r959419;
double r959430 = r959415 + r959429;
double r959431 = r959424 ? r959427 : r959430;
double r959432 = r959417 ? r959422 : r959431;
return r959432;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.4 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if x < -1.3649655464070602e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3649655464070602e+154 < x < 3.588070708117172e+111Initial program 0.0
if 3.588070708117172e+111 < x Initial program 51.0
Taylor expanded around inf 0.6
Final simplification0.1
herbie shell --seed 2019209
(FPCore (x y)
:name "Linear.Quaternion:$clog from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< x -1.5097698010472593e153) (- (+ (* 0.5 (/ y x)) x)) (if (< x 5.5823995511225407e57) (sqrt (+ (* x x) y)) (+ (* 0.5 (/ y x)) x)))
(sqrt (+ (* x x) y)))