Average Error: 20.0 → 6.9
Time: 6.4s
Precision: binary64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.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 -7.05324033639582285 \cdot 10^{84}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right) - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 8.15742822070599517 \cdot 10^{90}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}\right| \cdot \sqrt{\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}} \cdot \sqrt[3]{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{2 \cdot \left(c \cdot \frac{a}{b}\right) + b \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - 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 < -7.05324033639582285e84

    1. Initial program 44.4

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.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. Simplified44.4

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}{2 \cdot a}\\ \end{array}\]
    4. Simplified4.2

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

    if -7.05324033639582285e84 < b < 8.15742822070599517e90

    1. Initial program 9.3

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.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. Simplified9.3

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)} \cdot \sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}\right) \cdot \sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}} - b}{2 \cdot a}\\ \end{array}\]
    5. Applied sqrt-prod9.6

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}} - b}{2 \cdot a}\\ \end{array}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt9.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}\right| \cdot \sqrt{\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} \cdot \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}} - b}{2 \cdot a}\\ \end{array}\]
    9. Applied cbrt-prod9.6

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

    if 8.15742822070599517e90 < b

    1. Initial program 29.0

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.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. Simplified29.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7.05324033639582285 \cdot 10^{84}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right) - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 8.15742822070599517 \cdot 10^{90}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\sqrt[3]{b \cdot b - c \cdot \left(4 \cdot a\right)}\right| \cdot \sqrt{\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}} \cdot \sqrt[3]{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;2 \cdot \frac{c}{2 \cdot \left(c \cdot \frac{a}{b}\right) + b \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020184 
(FPCore (a b c)
  :name "jeff quadratic root 2"
  :precision binary64
  (if (>= b 0.0) (/ (* 2.0 c) (- (neg b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (neg b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))