Average Error: 25.1 → 11.9
Time: 6.3s
Precision: 64
$\sqrt{1 + \frac{x \cdot x}{y \cdot y}}$
$\begin{array}{l} \mathbf{if}\;y \le -9.74195614250472421881859824458307299021 \cdot 10^{-172} \lor \neg \left(y \le -1.204183290177364032831258704580874017106 \cdot 10^{-201}\right):\\ \;\;\;\;\sqrt{1 + \left|\frac{x}{y}\right| \cdot \left|\frac{x}{y}\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array}$
\sqrt{1 + \frac{x \cdot x}{y \cdot y}}
\begin{array}{l}
\mathbf{if}\;y \le -9.74195614250472421881859824458307299021 \cdot 10^{-172} \lor \neg \left(y \le -1.204183290177364032831258704580874017106 \cdot 10^{-201}\right):\\
\;\;\;\;\sqrt{1 + \left|\frac{x}{y}\right| \cdot \left|\frac{x}{y}\right|}\\

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

\end{array}
double f(double x, double y) {
double r2249843 = 1.0;
double r2249844 = x;
double r2249845 = r2249844 * r2249844;
double r2249846 = y;
double r2249847 = r2249846 * r2249846;
double r2249848 = r2249845 / r2249847;
double r2249849 = r2249843 + r2249848;
double r2249850 = sqrt(r2249849);
return r2249850;
}


double f(double x, double y) {
double r2249851 = y;
double r2249852 = -9.741956142504724e-172;
bool r2249853 = r2249851 <= r2249852;
double r2249854 = -1.204183290177364e-201;
bool r2249855 = r2249851 <= r2249854;
double r2249856 = !r2249855;
bool r2249857 = r2249853 || r2249856;
double r2249858 = 1.0;
double r2249859 = x;
double r2249860 = r2249859 / r2249851;
double r2249861 = fabs(r2249860);
double r2249862 = r2249861 * r2249861;
double r2249863 = r2249858 + r2249862;
double r2249864 = sqrt(r2249863);
double r2249865 = r2249857 ? r2249864 : r2249860;
return r2249865;
}



Try it out

Results

 In Out
Enter valid numbers for all inputs

Derivation

1. Split input into 2 regimes
2. if y < -9.741956142504724e-172 or -1.204183290177364e-201 < y

1. Initial program 24.3

$\sqrt{1 + \frac{x \cdot x}{y \cdot y}}$
2. Using strategy rm

$\leadsto \sqrt{1 + \color{blue}{\sqrt{\frac{x \cdot x}{y \cdot y}} \cdot \sqrt{\frac{x \cdot x}{y \cdot y}}}}$
4. Simplified24.3

$\leadsto \sqrt{1 + \color{blue}{\left|\frac{x}{y}\right|} \cdot \sqrt{\frac{x \cdot x}{y \cdot y}}}$
5. Simplified11.3

$\leadsto \sqrt{1 + \left|\frac{x}{y}\right| \cdot \color{blue}{\left|\frac{x}{y}\right|}}$

if -9.741956142504724e-172 < y < -1.204183290177364e-201

1. Initial program 64.0

$\sqrt{1 + \frac{x \cdot x}{y \cdot y}}$
2. Taylor expanded around inf 43.7

$\leadsto \color{blue}{\frac{x}{y}}$
3. Recombined 2 regimes into one program.
4. Final simplification11.9

$\leadsto \begin{array}{l} \mathbf{if}\;y \le -9.74195614250472421881859824458307299021 \cdot 10^{-172} \lor \neg \left(y \le -1.204183290177364032831258704580874017106 \cdot 10^{-201}\right):\\ \;\;\;\;\sqrt{1 + \left|\frac{x}{y}\right| \cdot \left|\frac{x}{y}\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array}$

Reproduce

herbie shell --seed 1
(FPCore (x y)
:name "sqrt(1 + (x * x) / (y * y))"
:precision binary64
(sqrt (+ 1 (/ (* x x) (* y y)))))