Average Error: 33.8 → 10.9
Time: 30.4s
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 -2.818264606683512 \cdot 10^{+17}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 1.2507329391222916 \cdot 10^{-46}:\\ \;\;\;\;\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} + \left(-b\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{-b}{c}}\\ \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 3 regimes
  2. if b < -2.818264606683512e+17

    1. Initial program 32.1

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

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

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

    if -2.818264606683512e+17 < b < 1.2507329391222916e-46

    1. Initial program 15.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 sub-neg15.5

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

    if 1.2507329391222916e-46 < b

    1. Initial program 53.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity53.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
    4. Applied associate-/l*53.9

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    5. Taylor expanded around 0 8.2

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{b}{c}}}\]
    6. Simplified8.2

      \[\leadsto \frac{1}{\color{blue}{\frac{-b}{c}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.818264606683512 \cdot 10^{+17}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 1.2507329391222916 \cdot 10^{-46}:\\ \;\;\;\;\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} + \left(-b\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{-b}{c}}\\ \end{array}\]

Runtime

Time bar (total: 30.4s)Debug logProfile

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