Average Error: 31.4 → 17.2
Time: 10.8s
Precision: 64
$\sqrt{{x}^{2} + {y}^{2}}$
$\begin{array}{l} \mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \le 1.943934747643531875760607600817076209382 \cdot 10^{128}:\\ \;\;\;\;\sqrt{{x}^{2} + {y}^{2}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}$
\sqrt{{x}^{2} + {y}^{2}}
\begin{array}{l}
\mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\
\;\;\;\;-x\\

\mathbf{elif}\;x \le 1.943934747643531875760607600817076209382 \cdot 10^{128}:\\
\;\;\;\;\sqrt{{x}^{2} + {y}^{2}}\\

\mathbf{else}:\\
\;\;\;\;x\\

\end{array}
double f(double x, double y) {
double r24856644 = x;
double r24856645 = 2.0;
double r24856646 = pow(r24856644, r24856645);
double r24856647 = y;
double r24856648 = pow(r24856647, r24856645);
double r24856649 = r24856646 + r24856648;
double r24856650 = sqrt(r24856649);
return r24856650;
}


double f(double x, double y) {
double r24856651 = x;
double r24856652 = -3.3032099476572043e+84;
bool r24856653 = r24856651 <= r24856652;
double r24856654 = -r24856651;
double r24856655 = 1.943934747643532e+128;
bool r24856656 = r24856651 <= r24856655;
double r24856657 = 2.0;
double r24856658 = pow(r24856651, r24856657);
double r24856659 = y;
double r24856660 = pow(r24856659, r24856657);
double r24856661 = r24856658 + r24856660;
double r24856662 = sqrt(r24856661);
double r24856663 = r24856656 ? r24856662 : r24856651;
double r24856664 = r24856653 ? r24856654 : r24856663;
return r24856664;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if x < -3.3032099476572043e+84

1. Initial program 48.4

$\sqrt{{x}^{2} + {y}^{2}}$
2. Taylor expanded around -inf 10.3

$\leadsto \color{blue}{-1 \cdot x}$
3. Simplified10.3

$\leadsto \color{blue}{-x}$

## if -3.3032099476572043e+84 < x < 1.943934747643532e+128

1. Initial program 21.1

$\sqrt{{x}^{2} + {y}^{2}}$

## if 1.943934747643532e+128 < x

1. Initial program 57.0

$\sqrt{{x}^{2} + {y}^{2}}$
2. Taylor expanded around inf 8.2

$\leadsto \color{blue}{x}$
3. Recombined 3 regimes into one program.
4. Final simplification17.2

$\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \le 1.943934747643531875760607600817076209382 \cdot 10^{128}:\\ \;\;\;\;\sqrt{{x}^{2} + {y}^{2}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x y)
:name "sqrt(pow(x,2)+pow(y,2))"
(sqrt (+ (pow x 2.0) (pow y 2.0))))