Average Error: 29.5 → 0.7
Time: 15.1s
Precision: 64
Internal Precision: 2368
$a - \sqrt{a \cdot a - b}$
$\begin{array}{l} \mathbf{if}\;a \le -1.3407175129675078 \cdot 10^{+154}:\\ \;\;\;\;a - \left(\frac{1}{2} \cdot \frac{b}{a} - a\right)\\ \mathbf{if}\;a \le 5.020139441458604 \cdot 10^{-101}:\\ \;\;\;\;a - \sqrt{a \cdot a - b}\\ \mathbf{if}\;a \le 1.3207397497089328 \cdot 10^{+81}:\\ \;\;\;\;\frac{b}{a + \sqrt{a \cdot a - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{b}{a}\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 4 regimes
2. ## if a < -1.3407175129675078e+154

1. Initial program 59.6

$a - \sqrt{a \cdot a - b}$
2. Taylor expanded around -inf 0.0

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

## if -1.3407175129675078e+154 < a < 5.020139441458604e-101

1. Initial program 0.6

$a - \sqrt{a \cdot a - b}$

## if 5.020139441458604e-101 < a < 1.3207397497089328e+81

1. Initial program 35.1

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

$\leadsto \color{blue}{\frac{a \cdot a - \sqrt{a \cdot a - b} \cdot \sqrt{a \cdot a - b}}{a + \sqrt{a \cdot a - b}}}$
4. Applied simplify0.2

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

## if 1.3207397497089328e+81 < a

1. Initial program 56.6

$a - \sqrt{a \cdot a - b}$
2. Taylor expanded around inf 1.6

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

# Runtime

Time bar (total: 15.1s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)'
(FPCore (a b)
:name "a-sqrt(a*a-b)"
(- a (sqrt (- (* a a) b))))