Average Error: 33.4 → 9.0
Time: 1.4m
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}\;\frac{c}{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}} \le -2.654293537540784 \cdot 10^{+58}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{if}\;\frac{c}{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}} \le 3.2231501628355665 \cdot 10^{-308}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{if}\;\frac{c}{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}} \le 1.2109974218653852 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if (/ c (* (- 1/2) (/ c b_2))) < -2.654293537540784e+58

    1. Initial program 36.7

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{c \cdot a}{b_2} - 2 \cdot b_2}}{a}\]
    3. Applied simplify5.2

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

    if -2.654293537540784e+58 < (/ c (* (- 1/2) (/ c b_2))) < 3.2231501628355665e-308

    1. Initial program 11.2

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

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

    if 3.2231501628355665e-308 < (/ c (* (- 1/2) (/ c b_2))) < 1.2109974218653852e+73

    1. Initial program 32.8

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

      \[\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. Applied simplify15.3

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

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

    if 1.2109974218653852e+73 < (/ c (* (- 1/2) (/ c b_2)))

    1. Initial program 57.0

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

      \[\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 simplify3.4

      \[\leadsto \color{blue}{\frac{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}}{1}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify9.0

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{c}{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}} \le -2.654293537540784 \cdot 10^{+58}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{if}\;\frac{c}{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}} \le 3.2231501628355665 \cdot 10^{-308}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{if}\;\frac{c}{\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}} \le 1.2109974218653852 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \end{array}}\]

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed 2018198 +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))