Average Error: 33.3 → 12.2
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 -3.9154047919814403 \cdot 10^{+52}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 2.3540708339747997 \cdot 10^{-217}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}\\ \mathbf{if}\;b \le 3.607543696370626 \cdot 10^{+92}:\\ \;\;\;\;\frac{\left(c \cdot 4\right) \cdot \frac{1}{2}}{\frac{2 \cdot c}{\frac{b}{a}} + \left(\left(-b\right) - b\right)}\\ \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 < -3.9154047919814403e+52

    1. Initial program 36.7

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

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

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

    if -3.9154047919814403e+52 < b < 2.3540708339747997e-217

    1. Initial program 9.9

      \[\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.1

      \[\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.1

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

    if 2.3540708339747997e-217 < b < 3.607543696370626e+92

    1. Initial program 35.6

      \[\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-+35.7

      \[\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 simplify16.2

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot 4\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied add-exp-log18.7

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \color{blue}{e^{\log \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}}{2 \cdot a}\]
    7. Taylor expanded around inf 40.0

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - e^{\log \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}}}}{2 \cdot a}\]
    8. Applied simplify28.7

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

    if 3.607543696370626e+92 < b

    1. Initial program 58.2

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -3.9154047919814403 \cdot 10^{+52}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 2.3540708339747997 \cdot 10^{-217}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}\\ \mathbf{if}\;b \le 3.607543696370626 \cdot 10^{+92}:\\ \;\;\;\;\frac{\left(c \cdot 4\right) \cdot \frac{1}{2}}{\frac{2 \cdot c}{\frac{b}{a}} + \left(\left(-b\right) - b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}}\]

Runtime

Time bar (total: 3.7m)Debug logProfile

herbie shell --seed '#(1072743783 989954326 4239155542 3782239461 3602631542 1719177920)' 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))