Average Error: 33.0 → 15.5
Time: 15.9s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -4.179536313363076 \cdot 10^{+72}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{\frac{3}{2}}{\frac{b}{a \cdot c}}\right)}{a \cdot 3}\\ \mathbf{elif}\;b \le 5.700960046364564 \cdot 10^{-39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -4.179536313363076 \cdot 10^{+72}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{\frac{3}{2}}{\frac{b}{a \cdot c}}\right)}{a \cdot 3}\\

\mathbf{elif}\;b \le 5.700960046364564 \cdot 10^{-39}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{a \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\

\end{array}
double f(double a, double b, double c) {
        double r1632010 = b;
        double r1632011 = -r1632010;
        double r1632012 = r1632010 * r1632010;
        double r1632013 = 3.0;
        double r1632014 = a;
        double r1632015 = r1632013 * r1632014;
        double r1632016 = c;
        double r1632017 = r1632015 * r1632016;
        double r1632018 = r1632012 - r1632017;
        double r1632019 = sqrt(r1632018);
        double r1632020 = r1632011 + r1632019;
        double r1632021 = r1632020 / r1632015;
        return r1632021;
}

double f(double a, double b, double c) {
        double r1632022 = b;
        double r1632023 = -4.179536313363076e+72;
        bool r1632024 = r1632022 <= r1632023;
        double r1632025 = -2.0;
        double r1632026 = 1.5;
        double r1632027 = a;
        double r1632028 = c;
        double r1632029 = r1632027 * r1632028;
        double r1632030 = r1632022 / r1632029;
        double r1632031 = r1632026 / r1632030;
        double r1632032 = fma(r1632022, r1632025, r1632031);
        double r1632033 = 3.0;
        double r1632034 = r1632027 * r1632033;
        double r1632035 = r1632032 / r1632034;
        double r1632036 = 5.700960046364564e-39;
        bool r1632037 = r1632022 <= r1632036;
        double r1632038 = -r1632022;
        double r1632039 = cbrt(r1632038);
        double r1632040 = r1632039 * r1632039;
        double r1632041 = r1632022 * r1632022;
        double r1632042 = r1632034 * r1632028;
        double r1632043 = r1632041 - r1632042;
        double r1632044 = sqrt(r1632043);
        double r1632045 = fma(r1632040, r1632039, r1632044);
        double r1632046 = r1632045 / r1632034;
        double r1632047 = -1.5;
        double r1632048 = r1632029 / r1632022;
        double r1632049 = r1632047 * r1632048;
        double r1632050 = r1632049 / r1632034;
        double r1632051 = r1632037 ? r1632046 : r1632050;
        double r1632052 = r1632024 ? r1632035 : r1632051;
        return r1632052;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -4.179536313363076e+72

    1. Initial program 38.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt38.3

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Applied sqrt-prod38.3

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    5. Taylor expanded around -inf 9.4

      \[\leadsto \frac{\color{blue}{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    6. Simplified9.4

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -2, \frac{\frac{3}{2}}{\frac{b}{a \cdot c}}\right)}}{3 \cdot a}\]

    if -4.179536313363076e+72 < b < 5.700960046364564e-39

    1. Initial program 14.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt14.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \sqrt[3]{-b}} + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    4. Applied fma-def14.9

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]

    if 5.700960046364564e-39 < b

    1. Initial program 53.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 19.1

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.179536313363076 \cdot 10^{+72}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{\frac{3}{2}}{\frac{b}{a \cdot c}}\right)}{a \cdot 3}\\ \mathbf{elif}\;b \le 5.700960046364564 \cdot 10^{-39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\ \end{array}\]

Reproduce

herbie shell --seed 2019154 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))