Average Error: 19.1 → 12.7
Time: 54.7s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 1.1218716869064953 \cdot 10^{+100}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(b + \left(-b\right)\right) + (\left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} \cdot \sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}}\right) \cdot \left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}}\right) + \left(-b\right))_*}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(a \cdot \frac{c}{b} - b\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(b + \left(-b\right)\right) + \left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right)}{2 \cdot a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 1.1218716869064953e+100

    1. Initial program 15.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified15.8

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt40.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - \sqrt{b} \cdot \sqrt{b}}{2 \cdot a}\\ \end{array}\]
    5. Applied add-cube-cbrt40.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}} \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}} - \sqrt{b} \cdot \sqrt{b}}{2 \cdot a}\\ \end{array}\]
    6. Applied prod-diff40.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}} \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) \cdot \left(\sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) + \left(-\sqrt{b} \cdot \sqrt{b}\right))_* + (\left(-\sqrt{b}\right) \cdot \left(\sqrt{b}\right) + \left(\sqrt{b} \cdot \sqrt{b}\right))_*}{2 \cdot a}\\ \end{array}\]
    7. Simplified40.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right) + (\left(-\sqrt{b}\right) \cdot \left(\sqrt{b}\right) + \left(\sqrt{b} \cdot \sqrt{b}\right))_*}{2 \cdot a}\\ \end{array}\]
    8. Simplified15.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right) + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt16.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{\left(\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} \cdot \sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}\right) \cdot \sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}} - b\right) + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]
    11. Applied sqrt-prod16.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} \cdot \sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}} - b\right) + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]
    12. Applied fma-neg16.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} \cdot \sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}}\right) \cdot \left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}}\right) + \left(-b\right))_* + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]

    if 1.1218716869064953e+100 < b

    1. Initial program 29.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified29.7

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt29.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - \sqrt{b} \cdot \sqrt{b}}{2 \cdot a}\\ \end{array}\]
    5. Applied add-cube-cbrt29.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}} \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}} - \sqrt{b} \cdot \sqrt{b}}{2 \cdot a}\\ \end{array}\]
    6. Applied prod-diff29.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}} \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) \cdot \left(\sqrt[3]{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) + \left(-\sqrt{b} \cdot \sqrt{b}\right))_* + (\left(-\sqrt{b}\right) \cdot \left(\sqrt{b}\right) + \left(\sqrt{b} \cdot \sqrt{b}\right))_*}{2 \cdot a}\\ \end{array}\]
    7. Simplified29.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right) + (\left(-\sqrt{b}\right) \cdot \left(\sqrt{b}\right) + \left(\sqrt{b} \cdot \sqrt{b}\right))_*}{2 \cdot a}\\ \end{array}\]
    8. Simplified29.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right) + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]
    9. Taylor expanded around inf 6.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right) + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]
    10. Simplified2.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(\frac{c}{b} \cdot a - b\right) \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right) + \left(\left(-b\right) + b\right)}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification12.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.1218716869064953 \cdot 10^{+100}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(b + \left(-b\right)\right) + (\left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} \cdot \sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}}\right) \cdot \left(\sqrt{\sqrt[3]{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*}}\right) + \left(-b\right))_*}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(a \cdot \frac{c}{b} - b\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(b + \left(-b\right)\right) + \left(\sqrt{(\left(-4 \cdot c\right) \cdot a + \left(b \cdot b\right))_*} - b\right)}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019072 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))