Average Error: 33.7 → 10.5
Time: 6.7m
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -6.513446677820839 \cdot 10^{-78}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.145891006680855 \cdot 10^{-06}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a} - (\frac{-1}{2} \cdot \left(\frac{c}{b_2}\right) + \left(\frac{b_2}{a}\right))_*\\ \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 < -6.513446677820839e-78

    1. Initial program 52.5

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]

    if -6.513446677820839e-78 < b_2 < 7.145891006680855e-06

    1. Initial program 14.8

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]

    if 7.145891006680855e-06 < b_2

    1. Initial program 30.9

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv31.0

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}}\]
    6. Taylor expanded around inf 7.3

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

      \[\leadsto \frac{-b_2}{a} - \color{blue}{(\frac{-1}{2} \cdot \left(\frac{c}{b_2}\right) + \left(\frac{b_2}{a}\right))_*}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.513446677820839 \cdot 10^{-78}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.145891006680855 \cdot 10^{-06}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a} - (\frac{-1}{2} \cdot \left(\frac{c}{b_2}\right) + \left(\frac{b_2}{a}\right))_*\\ \end{array}\]

Reproduce

herbie shell --seed 2019089 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))