\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.3300132858515627319920499059244220404 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 8.331092342254926651866005497662461340443 \cdot 10^{95}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r387337 = x;
double r387338 = r387337 * r387337;
double r387339 = y;
double r387340 = r387338 + r387339;
double r387341 = sqrt(r387340);
return r387341;
}
double f(double x, double y) {
double r387342 = x;
double r387343 = -1.3300132858515627e+154;
bool r387344 = r387342 <= r387343;
double r387345 = y;
double r387346 = r387345 / r387342;
double r387347 = -0.5;
double r387348 = r387346 * r387347;
double r387349 = r387348 - r387342;
double r387350 = 8.331092342254927e+95;
bool r387351 = r387342 <= r387350;
double r387352 = r387342 * r387342;
double r387353 = r387352 + r387345;
double r387354 = sqrt(r387353);
double r387355 = 0.5;
double r387356 = r387355 * r387346;
double r387357 = r387342 + r387356;
double r387358 = r387351 ? r387354 : r387357;
double r387359 = r387344 ? r387349 : r387358;
return r387359;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.7 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if x < -1.3300132858515627e+154Initial program 64.0
Taylor expanded around -inf 0.0
Simplified0.0
if -1.3300132858515627e+154 < x < 8.331092342254927e+95Initial program 0.0
if 8.331092342254927e+95 < x Initial program 46.8
Taylor expanded around inf 1.0
Final simplification0.2
herbie shell --seed 2019305
(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)))