Average Error: 33.7 → 13.5
Time: 2.6m
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{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{2} \cdot \frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{a} \le -5.467006012511375 \cdot 10^{+301}:\\ \;\;\;\;\frac{-4}{2} \cdot \frac{c}{b + b}\\ \mathbf{if}\;\frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{2} \cdot \frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{a} \le -2.345332273158681 \cdot 10^{-262}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \mathbf{if}\;\frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{2} \cdot \frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{a} \le 6.687484398042843 \cdot 10^{-277}:\\ \;\;\;\;\frac{-4}{2} \cdot \frac{c}{b + b}\\ \mathbf{if}\;\frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{2} \cdot \frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{a} \le 6.905200484599866 \cdot 10^{+297}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-4}{2} \cdot \frac{c}{b + 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 (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < -5.467006012511375e+301 or -2.345332273158681e-262 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < 6.687484398042843e-277 or 6.905200484599866e+297 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a))

    1. Initial program 58.8

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

      \[\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.4

      \[\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.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 *-un-lft-identity39.8

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

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

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

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

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

    if -5.467006012511375e+301 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < -2.345332273158681e-262 or 6.687484398042843e-277 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < 6.905200484599866e+297

    1. Initial program 2.2

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

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

Runtime

Time bar (total: 2.6m)Debug logProfile

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