\sqrt{x \cdot x + y}\begin{array}{l}
\mathbf{if}\;x \le -1.352540539223698945459720582374994240123 \cdot 10^{154}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{-1}{2} - x\\
\mathbf{elif}\;x \le 4.721377972444830028288106556093954402552 \cdot 10^{71}:\\
\;\;\;\;\sqrt{x \cdot x + y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\
\end{array}double f(double x, double y) {
double r357753 = x;
double r357754 = r357753 * r357753;
double r357755 = y;
double r357756 = r357754 + r357755;
double r357757 = sqrt(r357756);
return r357757;
}
double f(double x, double y) {
double r357758 = x;
double r357759 = -1.352540539223699e+154;
bool r357760 = r357758 <= r357759;
double r357761 = y;
double r357762 = r357761 / r357758;
double r357763 = -0.5;
double r357764 = r357762 * r357763;
double r357765 = r357764 - r357758;
double r357766 = 4.72137797244483e+71;
bool r357767 = r357758 <= r357766;
double r357768 = r357758 * r357758;
double r357769 = r357768 + r357761;
double r357770 = sqrt(r357769);
double r357771 = 0.5;
double r357772 = r357771 * r357762;
double r357773 = r357758 + r357772;
double r357774 = r357767 ? r357770 : r357773;
double r357775 = r357760 ? r357765 : r357774;
return r357775;
}




Bits error versus x




Bits error versus y
Results
| Original | 21.4 |
|---|---|
| Target | 0.5 |
| Herbie | 0.4 |
if x < -1.352540539223699e+154Initial program 64.0
Taylor expanded around -inf 0
Simplified0
if -1.352540539223699e+154 < x < 4.72137797244483e+71Initial program 0.0
if 4.72137797244483e+71 < x Initial program 42.1
Taylor expanded around inf 1.6
Final simplification0.4
herbie shell --seed 2019306
(FPCore (x y)
:name "Linear.Quaternion:$clog from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< x -1.5097698010472593e153) (- (+ (* 0.5 (/ y x)) x)) (if (< x 5.5823995511225407e57) (sqrt (+ (* x x) y)) (+ (* 0.5 (/ y x)) x)))
(sqrt (+ (* x x) y)))