Average Error: 32.8 → 8.8
Time: 2.8m
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 -5.821596402918175 \cdot 10^{+115}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{if}\;-b \le -1.9516615171416054 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a \cdot 2}\\ \mathbf{if}\;-b \le 3.092591079713731 \cdot 10^{+103}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \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) < -5.821596402918175e+115

    1. Initial program 59.9

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

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{2 \cdot a}\]
    3. Applied simplify2.0

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

    if -5.821596402918175e+115 < (- b) < -1.9516615171416054e-122

    1. Initial program 40.7

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

      \[\leadsto \frac{\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}}}}{2 \cdot a}\]
    4. Applied simplify14.9

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

    if -1.9516615171416054e-122 < (- b) < 3.092591079713731e+103

    1. Initial program 11.0

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

    if 3.092591079713731e+103 < (- b)

    1. Initial program 44.4

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

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

      \[\leadsto \color{blue}{\frac{\frac{c}{1}}{b} - \frac{b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify8.8

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-b \le -5.821596402918175 \cdot 10^{+115}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{if}\;-b \le -1.9516615171416054 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a \cdot 2}\\ \mathbf{if}\;-b \le 3.092591079713731 \cdot 10^{+103}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}}\]

Runtime

Time bar (total: 2.8m)Debug logProfile

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