Average Error: 18.9 → 8.2
Time: 39.4s
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.2708854266085412 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 3.574043840337914 \cdot 10^{+108}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt[3]{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \left|\sqrt[3]{b \cdot b + \left(-4 \cdot c\right) \cdot a}\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -1.2708854266085412e+154

    1. Initial program 60.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. Initial simplification60.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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    3. Taylor expanded around -inf 10.6

      \[\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}\]

    if -1.2708854266085412e+154 < b < 3.574043840337914e+108

    1. Initial program 8.7

      \[\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 simplification8.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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt8.8

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

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

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

    if 3.574043840337914e+108 < b

    1. Initial program 30.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. Initial simplification30.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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    3. Taylor expanded around inf 5.3

      \[\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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.2

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

Runtime

Time bar (total: 39.4s)Debug logProfile

herbie shell --seed 2018348 
(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))))