\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.34741200166273024865549457096980522016 \cdot 10^{154}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{y}{x}, \frac{1}{2}, x\right)\\
\mathbf{elif}\;x \le 3.903488335015737711762269431799121933757 \cdot 10^{107}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(x, x, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x}, \frac{1}{2}, x\right)\\
\end{array}double f(double x, double y) {
double r543601 = x;
double r543602 = r543601 * r543601;
double r543603 = y;
double r543604 = r543602 + r543603;
double r543605 = sqrt(r543604);
return r543605;
}
double f(double x, double y) {
double r543606 = x;
double r543607 = -1.3474120016627302e+154;
bool r543608 = r543606 <= r543607;
double r543609 = y;
double r543610 = r543609 / r543606;
double r543611 = 0.5;
double r543612 = fma(r543610, r543611, r543606);
double r543613 = -r543612;
double r543614 = 3.903488335015738e+107;
bool r543615 = r543606 <= r543614;
double r543616 = fma(r543606, r543606, r543609);
double r543617 = sqrt(r543616);
double r543618 = r543615 ? r543617 : r543612;
double r543619 = r543608 ? r543613 : r543618;
return r543619;
}




Bits error versus x




Bits error versus y
| Original | 21.6 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
if x < -1.3474120016627302e+154Initial program 64.0
Simplified64.0
Taylor expanded around -inf 0.0
Simplified0.0
if -1.3474120016627302e+154 < x < 3.903488335015738e+107Initial program 0.0
Simplified0.0
if 3.903488335015738e+107 < x Initial program 50.4
Simplified50.4
Taylor expanded around inf 0.5
Simplified0.5
Final simplification0.1
herbie shell --seed 2019350 +o rules:numerics
(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)))