Average Error: 33.5 → 7.1
Time: 2.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{2}{b} \le -1.4176992465540237 \cdot 10^{-98}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} - b}{a \cdot 2}\\ \mathbf{if}\;\frac{2}{b} \le 4.859094672771441 \cdot 10^{-308}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a \cdot 2}\\ \mathbf{if}\;\frac{2}{b} \le 2.645777374402077 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{-4}{2} \cdot \frac{c}{2}}{b - \frac{c}{\frac{b}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + b} \cdot \frac{-4}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if (/ 2 b) < -1.4176992465540237e-98

    1. Initial program 8.2

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

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

    if -1.4176992465540237e-98 < (/ 2 b) < 4.859094672771441e-308

    1. Initial program 45.0

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

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

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

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

    if 4.859094672771441e-308 < (/ 2 b) < 2.645777374402077e-23

    1. Initial program 55.8

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-\frac{4}{2}\right) \cdot \frac{c}{\color{blue}{2 \cdot b - 2 \cdot \frac{c \cdot a}{b}}}\]
    13. Applied simplify4.7

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

    if 2.645777374402077e-23 < (/ 2 b)

    1. Initial program 27.5

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{2}{b} \le -1.4176992465540237 \cdot 10^{-98}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} - b}{a \cdot 2}\\ \mathbf{if}\;\frac{2}{b} \le 4.859094672771441 \cdot 10^{-308}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a \cdot 2}\\ \mathbf{if}\;\frac{2}{b} \le 2.645777374402077 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{-4}{2} \cdot \frac{c}{2}}{b - \frac{c}{\frac{b}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + b} \cdot \frac{-4}{2}\\ \end{array}}\]

Runtime

Time bar (total: 2.3m)Debug logProfile

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