Average Error: 34.0 → 13.5
Time: 37.4s
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.7412060648765384 \cdot 10^{+90}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -2.9108748169166987 \cdot 10^{-67}:\\ \;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) + \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right)}\\ \mathbf{elif}\;b \le -2.600632313007493 \cdot 10^{-91}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{-2 \cdot \frac{a \cdot c}{b}}}\\ \mathbf{elif}\;b \le 2.1153853257639953 \cdot 10^{+45}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \left(\sqrt[3]{-b}\right) + \left(-\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right))_*}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original34.0
Target21.3
Herbie13.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 5 regimes
  2. if b < -1.7412060648765384e+90

    1. Initial program 58.2

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    3. Taylor expanded around -inf 14.6

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

    if -1.7412060648765384e+90 < b < -2.9108748169166987e-67

    1. Initial program 44.0

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied flip--44.2

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

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

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

    if -2.9108748169166987e-67 < b < -2.600632313007493e-91

    1. Initial program 31.3

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity31.3

      \[\leadsto \frac{\left(-b\right) - \color{blue}{1 \cdot \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}}{2 \cdot a}\]
    5. Applied *-un-lft-identity31.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    6. Applied distribute-lft-out--31.3

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

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

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

    if -2.600632313007493e-91 < b < 2.1153853257639953e+45

    1. Initial program 14.1

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt14.2

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \sqrt[3]{-b}} - \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    5. Applied fma-neg14.2

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

    if 2.1153853257639953e+45 < b

    1. Initial program 36.0

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}{2 \cdot a}\]
    3. Taylor expanded around inf 5.8

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    4. Simplified5.8

      \[\leadsto \color{blue}{\frac{-b}{a}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification13.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.7412060648765384 \cdot 10^{+90}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -2.9108748169166987 \cdot 10^{-67}:\\ \;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) + \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right)}\\ \mathbf{elif}\;b \le -2.600632313007493 \cdot 10^{-91}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{-2 \cdot \frac{a \cdot c}{b}}}\\ \mathbf{elif}\;b \le 2.1153853257639953 \cdot 10^{+45}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \left(\sqrt[3]{-b}\right) + \left(-\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right))_*}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 37.4s)Debug logProfile

herbie shell --seed 2018248 +o rules:numerics
(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)))