Average Error: 33.5 → 13.8
Time: 2.8m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a} \le -3.893813382866839 \cdot 10^{+302}:\\ \;\;\;\;\frac{-4}{2} \cdot \frac{\frac{c}{2}}{b}\\ \mathbf{if}\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a} \le -2.279763752477715 \cdot 10^{-233}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a}\\ \mathbf{if}\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a} \le 9.990245652938313 \cdot 10^{-103}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot \left(-\frac{1}{2}\right)}{\sqrt{(\left(4 \cdot c\right) \cdot \left(-a\right) + \left(b \cdot b\right))_*} + b}\\ \mathbf{if}\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a} \le 7.314979115890435 \cdot 10^{+294}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4}{2} \cdot \frac{\frac{c}{2}}{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 (/ (- (sqrt (- (pow b 2) (* 4 (* c a)))) b) (* 2 a)) < -3.893813382866839e+302 or 7.314979115890435e+294 < (/ (- (sqrt (- (pow b 2) (* 4 (* c a)))) b) (* 2 a))

    1. Initial program 61.6

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

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

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

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

      \[\leadsto \frac{\frac{\left(c \cdot a\right) \cdot \left(-4\right)}{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(c \cdot a\right)}} + b}}{2 \cdot a}\]
    7. Applied simplify50.0

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

      \[\leadsto \frac{\left(4 \cdot c\right) \cdot \left(-\frac{1}{2}\right)}{\color{blue}{2 \cdot b}}\]
    9. Applied simplify32.0

      \[\leadsto \color{blue}{\frac{-4}{2} \cdot \frac{\frac{c}{2}}{b}}\]

    if -3.893813382866839e+302 < (/ (- (sqrt (- (pow b 2) (* 4 (* c a)))) b) (* 2 a)) < -2.279763752477715e-233 or 9.990245652938313e-103 < (/ (- (sqrt (- (pow b 2) (* 4 (* c a)))) b) (* 2 a)) < 7.314979115890435e+294

    1. Initial program 4.0

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

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

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

    if -2.279763752477715e-233 < (/ (- (sqrt (- (pow b 2) (* 4 (* c a)))) b) (* 2 a)) < 9.990245652938313e-103

    1. Initial program 41.9

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

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

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

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

      \[\leadsto \frac{\frac{\left(c \cdot a\right) \cdot \left(-4\right)}{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(c \cdot a\right)}} + b}}{2 \cdot a}\]
    7. Applied simplify2.7

      \[\leadsto \color{blue}{\frac{\left(4 \cdot c\right) \cdot \left(-\frac{1}{2}\right)}{\sqrt{(\left(4 \cdot c\right) \cdot \left(-a\right) + \left(b \cdot b\right))_*} + b}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 2.8m)Debug logProfile

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