Average Error: 19.3 → 13.1
Time: 36.2s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 9.355687789763098 \cdot 10^{+87}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{(\left(-\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(\sqrt[3]{b}\right) + \left(-\sqrt{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt{\sqrt[3]{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} \cdot \sqrt[3]{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt[3]{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}}}\right))_*}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{c}{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(a \cdot \frac{c}{b} - b\right) \cdot 2}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{c}{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}\\ \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 < 9.355687789763098e+87

    1. Initial program 14.8

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

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

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

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

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

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

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

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

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

    if 9.355687789763098e+87 < b

    1. Initial program 41.1

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

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

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

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

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

Reproduce

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