Average Error: 33.5 → 13.1
Time: 2.2m
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}\;b \le -5.569179977095421 \cdot 10^{-254}:\\ \;\;\;\;\frac{(\left(\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}\right) \cdot \left(\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}\right) + \left(-b\right))_*}{2 \cdot a}\\ \mathbf{if}\;b \le 4.616584181492383 \cdot 10^{+126}:\\ \;\;\;\;-\frac{\left(4 \cdot c\right) \cdot \frac{1}{2}}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4}{\left(2 \cdot 2\right) \cdot \frac{b}{c}}\\ \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 < -5.569179977095421e-254

    1. Initial program 22.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Applied simplify22.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. Using strategy rm
    4. Applied add-sqr-sqrt22.0

      \[\leadsto \frac{\sqrt{\color{blue}{\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}{2 \cdot a}\]
    5. Applied sqrt-prod22.2

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

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

    if -5.569179977095421e-254 < b < 4.616584181492383e+126

    1. Initial program 32.4

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

      \[\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--32.5

      \[\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 simplify15.8

      \[\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. Using strategy rm
    7. Applied distribute-rgt-neg-out15.8

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

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

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

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

    if 4.616584181492383e+126 < b

    1. Initial program 60.1

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

      \[\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--60.1

      \[\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 simplify34.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. Using strategy rm
    7. Applied distribute-rgt-neg-out34.5

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

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

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

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

      \[\leadsto -\frac{\left(4 \cdot c\right) \cdot \frac{1}{2}}{\color{blue}{2 \cdot b}}\]
    12. Applied simplify2.8

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

Runtime

Time bar (total: 2.2m)Debug logProfile

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