Average Error: 32.9 → 8.8
Time: 2.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 -1.327146768770392 \cdot 10^{+58}:\\ \;\;\;\;\frac{c \cdot \left(\frac{a}{2} \cdot \frac{4}{a}\right)}{(\left(\frac{a}{\frac{b}{c}}\right) \cdot 2 + \left(\left(-b\right) - b\right))_*}\\ \mathbf{if}\;-b \le -3.204523618328988 \cdot 10^{-129}:\\ \;\;\;\;\frac{\frac{\left(a \cdot 4\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}{a \cdot 2}\\ \mathbf{if}\;-b \le 7.554938830379422 \cdot 10^{+118}:\\ \;\;\;\;\frac{1}{a \cdot 2} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a \cdot 2}\\ \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.327146768770392e+58

    1. Initial program 57.0

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

      \[\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 simplify28.8

      \[\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. Taylor expanded around inf 15.2

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

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

    if -1.327146768770392e+58 < (- b) < -3.204523618328988e-129

    1. Initial program 38.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-+38.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 simplify16.3

      \[\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 -3.204523618328988e-129 < (- b) < 7.554938830379422e+118

    1. Initial program 10.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 div-inv11.0

      \[\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 7.554938830379422e+118 < (- b)

    1. Initial program 48.4

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-b \le -1.327146768770392 \cdot 10^{+58}:\\ \;\;\;\;\frac{c \cdot \left(\frac{a}{2} \cdot \frac{4}{a}\right)}{(\left(\frac{a}{\frac{b}{c}}\right) \cdot 2 + \left(\left(-b\right) - b\right))_*}\\ \mathbf{if}\;-b \le -3.204523618328988 \cdot 10^{-129}:\\ \;\;\;\;\frac{\frac{\left(a \cdot 4\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}{a \cdot 2}\\ \mathbf{if}\;-b \le 7.554938830379422 \cdot 10^{+118}:\\ \;\;\;\;\frac{1}{a \cdot 2} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a \cdot 2}\\ \end{array}}\]

Runtime

Time bar (total: 2.7m)Debug logProfile

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