Average Error: 33.6 → 16.4
Time: 21.4s
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 4.254370217686771 \cdot 10^{-114}:\\ \;\;\;\;\frac{\frac{\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}{2}}{a} - \frac{\frac{b}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{-b}{c}}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 4.254370217686771e-114

    1. Initial program 20.2

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied div-sub20.2

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}{2} - \frac{b}{2}}}{a}\]
    5. Applied div-sub20.2

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

    if 4.254370217686771e-114 < b

    1. Initial program 51.9

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity51.9

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\frac{\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*} - b}{2}}}}\]
    6. Taylor expanded around 0 11.4

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

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

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

Reproduce

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