Average Error: 19.2 → 12.7
Time: 52.6s
Precision: 64
\[\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 8.691040984183392 \cdot 10^{+95}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{-(\left(\left|\sqrt[3]{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}\right|\right) \cdot \left(\sqrt{\sqrt[3]{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}} \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}}\right) + b)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{c}{b} \cdot a - b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \end{array}\]
\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 8.691040984183392 \cdot 10^{+95}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{-(\left(\left|\sqrt[3]{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}\right|\right) \cdot \left(\sqrt{\sqrt[3]{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}} \cdot \sqrt[3]{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}}\right) + b)_*}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\

\end{array}\\

\mathbf{elif}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{c}{b} \cdot a - b\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\

\end{array}
double f(double a, double b, double c) {
        double r1316294 = b;
        double r1316295 = 0.0;
        bool r1316296 = r1316294 >= r1316295;
        double r1316297 = 2.0;
        double r1316298 = c;
        double r1316299 = r1316297 * r1316298;
        double r1316300 = -r1316294;
        double r1316301 = r1316294 * r1316294;
        double r1316302 = 4.0;
        double r1316303 = a;
        double r1316304 = r1316302 * r1316303;
        double r1316305 = r1316304 * r1316298;
        double r1316306 = r1316301 - r1316305;
        double r1316307 = sqrt(r1316306);
        double r1316308 = r1316300 - r1316307;
        double r1316309 = r1316299 / r1316308;
        double r1316310 = r1316300 + r1316307;
        double r1316311 = r1316297 * r1316303;
        double r1316312 = r1316310 / r1316311;
        double r1316313 = r1316296 ? r1316309 : r1316312;
        return r1316313;
}

double f(double a, double b, double c) {
        double r1316314 = b;
        double r1316315 = 8.691040984183392e+95;
        bool r1316316 = r1316314 <= r1316315;
        double r1316317 = 0.0;
        bool r1316318 = r1316314 >= r1316317;
        double r1316319 = 2.0;
        double r1316320 = c;
        double r1316321 = r1316319 * r1316320;
        double r1316322 = -4.0;
        double r1316323 = a;
        double r1316324 = r1316323 * r1316320;
        double r1316325 = r1316314 * r1316314;
        double r1316326 = fma(r1316322, r1316324, r1316325);
        double r1316327 = cbrt(r1316326);
        double r1316328 = fabs(r1316327);
        double r1316329 = sqrt(r1316326);
        double r1316330 = cbrt(r1316329);
        double r1316331 = r1316330 * r1316330;
        double r1316332 = sqrt(r1316331);
        double r1316333 = fma(r1316328, r1316332, r1316314);
        double r1316334 = -r1316333;
        double r1316335 = r1316321 / r1316334;
        double r1316336 = r1316329 - r1316314;
        double r1316337 = r1316323 * r1316319;
        double r1316338 = r1316336 / r1316337;
        double r1316339 = r1316318 ? r1316335 : r1316338;
        double r1316340 = r1316320 / r1316314;
        double r1316341 = r1316340 * r1316323;
        double r1316342 = r1316341 - r1316314;
        double r1316343 = r1316319 * r1316342;
        double r1316344 = r1316321 / r1316343;
        double r1316345 = r1316318 ? r1316344 : r1316338;
        double r1316346 = r1316316 ? r1316339 : r1316345;
        return r1316346;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 8.691040984183392e+95

    1. Initial program 15.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. Simplified15.8

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-(\left(\left|\sqrt[3]{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}\right|\right) \cdot \left(\sqrt{\sqrt[3]{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\right) + b)_*\right) + \color{blue}{0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \end{array}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt16.0

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

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

    if 8.691040984183392e+95 < b

    1. Initial program 29.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. Simplified29.8

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

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

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

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

Reproduce

herbie shell --seed 2019104 +o rules:numerics
(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))))