Average Error: 19.5 → 6.3
Time: 1.9m
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.853749799020936 \cdot 10^{+125}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{2}{b} \cdot \left(c \cdot a\right) - \left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b}{c}} - \frac{b + b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \le 1.1210956779554438 \cdot 10^{+123}:\\ \;\;\;\;\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}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}} \cdot \sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}}\right) \cdot \left(\left(\sqrt[3]{\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}}} \cdot \sqrt[3]{\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}}}\right) \cdot \sqrt[3]{\left(\sqrt[3]{\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}}} \cdot \sqrt[3]{\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}}}\right) \cdot \sqrt[3]{\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b}}}}\right) - \left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - 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 < -4.853749799020936e+125

    1. Initial program 51.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 51.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{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. Applied simplify51.2

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

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

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

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

    if -4.853749799020936e+125 < b < 1.1210956779554438e+123

    1. Initial program 8.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. Using strategy rm
    3. Applied add-sqr-sqrt8.3

      \[\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-prod8.4

      \[\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.1210956779554438e+123 < b

    1. Initial program 33.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{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. Applied simplify1.8

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

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

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

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

Runtime

Time bar (total: 1.9m)Debug logProfile

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