Average Error: 34.5 → 8.9
Time: 6.9s
Precision: binary64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.25744095545956827 \cdot 10^{56}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 6.6320067542060884 \cdot 10^{-298}:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}{c}}}{a}\\ \mathbf{elif}\;b_2 \le 1.39040022315620788 \cdot 10^{44}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.25744095545956827e56

    1. Initial program 57.5

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

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

    if -1.25744095545956827e56 < b_2 < 6.6320067542060884e-298

    1. Initial program 29.7

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified17.1

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Simplified17.1

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied clear-num17.1

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{0 + a \cdot c}}}}{a}\]
    8. Simplified15.2

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

    if 6.6320067542060884e-298 < b_2 < 1.39040022315620788e44

    1. Initial program 9.8

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

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

    if 1.39040022315620788e44 < b_2

    1. Initial program 37.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.25744095545956827 \cdot 10^{56}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 6.6320067542060884 \cdot 10^{-298}:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}{c}}}{a}\\ \mathbf{elif}\;b_2 \le 1.39040022315620788 \cdot 10^{44}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020174 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (neg b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))