Average Error: 19.1 → 6.6
Time: 29.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 -4.858471778140402 \cdot 10^{+95} \lor \neg \left(b \le 1.0871850582953129 \cdot 10^{+142}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - (\left(\left(\sqrt[3]{\frac{c}{b}} \cdot \sqrt[3]{\frac{c}{b}}\right) \cdot \left(a \cdot \sqrt[3]{\frac{c}{b}}\right)\right) \cdot -2 + b)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|b\right| + \left(-b\right)}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\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}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\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 2 regimes
  2. if b < -4.858471778140402e+95 or 1.0871850582953129e+142 < b

    1. Initial program 38.9

      \[\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 24.2

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

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

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

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

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

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

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

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

    if -4.858471778140402e+95 < b < 1.0871850582953129e+142

    1. Initial program 8.5

      \[\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-sqrt8.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\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}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.858471778140402 \cdot 10^{+95} \lor \neg \left(b \le 1.0871850582953129 \cdot 10^{+142}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - (\left(\left(\sqrt[3]{\frac{c}{b}} \cdot \sqrt[3]{\frac{c}{b}}\right) \cdot \left(a \cdot \sqrt[3]{\frac{c}{b}}\right)\right) \cdot -2 + b)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|b\right| + \left(-b\right)}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\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}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\ \end{array}\]

Runtime

Time bar (total: 29.8s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes20.86.65.415.492.4%
herbie shell --seed 2018340 +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))))