Average Error: 31.4 → 11.6
Time: 8.9s
Precision: 64
$\left|\sqrt{{x}^{2} + {y}^{2}}\right|$
$\begin{array}{l} \mathbf{if}\;{x}^{2} \le 8.398361527118406339261623076396411282699 \cdot 10^{-203}:\\ \;\;\;\;\left|y\right|\\ \mathbf{elif}\;{x}^{2} \le 7.920321990653224806961742848675063044363 \cdot 10^{253}:\\ \;\;\;\;\left|\sqrt{{x}^{2} + {y}^{2}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|-x\right|\\ \end{array}$
\left|\sqrt{{x}^{2} + {y}^{2}}\right|
\begin{array}{l}
\mathbf{if}\;{x}^{2} \le 8.398361527118406339261623076396411282699 \cdot 10^{-203}:\\
\;\;\;\;\left|y\right|\\

\mathbf{elif}\;{x}^{2} \le 7.920321990653224806961742848675063044363 \cdot 10^{253}:\\
\;\;\;\;\left|\sqrt{{x}^{2} + {y}^{2}}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|-x\right|\\

\end{array}
double f(double x, double y) {
double r1928741 = x;
double r1928742 = 2.0;
double r1928743 = pow(r1928741, r1928742);
double r1928744 = y;
double r1928745 = pow(r1928744, r1928742);
double r1928746 = r1928743 + r1928745;
double r1928747 = sqrt(r1928746);
double r1928748 = fabs(r1928747);
return r1928748;
}


double f(double x, double y) {
double r1928749 = x;
double r1928750 = 2.0;
double r1928751 = pow(r1928749, r1928750);
double r1928752 = 8.398361527118406e-203;
bool r1928753 = r1928751 <= r1928752;
double r1928754 = y;
double r1928755 = fabs(r1928754);
double r1928756 = 7.920321990653225e+253;
bool r1928757 = r1928751 <= r1928756;
double r1928758 = pow(r1928754, r1928750);
double r1928759 = r1928751 + r1928758;
double r1928760 = sqrt(r1928759);
double r1928761 = fabs(r1928760);
double r1928762 = -r1928749;
double r1928763 = fabs(r1928762);
double r1928764 = r1928757 ? r1928761 : r1928763;
double r1928765 = r1928753 ? r1928755 : r1928764;
return r1928765;
}



Try it out

Results

 In Out
Enter valid numbers for all inputs

Derivation

1. Split input into 3 regimes
2. if (pow x 2.0) < 8.398361527118406e-203

1. Initial program 26.9

$\left|\sqrt{{x}^{2} + {y}^{2}}\right|$
2. Taylor expanded around 0 10.1

$\leadsto \left|\color{blue}{y}\right|$

if 8.398361527118406e-203 < (pow x 2.0) < 7.920321990653225e+253

1. Initial program 15.6

$\left|\sqrt{{x}^{2} + {y}^{2}}\right|$

if 7.920321990653225e+253 < (pow x 2.0)

1. Initial program 56.4

$\left|\sqrt{{x}^{2} + {y}^{2}}\right|$
2. Taylor expanded around -inf 8.4

$\leadsto \left|\color{blue}{-1 \cdot x}\right|$
3. Simplified8.4

$\leadsto \left|\color{blue}{-x}\right|$
3. Recombined 3 regimes into one program.
4. Final simplification11.6

$\leadsto \begin{array}{l} \mathbf{if}\;{x}^{2} \le 8.398361527118406339261623076396411282699 \cdot 10^{-203}:\\ \;\;\;\;\left|y\right|\\ \mathbf{elif}\;{x}^{2} \le 7.920321990653224806961742848675063044363 \cdot 10^{253}:\\ \;\;\;\;\left|\sqrt{{x}^{2} + {y}^{2}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|-x\right|\\ \end{array}$

Reproduce

herbie shell --seed 1
(FPCore (x y)
:name "abs(sqrt(x^2 + y^2))"
:precision binary64
(fabs (sqrt (+ (pow x 2) (pow y 2)))))