Average Error: 33.7 → 13.0
Time: 9.6s
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 -2.2724541866372811 \cdot 10^{165}:\\ \;\;\;\;\frac{-\left(2 \cdot b - 1.5 \cdot \frac{a \cdot c}{b}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 5.89694692852593396 \cdot 10^{-166}:\\ \;\;\;\;\frac{-\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.482156797684751 \cdot 10^{153}:\\ \;\;\;\;\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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 -2.2724541866372811 \cdot 10^{165}:\\
\;\;\;\;\frac{-\left(2 \cdot b - 1.5 \cdot \frac{a \cdot c}{b}\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 5.89694692852593396 \cdot 10^{-166}:\\
\;\;\;\;\frac{-\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 2.482156797684751 \cdot 10^{153}:\\
\;\;\;\;\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r99025 = b;
        double r99026 = -r99025;
        double r99027 = r99025 * r99025;
        double r99028 = 3.0;
        double r99029 = a;
        double r99030 = r99028 * r99029;
        double r99031 = c;
        double r99032 = r99030 * r99031;
        double r99033 = r99027 - r99032;
        double r99034 = sqrt(r99033);
        double r99035 = r99026 + r99034;
        double r99036 = r99035 / r99030;
        return r99036;
}

double f(double a, double b, double c) {
        double r99037 = b;
        double r99038 = -2.272454186637281e+165;
        bool r99039 = r99037 <= r99038;
        double r99040 = 2.0;
        double r99041 = r99040 * r99037;
        double r99042 = 1.5;
        double r99043 = a;
        double r99044 = c;
        double r99045 = r99043 * r99044;
        double r99046 = r99045 / r99037;
        double r99047 = r99042 * r99046;
        double r99048 = r99041 - r99047;
        double r99049 = -r99048;
        double r99050 = 3.0;
        double r99051 = r99050 * r99043;
        double r99052 = r99049 / r99051;
        double r99053 = 5.896946928525934e-166;
        bool r99054 = r99037 <= r99053;
        double r99055 = r99037 * r99037;
        double r99056 = r99051 * r99044;
        double r99057 = r99055 - r99056;
        double r99058 = sqrt(r99057);
        double r99059 = r99037 - r99058;
        double r99060 = -r99059;
        double r99061 = r99060 / r99051;
        double r99062 = 2.482156797684751e+153;
        bool r99063 = r99037 <= r99062;
        double r99064 = -r99037;
        double r99065 = r99064 - r99058;
        double r99066 = r99056 / r99065;
        double r99067 = r99066 / r99051;
        double r99068 = -r99047;
        double r99069 = r99068 / r99051;
        double r99070 = r99063 ? r99067 : r99069;
        double r99071 = r99054 ? r99061 : r99070;
        double r99072 = r99039 ? r99052 : r99071;
        return r99072;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -2.272454186637281e+165

    1. Initial program 64.0

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

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

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

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

    if -2.272454186637281e+165 < b < 5.896946928525934e-166

    1. Initial program 11.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 neg-sub011.1

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

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

    if 5.896946928525934e-166 < b < 2.482156797684751e+153

    1. Initial program 40.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 flip-+40.1

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

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

    if 2.482156797684751e+153 < b

    1. Initial program 63.9

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

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

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

      \[\leadsto \frac{0 - \color{blue}{1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification13.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.2724541866372811 \cdot 10^{165}:\\ \;\;\;\;\frac{-\left(2 \cdot b - 1.5 \cdot \frac{a \cdot c}{b}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 5.89694692852593396 \cdot 10^{-166}:\\ \;\;\;\;\frac{-\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.482156797684751 \cdot 10^{153}:\\ \;\;\;\;\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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