\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 r310667 = x;
double r310668 = r310667 * r310667;
double r310669 = y;
double r310670 = r310668 + r310669;
double r310671 = sqrt(r310670);
return r310671;
}
double f(double x, double y) {
double r310672 = x;
double r310673 = -1.3221955759293222e+154;
bool r310674 = r310672 <= r310673;
double r310675 = y;
double r310676 = r310675 / r310672;
double r310677 = -0.5;
double r310678 = r310676 * r310677;
double r310679 = r310678 - r310672;
double r310680 = 1.892549585482312e+97;
bool r310681 = r310672 <= r310680;
double r310682 = r310672 * r310672;
double r310683 = r310682 + r310675;
double r310684 = sqrt(r310683);
double r310685 = 0.5;
double r310686 = r310685 * r310676;
double r310687 = r310672 + r310686;
double r310688 = r310681 ? r310684 : r310687;
double r310689 = r310674 ? r310679 : r310688;
return r310689;
}




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)))