Average Error: 34.0 → 8.5
Time: 2.2m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.1269598506066497 \cdot 10^{+79}:\\ \;\;\;\;\frac{\frac{c \cdot 4}{2 \cdot 2}}{\frac{c}{\frac{b}{a}} - b}\\ \mathbf{if}\;b \le -4.53738813869002 \cdot 10^{-281}:\\ \;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{a \cdot 2}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\ \mathbf{if}\;b \le 2.0794276032783904 \cdot 10^{+131}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(-b\right) + \left(-b\right)\right) + \frac{c}{b} \cdot \left(a \cdot 2\right)}{a \cdot 2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original34.0
Target20.9
Herbie8.5
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if b < -1.1269598506066497e+79

    1. Initial program 58.1

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv58.1

      \[\leadsto \color{blue}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied flip--58.1

      \[\leadsto \color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/58.1

      \[\leadsto \color{blue}{\frac{\left(\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\]
    7. Applied simplify29.6

      \[\leadsto \frac{\color{blue}{\frac{\left(4 \cdot c\right) \cdot a}{a \cdot 2}}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\]
    8. Taylor expanded around -inf 8.1

      \[\leadsto \frac{\frac{\left(4 \cdot c\right) \cdot a}{a \cdot 2}}{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}\]
    9. Applied simplify3.0

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

    if -1.1269598506066497e+79 < b < -4.53738813869002e-281

    1. Initial program 32.0

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv32.1

      \[\leadsto \color{blue}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied flip--32.2

      \[\leadsto \color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/32.3

      \[\leadsto \color{blue}{\frac{\left(\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\]
    7. Applied simplify15.3

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

    if -4.53738813869002e-281 < b < 2.0794276032783904e+131

    1. Initial program 9.3

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]

    if 2.0794276032783904e+131 < b

    1. Initial program 53.6

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv53.6

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

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

      \[\leadsto \color{blue}{\frac{\left(2 \cdot a\right) \cdot \frac{c}{b} + \left(-\left(b + b\right)\right)}{2 \cdot a}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify8.5

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -1.1269598506066497 \cdot 10^{+79}:\\ \;\;\;\;\frac{\frac{c \cdot 4}{2 \cdot 2}}{\frac{c}{\frac{b}{a}} - b}\\ \mathbf{if}\;b \le -4.53738813869002 \cdot 10^{-281}:\\ \;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{a \cdot 2}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\ \mathbf{if}\;b \le 2.0794276032783904 \cdot 10^{+131}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(-b\right) + \left(-b\right)\right) + \frac{c}{b} \cdot \left(a \cdot 2\right)}{a \cdot 2}\\ \end{array}}\]

Runtime

Time bar (total: 2.2m)Debug logProfile

herbie shell --seed '#(1071119240 1686926585 3481876196 78132896 2080707795 3185793749)' 
(FPCore (a b c)
  :name "quadm (p42, negative)"

  :herbie-target
  (if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))