\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.322195575929322175161499122447085220085 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 1.892549585482311918236295649622823641354 \cdot 10^{97}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r372278 = x;
double r372279 = r372278 * r372278;
double r372280 = y;
double r372281 = r372279 + r372280;
double r372282 = sqrt(r372281);
return r372282;
}
double f(double x, double y) {
double r372283 = x;
double r372284 = -1.3221955759293222e+154;
bool r372285 = r372283 <= r372284;
double r372286 = y;
double r372287 = r372286 / r372283;
double r372288 = -0.5;
double r372289 = r372287 * r372288;
double r372290 = r372289 - r372283;
double r372291 = 1.892549585482312e+97;
bool r372292 = r372283 <= r372291;
double r372293 = r372283 * r372283;
double r372294 = r372293 + r372286;
double r372295 = sqrt(r372294);
double r372296 = 0.5;
double r372297 = r372296 * r372287;
double r372298 = r372283 + r372297;
double r372299 = r372292 ? r372295 : r372298;
double r372300 = r372285 ? r372290 : r372299;
return r372300;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.0 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if x < -1.3221955759293222e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.3221955759293222e+154 < x < 1.892549585482312e+97Initial program 0.0
if 1.892549585482312e+97 < x Initial program 47.8
Taylor expanded around inf 0.8
Final simplification0.2
herbie shell --seed 2019323
(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)))