Average Error: 33.0 → 8.5
Time: 3.7m
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}\;b \le -7.739999686026577 \cdot 10^{+110}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;b \le 5.615557440665007 \cdot 10^{-158}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}}\\ \mathbf{if}\;b \le 1.643123946810858 \cdot 10^{+22}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(c \cdot a\right)}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot \frac{c}{2}}{a \cdot \frac{c}{b} - b}\\ \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 b < -7.739999686026577e+110

    1. Initial program 46.6

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

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    3. Applied simplify3.1

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

    if -7.739999686026577e+110 < b < 5.615557440665007e-158

    1. Initial program 10.4

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

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

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

    if 5.615557440665007e-158 < b < 1.643123946810858e+22

    1. Initial program 34.1

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

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

      \[\leadsto \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}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/34.3

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    7. Applied simplify16.5

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

    if 1.643123946810858e+22 < b

    1. Initial program 55.5

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

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

      \[\leadsto \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}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/55.5

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    7. Applied simplify25.8

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -7.739999686026577 \cdot 10^{+110}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;b \le 5.615557440665007 \cdot 10^{-158}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}}\\ \mathbf{if}\;b \le 1.643123946810858 \cdot 10^{+22}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(c \cdot a\right)}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot \frac{c}{2}}{a \cdot \frac{c}{b} - b}\\ \end{array}}\]

Runtime

Time bar (total: 3.7m)Debug logProfile

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