Average Error: 26.5 → 14.5
Time: 14.0s
Precision: 64
$\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}$
$\begin{array}{l} \mathbf{if}\;s1 \le -6.519245487843891964644199870468715690967 \cdot 10^{121}:\\ \;\;\;\;\frac{m1 - m2}{-s1}\\ \mathbf{elif}\;s1 \le 9.842246389838428287738545136755181573398 \cdot 10^{129}:\\ \;\;\;\;\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{m1 - m2}{s1}\\ \end{array}$
\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}
\begin{array}{l}
\mathbf{if}\;s1 \le -6.519245487843891964644199870468715690967 \cdot 10^{121}:\\
\;\;\;\;\frac{m1 - m2}{-s1}\\

\mathbf{elif}\;s1 \le 9.842246389838428287738545136755181573398 \cdot 10^{129}:\\
\;\;\;\;\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{m1 - m2}{s1}\\

\end{array}
double f(double m1, double m2, double s1, double s2) {
double r76321 = m1;
double r76322 = m2;
double r76323 = r76321 - r76322;
double r76324 = s1;
double r76325 = 2.0;
double r76326 = pow(r76324, r76325);
double r76327 = s2;
double r76328 = pow(r76327, r76325);
double r76329 = r76326 + r76328;
double r76330 = sqrt(r76329);
double r76331 = r76323 / r76330;
return r76331;
}


double f(double m1, double m2, double s1, double s2) {
double r76332 = s1;
double r76333 = -6.519245487843892e+121;
bool r76334 = r76332 <= r76333;
double r76335 = m1;
double r76336 = m2;
double r76337 = r76335 - r76336;
double r76338 = -r76332;
double r76339 = r76337 / r76338;
double r76340 = 9.842246389838428e+129;
bool r76341 = r76332 <= r76340;
double r76342 = 2.0;
double r76343 = pow(r76332, r76342);
double r76344 = s2;
double r76345 = pow(r76344, r76342);
double r76346 = r76343 + r76345;
double r76347 = sqrt(r76346);
double r76348 = r76337 / r76347;
double r76349 = r76337 / r76332;
double r76350 = r76341 ? r76348 : r76349;
double r76351 = r76334 ? r76339 : r76350;
return r76351;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if s1 < -6.519245487843892e+121

1. Initial program 45.8

$\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}$
2. Taylor expanded around -inf 8.0

$\leadsto \frac{m1 - m2}{\color{blue}{-1 \cdot s1}}$
3. Simplified8.0

$\leadsto \frac{m1 - m2}{\color{blue}{-s1}}$

## if -6.519245487843892e+121 < s1 < 9.842246389838428e+129

1. Initial program 17.5

$\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}$

## if 9.842246389838428e+129 < s1

1. Initial program 46.2

$\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}$
2. Taylor expanded around inf 7.7

$\leadsto \frac{m1 - m2}{\color{blue}{s1}}$
3. Recombined 3 regimes into one program.
4. Final simplification14.5

$\leadsto \begin{array}{l} \mathbf{if}\;s1 \le -6.519245487843891964644199870468715690967 \cdot 10^{121}:\\ \;\;\;\;\frac{m1 - m2}{-s1}\\ \mathbf{elif}\;s1 \le 9.842246389838428287738545136755181573398 \cdot 10^{129}:\\ \;\;\;\;\frac{m1 - m2}{\sqrt{{s1}^{2} + {s2}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{m1 - m2}{s1}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (m1 m2 s1 s2)
:name "(m1 - m2) / sqrt(pow(s1, 2) + pow(s2, 2))"
:precision binary64
(/ (- m1 m2) (sqrt (+ (pow s1 2) (pow s2 2)))))