Average Error: 34.3 → 9.6
Time: 14.5s
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 -5.791348048249166002460683130439961414293 \cdot 10^{138}:\\ \;\;\;\;\frac{\frac{1}{\frac{-1.5}{b}}}{a}\\ \mathbf{elif}\;b \le 4.626043257219637986942022736183111936335 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \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 -5.791348048249166002460683130439961414293 \cdot 10^{138}:\\
\;\;\;\;\frac{\frac{1}{\frac{-1.5}{b}}}{a}\\

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

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r6877040 = b;
        double r6877041 = -r6877040;
        double r6877042 = r6877040 * r6877040;
        double r6877043 = 3.0;
        double r6877044 = a;
        double r6877045 = r6877043 * r6877044;
        double r6877046 = c;
        double r6877047 = r6877045 * r6877046;
        double r6877048 = r6877042 - r6877047;
        double r6877049 = sqrt(r6877048);
        double r6877050 = r6877041 + r6877049;
        double r6877051 = r6877050 / r6877045;
        return r6877051;
}

double f(double a, double b, double c) {
        double r6877052 = b;
        double r6877053 = -5.791348048249166e+138;
        bool r6877054 = r6877052 <= r6877053;
        double r6877055 = 1.0;
        double r6877056 = -1.5;
        double r6877057 = r6877056 / r6877052;
        double r6877058 = r6877055 / r6877057;
        double r6877059 = a;
        double r6877060 = r6877058 / r6877059;
        double r6877061 = 4.626043257219638e-62;
        bool r6877062 = r6877052 <= r6877061;
        double r6877063 = r6877052 * r6877052;
        double r6877064 = 3.0;
        double r6877065 = r6877064 * r6877059;
        double r6877066 = c;
        double r6877067 = r6877065 * r6877066;
        double r6877068 = r6877063 - r6877067;
        double r6877069 = sqrt(r6877068);
        double r6877070 = r6877069 - r6877052;
        double r6877071 = r6877070 / r6877064;
        double r6877072 = r6877071 / r6877059;
        double r6877073 = -0.5;
        double r6877074 = r6877066 / r6877052;
        double r6877075 = r6877073 * r6877074;
        double r6877076 = r6877062 ? r6877072 : r6877075;
        double r6877077 = r6877054 ? r6877060 : r6877076;
        return r6877077;
}

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 3 regimes
  2. if b < -5.791348048249166e+138

    1. Initial program 58.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified58.6

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-/r*58.6

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}}\]
    5. Using strategy rm
    6. Applied clear-num58.6

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{-1.5}{b}}}}{a}\]

    if -5.791348048249166e+138 < b < 4.626043257219638e-62

    1. Initial program 12.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified12.3

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-/r*12.4

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

    if 4.626043257219638e-62 < b

    1. Initial program 53.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified53.7

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.791348048249166002460683130439961414293 \cdot 10^{138}:\\ \;\;\;\;\frac{\frac{1}{\frac{-1.5}{b}}}{a}\\ \mathbf{elif}\;b \le 4.626043257219637986942022736183111936335 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))