Average Error: 33.8 → 6.8
Time: 3.2m
Precision: 64
Internal Precision: 3136
\[\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.480021572372691 \cdot 10^{+121}:\\ \;\;\;\;\frac{(\left(-c\right) \cdot \left(\frac{a}{b}\right) + \left(-b\right))_*}{a}\\ \mathbf{if}\;b \le 3.3274636606180965 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{if}\;b \le 3.4914761643971034 \cdot 10^{+87}:\\ \;\;\;\;\frac{c \cdot 4}{\left(-b\right) - \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}} \cdot \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{4 \cdot \frac{c}{2}}{\left(\left(-b\right) + \left(-b\right)\right) - \frac{a}{b} \cdot \left(2 \cdot c\right)}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -4.480021572372691e+121

    1. Initial program 50.5

      \[\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{\color{blue}{-\left(2 \cdot \frac{a \cdot c}{b} + 2 \cdot b\right)}}{2 \cdot a}\]
    3. Applied simplify3.0

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

    if -4.480021572372691e+121 < b < 3.3274636606180965e-305

    1. Initial program 8.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied clear-num9.1

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

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

    if 3.3274636606180965e-305 < b < 3.4914761643971034e+87

    1. Initial program 32.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+32.3

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

      \[\leadsto \frac{\frac{\color{blue}{\left(4 \cdot c\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity17.1

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{\frac{\left(4 \cdot c\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}}\]
    8. Applied simplify9.5

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

    if 3.4914761643971034e+87 < b

    1. Initial program 57.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+57.8

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

      \[\leadsto \frac{\frac{\color{blue}{\left(4 \cdot c\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Taylor expanded around inf 14.3

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -4.480021572372691 \cdot 10^{+121}:\\ \;\;\;\;\frac{(\left(-c\right) \cdot \left(\frac{a}{b}\right) + \left(-b\right))_*}{a}\\ \mathbf{if}\;b \le 3.3274636606180965 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{if}\;b \le 3.4914761643971034 \cdot 10^{+87}:\\ \;\;\;\;\frac{c \cdot 4}{\left(-b\right) - \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}} \cdot \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{4 \cdot \frac{c}{2}}{\left(\left(-b\right) + \left(-b\right)\right) - \frac{a}{b} \cdot \left(2 \cdot c\right)}\\ \end{array}}\]

Runtime

Time bar (total: 3.2m)Debug logProfile

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