Average Error: 19.0 → 6.9
Time: 53.3s
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 -2.7261971550086115 \cdot 10^{+82}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2}{\sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}} \cdot \sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}} \cdot \frac{c}{\sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \le 1.170080853887373 \cdot 10^{+54}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}} + \left(-b\right)}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{(\left(\frac{a}{b}\right) \cdot c + \left(-b\right))_* \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.7261971550086115e+82

    1. Initial program 42.2

      \[\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. Taylor expanded around -inf 10.8

      \[\leadsto \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{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\]
    3. Simplified4.9

      \[\leadsto \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(\frac{a}{b}\right) \cdot c + \left(-b\right))_* \cdot 2}{2 \cdot a}\\ \end{array}\]
    4. Taylor expanded around 0 4.7

      \[\leadsto \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{c}{b} - \frac{b}{a}\\ \end{array}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt4.7

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

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

    if -2.7261971550086115e+82 < b < 1.170080853887373e+54

    1. Initial program 9.0

      \[\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. Using strategy rm
    3. Applied add-sqr-sqrt9.0

      \[\leadsto \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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\]
    4. Applied sqrt-prod9.2

      \[\leadsto \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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\]

    if 1.170080853887373e+54 < b

    1. Initial program 24.6

      \[\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. Taylor expanded around inf 6.6

      \[\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(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    3. Simplified3.6

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

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

Runtime

Time bar (total: 53.3s)Debug logProfile

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