Average Error: 19.2 → 6.5
Time: 1.2m
Precision: 64
Internal Precision: 320
\[\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.6043155169605484 \cdot 10^{+112}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{\sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}} \cdot \frac{2}{\sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{if}\;b \le 2.9522260100101025 \cdot 10^{+95}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b} \cdot \sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{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 < -1.6043155169605484e+112

    1. Initial program 47.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 9.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{c \cdot a}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\]
    3. Applied simplify3.7

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{1}}{b} - \frac{b}{a}\\ \end{array}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt3.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(a \cdot c\right) \cdot 4}} \cdot \sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}\right) \cdot \sqrt[3]{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{1}}{b} - \frac{b}{a}\\ \end{array}\]
    6. Applied times-frac3.7

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

    if -1.6043155169605484e+112 < b < 2.9522260100101025e+95

    1. Initial program 8.4

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

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

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

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

    if 2.9522260100101025e+95 < b

    1. Initial program 30.1

      \[\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.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 simplify3.0

      \[\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.
  4. Applied simplify6.5

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

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed '#(1071852389 864846987 1238109217 3425890003 4124793586 650694553)' 
(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))))