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

Error

Bits error versus b

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 59.6

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

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

    if -1.3407175129675078e+154 < b < 5.020139441458604e-101

    1. Initial program 0.6

      \[b - \sqrt{b \cdot b - a}\]

    if 5.020139441458604e-101 < b < 1.3207397497089328e+81

    1. Initial program 35.1

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

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

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

    if 1.3207397497089328e+81 < b

    1. Initial program 56.6

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

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

Runtime

Time bar (total: 15.5s)Debug log

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