Average Error: 33.9 → 29.9
Time: 2.7m
Precision: 64
\[\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 9.493040921139284 \cdot 10^{+98}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*} - b}{2}}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \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 < 9.493040921139284e+98

    1. Initial program 25.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified25.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-identity25.9

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

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(\sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*} - b\right)}}{1 \cdot 2}}{a}\]
    6. Applied times-frac25.9

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

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

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

    if 9.493040921139284e+98 < b

    1. Initial program 58.3

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

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

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification29.9

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

Reproduce

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