Average Error: 33.6 → 9.6
Time: 2.4m
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 -9.085303359188405 \cdot 10^{+49}:\\ \;\;\;\;\frac{-c}{\frac{b}{1}}\\ \mathbf{if}\;-b \le -3.722166514696236 \cdot 10^{-38}:\\ \;\;\;\;\frac{-c}{\frac{b}{1}}\\ \mathbf{if}\;-b \le -9.61540166757193 \cdot 10^{-144}:\\ \;\;\;\;\log_* (1 + (e^{\frac{\frac{1}{2} \cdot \left(4 \cdot c\right)}{\left(-b\right) - \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}} - 1)^*)\\ \mathbf{if}\;-b \le 1.1215218636373465 \cdot 10^{+79}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(-4\right) \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{2 \cdot a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 5 regimes
  2. if (- b) < -9.085303359188405e+49

    1. Initial program 57.6

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

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

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

    if -9.085303359188405e+49 < (- b) < -3.722166514696236e-38

    1. Initial program 45.4

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

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

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

    if -3.722166514696236e-38 < (- b) < -9.61540166757193e-144

    1. Initial program 28.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 flip-+28.5

      \[\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 simplify15.6

      \[\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 log1p-expm1-u34.8

      \[\leadsto \color{blue}{\log_* (1 + (e^{\frac{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}} - 1)^*)}\]
    7. Applied simplify24.9

      \[\leadsto \log_* (1 + \color{blue}{(e^{\frac{\frac{1}{2} \cdot \left(c \cdot 4\right)}{\left(-b\right) - \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}} - 1)^*})\]

    if -9.61540166757193e-144 < (- b) < 1.1215218636373465e+79

    1. Initial program 11.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 clear-num11.5

      \[\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 simplify11.4

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

    if 1.1215218636373465e+79 < (- b)

    1. Initial program 41.5

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - \frac{b + b}{2 \cdot a}}\]
  3. Recombined 5 regimes into one program.
  4. Applied simplify9.6

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-b \le -9.085303359188405 \cdot 10^{+49}:\\ \;\;\;\;\frac{-c}{\frac{b}{1}}\\ \mathbf{if}\;-b \le -3.722166514696236 \cdot 10^{-38}:\\ \;\;\;\;\frac{-c}{\frac{b}{1}}\\ \mathbf{if}\;-b \le -9.61540166757193 \cdot 10^{-144}:\\ \;\;\;\;\log_* (1 + (e^{\frac{\frac{1}{2} \cdot \left(4 \cdot c\right)}{\left(-b\right) - \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}} - 1)^*)\\ \mathbf{if}\;-b \le 1.1215218636373465 \cdot 10^{+79}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(-4\right) \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{2 \cdot a}\\ \end{array}}\]

Runtime

Time bar (total: 2.4m)Debug logProfile

herbie shell --seed '#(1071119240 1686926585 3481876196 78132896 2080707795 3185793749)' +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))