\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.334986932601493855851749327767836382071 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 1.438893453520727542249422121009742042751 \cdot 10^{123}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r324000 = x;
double r324001 = r324000 * r324000;
double r324002 = y;
double r324003 = r324001 + r324002;
double r324004 = sqrt(r324003);
return r324004;
}
double f(double x, double y) {
double r324005 = x;
double r324006 = -1.3349869326014939e+154;
bool r324007 = r324005 <= r324006;
double r324008 = y;
double r324009 = r324008 / r324005;
double r324010 = -0.5;
double r324011 = r324009 * r324010;
double r324012 = r324011 - r324005;
double r324013 = 1.4388934535207275e+123;
bool r324014 = r324005 <= r324013;
double r324015 = r324005 * r324005;
double r324016 = r324015 + r324008;
double r324017 = sqrt(r324016);
double r324018 = 0.5;
double r324019 = r324018 * r324009;
double r324020 = r324005 + r324019;
double r324021 = r324014 ? r324017 : r324020;
double r324022 = r324007 ? r324012 : r324021;
return r324022;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.1 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if x < -1.3349869326014939e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3349869326014939e+154 < x < 1.4388934535207275e+123Initial program 0.0
if 1.4388934535207275e+123 < x Initial program 53.4
Taylor expanded around inf 0.2
Final simplification0.1
herbie shell --seed 2019326
(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)))