Average Error: 33.8 → 8.8
Time: 3.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}\;b \le -1.9979183584340477 \cdot 10^{+120}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 1.021266047469986 \cdot 10^{-281}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} + \left(-b\right)\right)\\ \mathbf{if}\;b \le 3.7208207919097225 \cdot 10^{+36}:\\ \;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{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 < -1.9979183584340477e+120

    1. Initial program 50.2

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    3. Applied simplify2.7

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

    if -1.9979183584340477e+120 < b < 1.021266047469986e-281

    1. Initial program 9.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 div-inv9.6

      \[\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}}\]

    if 1.021266047469986e-281 < b < 3.7208207919097225e+36

    1. Initial program 29.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 flip-+29.9

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

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

    if 3.7208207919097225e+36 < b

    1. Initial program 56.3

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -1.9979183584340477 \cdot 10^{+120}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 1.021266047469986 \cdot 10^{-281}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} + \left(-b\right)\right)\\ \mathbf{if}\;b \le 3.7208207919097225 \cdot 10^{+36}:\\ \;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}}\]

Runtime

Time bar (total: 3.3m)Debug logProfile

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