\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.37787330356564457 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 1.29225661239445747 \cdot 10^{80}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r679222 = x;
double r679223 = r679222 * r679222;
double r679224 = y;
double r679225 = r679223 + r679224;
double r679226 = sqrt(r679225);
return r679226;
}
double f(double x, double y) {
double r679227 = x;
double r679228 = -1.3778733035656446e+154;
bool r679229 = r679227 <= r679228;
double r679230 = y;
double r679231 = r679230 / r679227;
double r679232 = -0.5;
double r679233 = r679231 * r679232;
double r679234 = r679233 - r679227;
double r679235 = 1.2922566123944575e+80;
bool r679236 = r679227 <= r679235;
double r679237 = r679227 * r679227;
double r679238 = r679237 + r679230;
double r679239 = sqrt(r679238);
double r679240 = 0.5;
double r679241 = r679240 * r679231;
double r679242 = r679227 + r679241;
double r679243 = r679236 ? r679239 : r679242;
double r679244 = r679229 ? r679234 : r679243;
return r679244;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.3 |
|---|---|
| Target | 0.6 |
| Herbie | 0.4 |
if x < -1.3778733035656446e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3778733035656446e+154 < x < 1.2922566123944575e+80Initial program 0.0
if 1.2922566123944575e+80 < x Initial program 44.1
Taylor expanded around inf 1.5
Final simplification0.4
herbie shell --seed 2020047
(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)))