\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.34406943704910861 \cdot 10^{154}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{y}{x}, \frac{1}{2}, x\right)\\
\mathbf{elif}\;x \le 2.0914354496123656 \cdot 10^{108}:\\
\;\;\;\;\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 r362514 = x;
double r362515 = r362514 * r362514;
double r362516 = y;
double r362517 = r362515 + r362516;
double r362518 = sqrt(r362517);
return r362518;
}
double f(double x, double y) {
double r362519 = x;
double r362520 = -1.3440694370491086e+154;
bool r362521 = r362519 <= r362520;
double r362522 = y;
double r362523 = r362522 / r362519;
double r362524 = 0.5;
double r362525 = fma(r362523, r362524, r362519);
double r362526 = -r362525;
double r362527 = 2.0914354496123656e+108;
bool r362528 = r362519 <= r362527;
double r362529 = fma(r362519, r362519, r362522);
double r362530 = sqrt(r362529);
double r362531 = r362528 ? r362530 : r362525;
double r362532 = r362521 ? r362526 : r362531;
return r362532;
}




Bits error versus x




Bits error versus y
| Original | 21.6 |
|---|---|
| Target | 0.6 |
| Herbie | 0.1 |
if x < -1.3440694370491086e+154Initial program 64.0
Simplified64.0
Taylor expanded around -inf 0
Simplified0
if -1.3440694370491086e+154 < x < 2.0914354496123656e+108Initial program 0.0
Simplified0.0
if 2.0914354496123656e+108 < x Initial program 48.6
Simplified48.6
Taylor expanded around inf 0.5
Simplified0.5
Final simplification0.1
herbie shell --seed 2019199 +o rules:numerics
(FPCore (x y)
:name "Linear.Quaternion:$clog from linear-1.19.1.3"
: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)))