Average Error: 33.2 → 12.7
Time: 3.3m
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{e^{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}{2 \cdot a} \le -1.4033975884233095 \cdot 10^{+308}:\\ \;\;\;\;\frac{c}{-b}\\ \mathbf{if}\;\frac{e^{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}{2 \cdot a} \le -2.6609468470109447 \cdot 10^{-284}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{if}\;\frac{e^{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}{2 \cdot a} \le 2.076349911779355 \cdot 10^{-307}:\\ \;\;\;\;\frac{c}{-b}\\ \mathbf{if}\;\frac{e^{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}{2 \cdot a} \le 4.84634994550331 \cdot 10^{+300}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (exp (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (* 2 a)) < -1.4033975884233095e+308 or -2.6609468470109447e-284 < (/ (exp (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (* 2 a)) < 2.076349911779355e-307 or 4.84634994550331e+300 < (/ (exp (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (* 2 a))

    1. Initial program 58.9

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

      \[\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 simplify39.2

      \[\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 clear-num39.3

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\frac{\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}}}}\]
    8. Taylor expanded around 0 22.0

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{b}{c}}}\]
    9. Applied simplify21.4

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

    if -1.4033975884233095e+308 < (/ (exp (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (* 2 a)) < -2.6609468470109447e-284 or 2.076349911779355e-307 < (/ (exp (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (* 2 a)) < 4.84634994550331e+300

    1. Initial program 2.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Applied simplify2.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 clear-num2.2

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

Runtime

Time bar (total: 3.3m)Debug logProfile

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