Average Error: 46.8 → 5.6
Time: 16.5s
Precision: 64
$a \gt b \gt 0.0$
$a - \sqrt{a \cdot a - b \cdot b}$
$\begin{array}{l} \mathbf{if}\;a \le 1.771201644504744680797979365896316969329 \cdot 10^{129}:\\ \;\;\;\;\left|b\right| \cdot \frac{\left|b\right|}{a + \sqrt{a \cdot a - b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot b}{2 \cdot a}\\ \end{array}$
a - \sqrt{a \cdot a - b \cdot b}
\begin{array}{l}
\mathbf{if}\;a \le 1.771201644504744680797979365896316969329 \cdot 10^{129}:\\
\;\;\;\;\left|b\right| \cdot \frac{\left|b\right|}{a + \sqrt{a \cdot a - b \cdot b}}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot b}{2 \cdot a}\\

\end{array}
double f(double a, double b) {
double r889008 = a;
double r889009 = r889008 * r889008;
double r889010 = b;
double r889011 = r889010 * r889010;
double r889012 = r889009 - r889011;
double r889013 = sqrt(r889012);
double r889014 = r889008 - r889013;
return r889014;
}


double f(double a, double b) {
double r889015 = a;
double r889016 = 1.7712016445047447e+129;
bool r889017 = r889015 <= r889016;
double r889018 = b;
double r889019 = fabs(r889018);
double r889020 = r889015 * r889015;
double r889021 = r889018 * r889018;
double r889022 = r889020 - r889021;
double r889023 = sqrt(r889022);
double r889024 = r889015 + r889023;
double r889025 = r889019 / r889024;
double r889026 = r889019 * r889025;
double r889027 = 2.0;
double r889028 = r889027 * r889015;
double r889029 = r889021 / r889028;
double r889030 = r889017 ? r889026 : r889029;
return r889030;
}



Try it out

Results

 In Out
Enter valid numbers for all inputs

Derivation

1. Split input into 2 regimes
2. if a < 1.7712016445047447e+129

1. Initial program 33.3

$a - \sqrt{a \cdot a - b \cdot b}$
2. Using strategy rm
3. Applied flip--29.8

$\leadsto \color{blue}{\frac{a \cdot a - \sqrt{a \cdot a - b \cdot b} \cdot \sqrt{a \cdot a - b \cdot b}}{a + \sqrt{a \cdot a - b \cdot b}}}$
4. Simplified7.7

$\leadsto \frac{\color{blue}{0 + b \cdot b}}{a + \sqrt{a \cdot a - b \cdot b}}$
5. Using strategy rm
6. Applied *-un-lft-identity7.7

$\leadsto \frac{0 + b \cdot b}{\color{blue}{1 \cdot \left(a + \sqrt{a \cdot a - b \cdot b}\right)}}$

$\leadsto \frac{\color{blue}{\sqrt{0 + b \cdot b} \cdot \sqrt{0 + b \cdot b}}}{1 \cdot \left(a + \sqrt{a \cdot a - b \cdot b}\right)}$
8. Applied times-frac7.7

$\leadsto \color{blue}{\frac{\sqrt{0 + b \cdot b}}{1} \cdot \frac{\sqrt{0 + b \cdot b}}{a + \sqrt{a \cdot a - b \cdot b}}}$
9. Simplified7.7

$\leadsto \color{blue}{\left|b\right|} \cdot \frac{\sqrt{0 + b \cdot b}}{a + \sqrt{a \cdot a - b \cdot b}}$
10. Simplified3.4

$\leadsto \left|b\right| \cdot \color{blue}{\frac{\left|b\right|}{a + \sqrt{a \cdot a - b \cdot b}}}$

if 1.7712016445047447e+129 < a

1. Initial program 59.9

$a - \sqrt{a \cdot a - b \cdot b}$
2. Using strategy rm
3. Applied flip--59.9

$\leadsto \color{blue}{\frac{a \cdot a - \sqrt{a \cdot a - b \cdot b} \cdot \sqrt{a \cdot a - b \cdot b}}{a + \sqrt{a \cdot a - b \cdot b}}}$
4. Simplified26.8

$\leadsto \frac{\color{blue}{0 + b \cdot b}}{a + \sqrt{a \cdot a - b \cdot b}}$
5. Taylor expanded around inf 7.7

$\leadsto \frac{0 + b \cdot b}{\color{blue}{2 \cdot a}}$
3. Recombined 2 regimes into one program.
4. Final simplification5.6

$\leadsto \begin{array}{l} \mathbf{if}\;a \le 1.771201644504744680797979365896316969329 \cdot 10^{129}:\\ \;\;\;\;\left|b\right| \cdot \frac{\left|b\right|}{a + \sqrt{a \cdot a - b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot b}{2 \cdot a}\\ \end{array}$

Reproduce

herbie shell --seed 1
(FPCore (a b)
:name "a - sqrt(a * a - b * b)"
:precision binary64
:pre (> a b 0.0)
(- a (sqrt (- (* a a) (* b b)))))