Average Error: 33.2 → 8.7
Time: 2.7m
Precision: 64
Internal Precision: 3200
\[\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.3628056667376623 \cdot 10^{+154}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 4.284496431235526 \cdot 10^{-145}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{2 \cdot a}\\ \mathbf{if}\;b \le 6.619815002390032 \cdot 10^{+34}:\\ \;\;\;\;\frac{\frac{c \cdot \left(4 \cdot a\right)}{\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

Derivation

  1. Split input into 4 regimes
  2. if b < -1.3628056667376623e+154

    1. Initial program 60.9

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

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

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

    if -1.3628056667376623e+154 < b < 4.284496431235526e-145

    1. Initial program 10.7

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

    if 4.284496431235526e-145 < b < 6.619815002390032e+34

    1. Initial program 36.2

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

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

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

    if 6.619815002390032e+34 < 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. Taylor expanded around inf 43.1

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -1.3628056667376623 \cdot 10^{+154}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 4.284496431235526 \cdot 10^{-145}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{2 \cdot a}\\ \mathbf{if}\;b \le 6.619815002390032 \cdot 10^{+34}:\\ \;\;\;\;\frac{\frac{c \cdot \left(4 \cdot a\right)}{\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: 2.7m)Debug logProfile

herbie shell --seed '#(1070609872 3456127585 2380521889 2328837196 1765472538 734540918)' 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))