Average Error: 33.6 → 10.1
Time: 32.6s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.5081953238138552 \cdot 10^{+114}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.270925720464309 \cdot 10^{-123}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} + \left(-b\right)}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.5081953238138552e+114

    1. Initial program 48.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around -inf 3.2

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -1.5081953238138552e+114 < b < 1.270925720464309e-123

    1. Initial program 11.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity11.0

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    4. Applied *-un-lft-identity11.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    5. Applied distribute-lft-out11.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
    6. Applied associate-/l*11.1

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

    if 1.270925720464309e-123 < b

    1. Initial program 51.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 11.2

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    3. Simplified11.2

      \[\leadsto \color{blue}{-\frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.5081953238138552 \cdot 10^{+114}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.270925720464309 \cdot 10^{-123}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} + \left(-b\right)}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019050 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))