Average Error: 34.1 → 10.0
Time: 6.1s
Precision: binary64
\[\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.38476143180922117 \cdot 10^{134}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right)}{2 \cdot a}\\ \mathbf{elif}\;b \le 5.1943629106266941 \cdot 10^{-122}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \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.38476143180922117e134

    1. Initial program 56.8

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

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

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

    if -1.38476143180922117e134 < b < 5.1943629106266941e-122

    1. Initial program 11.3

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

    if 5.1943629106266941e-122 < b

    1. Initial program 51.6

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

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

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

Reproduce

herbie shell --seed 2020179 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (neg b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))