Average Error: 19.1 → 6.8
Time: 1.1m
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -8.130457313724135 \cdot 10^{+141}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 7.086915338165871 \cdot 10^{+90}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{(\left(\sqrt{b}\right) \cdot \left(-\sqrt{b}\right) + \left(\sqrt{\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(-\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right)\right))_*}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{c}{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} - b}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le -8.130457313724135 \cdot 10^{+141}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

\end{array}\\

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

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r2574992 = b;
        double r2574993 = 0.0;
        bool r2574994 = r2574992 >= r2574993;
        double r2574995 = -r2574992;
        double r2574996 = r2574992 * r2574992;
        double r2574997 = 4.0;
        double r2574998 = a;
        double r2574999 = r2574997 * r2574998;
        double r2575000 = c;
        double r2575001 = r2574999 * r2575000;
        double r2575002 = r2574996 - r2575001;
        double r2575003 = sqrt(r2575002);
        double r2575004 = r2574995 - r2575003;
        double r2575005 = 2.0;
        double r2575006 = r2575005 * r2574998;
        double r2575007 = r2575004 / r2575006;
        double r2575008 = r2575005 * r2575000;
        double r2575009 = r2574995 + r2575003;
        double r2575010 = r2575008 / r2575009;
        double r2575011 = r2574994 ? r2575007 : r2575010;
        return r2575011;
}

double f(double a, double b, double c) {
        double r2575012 = b;
        double r2575013 = -8.130457313724135e+141;
        bool r2575014 = r2575012 <= r2575013;
        double r2575015 = 0.0;
        bool r2575016 = r2575012 >= r2575015;
        double r2575017 = -r2575012;
        double r2575018 = r2575012 * r2575012;
        double r2575019 = 4.0;
        double r2575020 = a;
        double r2575021 = r2575019 * r2575020;
        double r2575022 = c;
        double r2575023 = r2575021 * r2575022;
        double r2575024 = r2575018 - r2575023;
        double r2575025 = sqrt(r2575024);
        double r2575026 = r2575017 - r2575025;
        double r2575027 = 2.0;
        double r2575028 = r2575027 * r2575020;
        double r2575029 = r2575026 / r2575028;
        double r2575030 = r2575022 * r2575027;
        double r2575031 = r2575022 / r2575012;
        double r2575032 = r2575020 * r2575031;
        double r2575033 = r2575032 - r2575012;
        double r2575034 = r2575027 * r2575033;
        double r2575035 = r2575030 / r2575034;
        double r2575036 = r2575016 ? r2575029 : r2575035;
        double r2575037 = 7.086915338165871e+90;
        bool r2575038 = r2575012 <= r2575037;
        double r2575039 = sqrt(r2575012);
        double r2575040 = -r2575039;
        double r2575041 = cbrt(r2575024);
        double r2575042 = r2575041 * r2575041;
        double r2575043 = r2575041 * r2575042;
        double r2575044 = cbrt(r2575043);
        double r2575045 = r2575044 * r2575041;
        double r2575046 = sqrt(r2575045);
        double r2575047 = sqrt(r2575041);
        double r2575048 = -r2575047;
        double r2575049 = r2575046 * r2575048;
        double r2575050 = fma(r2575039, r2575040, r2575049);
        double r2575051 = r2575050 / r2575028;
        double r2575052 = r2575025 + r2575017;
        double r2575053 = r2575030 / r2575052;
        double r2575054 = r2575016 ? r2575051 : r2575053;
        double r2575055 = r2575017 - r2575012;
        double r2575056 = r2575055 / r2575028;
        double r2575057 = -4.0;
        double r2575058 = r2575057 * r2575020;
        double r2575059 = fma(r2575058, r2575022, r2575018);
        double r2575060 = sqrt(r2575059);
        double r2575061 = r2575060 - r2575012;
        double r2575062 = r2575022 / r2575061;
        double r2575063 = r2575027 * r2575062;
        double r2575064 = r2575016 ? r2575056 : r2575063;
        double r2575065 = r2575038 ? r2575054 : r2575064;
        double r2575066 = r2575014 ? r2575036 : r2575065;
        return r2575066;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -8.130457313724135e+141

    1. Initial program 35.6

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

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

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

    if -8.130457313724135e+141 < b < 7.086915338165871e+90

    1. Initial program 8.9

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

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

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

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

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

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

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

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

    if 7.086915338165871e+90 < b

    1. Initial program 42.3

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

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

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

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

Reproduce

herbie shell --seed 2019112 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))