Average Error: 33.7 → 13.6
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.1000773871267674 \cdot 10^{+287}:\\ \;\;\;\;\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.4080356090966185 \cdot 10^{-240}:\\ \;\;\;\;\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 7.731607261485143 \cdot 10^{-308}:\\ \;\;\;\;\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 4.022127775041325 \cdot 10^{+307}:\\ \;\;\;\;\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.1000773871267674e+287 or -2.4080356090966185e-240 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < 7.731607261485143e-308 or 4.022127775041325e+307 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a))

    1. Initial program 58.4

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

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

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

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

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

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

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

    if -5.1000773871267674e+287 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < -2.4080356090966185e-240 or 7.731607261485143e-308 < (* (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) 2) (/ (sqrt (- (sqrt (fma (* 4 a) (- c) (* b b))) b)) a)) < 4.022127775041325e+307

    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)))