Average Error: 33.2 → 9.9
Time: 1.3m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.6457378087109476 \cdot 10^{-83}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le 1.326155867761659 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2} \cdot c}{b_2} - b_2 \cdot \frac{2}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -1.6457378087109476e-83

    1. Initial program 52.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 46.5

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

      \[\leadsto \color{blue}{\frac{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}}{1}}\]

    if -1.6457378087109476e-83 < b_2 < 1.326155867761659e+154

    1. Initial program 12.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]

    if 1.326155867761659e+154 < b_2

    1. Initial program 60.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv60.8

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Taylor expanded around inf 10.7

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{c \cdot a}{b_2} - 2 \cdot b_2\right)} \cdot \frac{1}{a}\]
    5. Applied simplify2.4

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b_2 \le -1.6457378087109476 \cdot 10^{-83}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le 1.326155867761659 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2} \cdot c}{b_2} - b_2 \cdot \frac{2}{a}\\ \end{array}}\]

Runtime

Time bar (total: 1.3m)Debug logProfile

herbie shell --seed '#(1071501266 3581234924 1086666455 2685055582 1243441566 1802958749)' +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))