Average Error: 19.8 → 13.7
Time: 35.8s
Precision: 64
Internal Precision: 576
\[\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 3.0332442122945613 \cdot 10^{+59}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}} \cdot \sqrt{\left|\sqrt[3]{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}\right| \cdot \sqrt{\sqrt[3]{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{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 < 3.0332442122945613e+59

    1. Initial program 17.3

      \[\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. Initial simplification17.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(\left(-4\right) \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(-4\right) \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-sqrt17.4

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

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

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

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

    if 3.0332442122945613e+59 < b

    1. Initial program 26.3

      \[\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. Initial simplification26.3

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

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

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

Runtime

Time bar (total: 35.8s)Debug logProfile

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