Average Error: 34.5 → 10.7
Time: 17.7s
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.286617011150557418784989675044525406772 \cdot 10^{129}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 3.264293321664548066454475951092508206932 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot 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 -2.286617011150557418784989675044525406772 \cdot 10^{129}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4712967 = b;
        double r4712968 = -r4712967;
        double r4712969 = r4712967 * r4712967;
        double r4712970 = 3.0;
        double r4712971 = a;
        double r4712972 = r4712970 * r4712971;
        double r4712973 = c;
        double r4712974 = r4712972 * r4712973;
        double r4712975 = r4712969 - r4712974;
        double r4712976 = sqrt(r4712975);
        double r4712977 = r4712968 + r4712976;
        double r4712978 = r4712977 / r4712972;
        return r4712978;
}

double f(double a, double b, double c) {
        double r4712979 = b;
        double r4712980 = -2.2866170111505574e+129;
        bool r4712981 = r4712979 <= r4712980;
        double r4712982 = 0.5;
        double r4712983 = c;
        double r4712984 = r4712983 / r4712979;
        double r4712985 = r4712982 * r4712984;
        double r4712986 = a;
        double r4712987 = r4712979 / r4712986;
        double r4712988 = 0.6666666666666666;
        double r4712989 = r4712987 * r4712988;
        double r4712990 = r4712985 - r4712989;
        double r4712991 = 3.264293321664548e-35;
        bool r4712992 = r4712979 <= r4712991;
        double r4712993 = r4712979 * r4712979;
        double r4712994 = 3.0;
        double r4712995 = r4712994 * r4712986;
        double r4712996 = r4712995 * r4712983;
        double r4712997 = r4712993 - r4712996;
        double r4712998 = sqrt(r4712997);
        double r4712999 = r4712998 / r4712995;
        double r4713000 = r4712979 / r4712995;
        double r4713001 = r4712999 - r4713000;
        double r4713002 = -0.5;
        double r4713003 = r4713002 * r4712984;
        double r4713004 = r4712992 ? r4713001 : r4713003;
        double r4713005 = r4712981 ? r4712990 : r4713004;
        return r4713005;
}

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 < -2.2866170111505574e+129

    1. Initial program 55.2

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}}\]

    if -2.2866170111505574e+129 < b < 3.264293321664548e-35

    1. Initial program 15.0

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

      \[\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 div-sub15.0

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

    if 3.264293321664548e-35 < b

    1. Initial program 54.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.286617011150557418784989675044525406772 \cdot 10^{129}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 3.264293321664548066454475951092508206932 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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