\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.330529990176199361196485578032770005542 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 1.239102867687965121108359501827503075543 \cdot 10^{132}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r347051 = x;
double r347052 = r347051 * r347051;
double r347053 = y;
double r347054 = r347052 + r347053;
double r347055 = sqrt(r347054);
return r347055;
}
double f(double x, double y) {
double r347056 = x;
double r347057 = -1.3305299901761994e+154;
bool r347058 = r347056 <= r347057;
double r347059 = y;
double r347060 = r347059 / r347056;
double r347061 = -0.5;
double r347062 = r347060 * r347061;
double r347063 = r347062 - r347056;
double r347064 = 1.2391028676879651e+132;
bool r347065 = r347056 <= r347064;
double r347066 = r347056 * r347056;
double r347067 = r347066 + r347059;
double r347068 = sqrt(r347067);
double r347069 = 0.5;
double r347070 = r347069 * r347060;
double r347071 = r347056 + r347070;
double r347072 = r347065 ? r347068 : r347071;
double r347073 = r347058 ? r347063 : r347072;
return r347073;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.7 |
|---|---|
| Target | 0.5 |
| Herbie | 0.0 |
if x < -1.3305299901761994e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3305299901761994e+154 < x < 1.2391028676879651e+132Initial program 0.0
if 1.2391028676879651e+132 < x Initial program 56.0
Taylor expanded around inf 0.2
Final simplification0.0
herbie shell --seed 2019322
(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)))