Average Error: 33.7 → 10.9
Time: 21.4s
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 -7.649331650633233 \cdot 10^{+117}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.133232442707745 \cdot 10^{+62}:\\ \;\;\;\;\frac{\frac{a}{\frac{a}{c}}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le -2.2061493354735315 \cdot 10^{-78}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.145891006680855 \cdot 10^{-06}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{1}{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 < -7.649331650633233e+117 or -1.133232442707745e+62 < b_2 < -2.2061493354735315e-78

    1. Initial program 53.6

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified53.6

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

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

    if -7.649331650633233e+117 < b_2 < -1.133232442707745e+62

    1. Initial program 46.1

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

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    4. Using strategy rm
    5. Applied div-inv46.1

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    6. Using strategy rm
    7. Applied flip--46.2

      \[\leadsto \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}}} \cdot \frac{1}{a}\]
    8. Applied associate-*l/46.2

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Simplified7.9

      \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{a}}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    10. Using strategy rm
    11. Applied associate-/l*16.3

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

    if -2.2061493354735315e-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. Taylor expanded around 0 14.8

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified14.8

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{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. Taylor expanded around 0 30.9

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified30.9

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

      \[\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 simplification10.9

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

Reproduce

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