Average Error: 30.2 → 3.8
Time: 13.1s
Precision: 64
$\left(-b\right) + \sqrt{b \cdot b - a}$
$\begin{array}{l} \mathbf{if}\;b \le -1.338328114114408775934292914336836675769 \cdot 10^{154}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{a}{b} - 2 \cdot b\\ \mathbf{elif}\;b \le 8.645349708093592150382656888660539656377 \cdot 10^{-100}:\\ \;\;\;\;\sqrt{b \cdot b - a} - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot a}{b}\\ \end{array}$
\left(-b\right) + \sqrt{b \cdot b - a}
\begin{array}{l}
\mathbf{if}\;b \le -1.338328114114408775934292914336836675769 \cdot 10^{154}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{a}{b} - 2 \cdot b\\

\mathbf{elif}\;b \le 8.645349708093592150382656888660539656377 \cdot 10^{-100}:\\
\;\;\;\;\sqrt{b \cdot b - a} - b\\

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

\end{array}
double f(double b, double a) {
double r30056057 = b;
double r30056058 = -r30056057;
double r30056059 = r30056057 * r30056057;
double r30056060 = a;
double r30056061 = r30056059 - r30056060;
double r30056062 = sqrt(r30056061);
double r30056063 = r30056058 + r30056062;
return r30056063;
}


double f(double b, double a) {
double r30056064 = b;
double r30056065 = -1.3383281141144088e+154;
bool r30056066 = r30056064 <= r30056065;
double r30056067 = 0.5;
double r30056068 = a;
double r30056069 = r30056068 / r30056064;
double r30056070 = r30056067 * r30056069;
double r30056071 = 2.0;
double r30056072 = r30056071 * r30056064;
double r30056073 = r30056070 - r30056072;
double r30056074 = 8.645349708093592e-100;
bool r30056075 = r30056064 <= r30056074;
double r30056076 = r30056064 * r30056064;
double r30056077 = r30056076 - r30056068;
double r30056078 = sqrt(r30056077);
double r30056079 = r30056078 - r30056064;
double r30056080 = -0.5;
double r30056081 = r30056080 * r30056068;
double r30056082 = r30056081 / r30056064;
double r30056083 = r30056075 ? r30056079 : r30056082;
double r30056084 = r30056066 ? r30056073 : r30056083;
return r30056084;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if b < -1.3383281141144088e+154

1. Initial program 64.0

$\left(-b\right) + \sqrt{b \cdot b - a}$
2. Simplified64.0

$\leadsto \color{blue}{\sqrt{b \cdot b - a} - b}$
3. Taylor expanded around -inf 0

$\leadsto \color{blue}{\frac{1}{2} \cdot \frac{a}{b} - 2 \cdot b}$

## if -1.3383281141144088e+154 < b < 8.645349708093592e-100

1. Initial program 0.6

$\left(-b\right) + \sqrt{b \cdot b - a}$
2. Simplified0.6

$\leadsto \color{blue}{\sqrt{b \cdot b - a} - b}$

## if 8.645349708093592e-100 < b

1. Initial program 49.4

$\left(-b\right) + \sqrt{b \cdot b - a}$
2. Simplified49.4

$\leadsto \color{blue}{\sqrt{b \cdot b - a} - b}$
3. Taylor expanded around inf 9.2

$\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{a}{b}}$
4. Using strategy rm
5. Applied associate-*r/9.2

$\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot a}{b}}$
3. Recombined 3 regimes into one program.
4. Final simplification3.8

$\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.338328114114408775934292914336836675769 \cdot 10^{154}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{a}{b} - 2 \cdot b\\ \mathbf{elif}\;b \le 8.645349708093592150382656888660539656377 \cdot 10^{-100}:\\ \;\;\;\;\sqrt{b \cdot b - a} - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot a}{b}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (b a)
:name "-b + sqrt(b*b - a)"
(+ (- b) (sqrt (- (* b b) a))))