Average Error: 19.9 → 7.2
Time: 1.4m
Precision: 64
Internal Precision: 384
\[\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.468619920395906 \cdot 10^{+136}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{2 \cdot c}{\sqrt[3]{\frac{a \cdot c}{\frac{b}{2}} - \left(b + b\right)}}}{\sqrt[3]{\frac{a \cdot c}{\frac{b}{2}} - \left(b + b\right)} \cdot \sqrt[3]{\frac{a \cdot c}{\frac{b}{2}} - \left(b + b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b}{c}} - \frac{b + b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \le 2.674727520834672 \cdot 10^{+36}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;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}}{2 \cdot a}\\ \end{array}\\ \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}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -3.468619920395906e+136

    1. Initial program 54.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. Taylor expanded around inf 54.5

      \[\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 simplify54.5

      \[\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-cbrt54.5

      \[\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} - \left(b + b\right)} \cdot \sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b} - \left(b + b\right)}\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. Applied times-frac54.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{\frac{2}{\sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b} - \left(b + b\right)} \cdot \sqrt[3]{\left(2 \cdot a\right) \cdot \frac{c}{b} - \left(b + b\right)}} \cdot \frac{c}{\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}\]
    7. Taylor expanded around -inf 9.9

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

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

    if -3.468619920395906e+136 < b < 2.674727520834672e+36

    1. Initial program 9.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-sqrt9.3

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

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

    if 2.674727520834672e+36 < b

    1. Initial program 25.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 8.0

      \[\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 simplify4.7

      \[\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}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed '#(1070578969 3140398606 632207097 462683394 1189254563 964980650)' 
(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))))