Average Error: 34.9 → 10.2
Time: 20.1s
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 -3.25165686884117225057308430661709452775 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 4.612990823111230552052602417245542305295 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \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 -3.25165686884117225057308430661709452775 \cdot 10^{152}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r5462071 = b;
        double r5462072 = -r5462071;
        double r5462073 = r5462071 * r5462071;
        double r5462074 = 3.0;
        double r5462075 = a;
        double r5462076 = r5462074 * r5462075;
        double r5462077 = c;
        double r5462078 = r5462076 * r5462077;
        double r5462079 = r5462073 - r5462078;
        double r5462080 = sqrt(r5462079);
        double r5462081 = r5462072 + r5462080;
        double r5462082 = r5462081 / r5462076;
        return r5462082;
}

double f(double a, double b, double c) {
        double r5462083 = b;
        double r5462084 = -3.2516568688411723e+152;
        bool r5462085 = r5462083 <= r5462084;
        double r5462086 = 0.5;
        double r5462087 = c;
        double r5462088 = r5462087 / r5462083;
        double r5462089 = r5462086 * r5462088;
        double r5462090 = a;
        double r5462091 = r5462083 / r5462090;
        double r5462092 = 0.6666666666666666;
        double r5462093 = r5462091 * r5462092;
        double r5462094 = r5462089 - r5462093;
        double r5462095 = 4.6129908231112306e-104;
        bool r5462096 = r5462083 <= r5462095;
        double r5462097 = 1.0;
        double r5462098 = 3.0;
        double r5462099 = r5462098 * r5462090;
        double r5462100 = r5462083 * r5462083;
        double r5462101 = r5462099 * r5462087;
        double r5462102 = r5462100 - r5462101;
        double r5462103 = sqrt(r5462102);
        double r5462104 = r5462103 - r5462083;
        double r5462105 = r5462099 / r5462104;
        double r5462106 = r5462097 / r5462105;
        double r5462107 = -0.5;
        double r5462108 = r5462107 * r5462088;
        double r5462109 = r5462096 ? r5462106 : r5462108;
        double r5462110 = r5462085 ? r5462094 : r5462109;
        return r5462110;
}

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 < -3.2516568688411723e+152

    1. Initial program 63.5

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

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

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

    if -3.2516568688411723e+152 < b < 4.6129908231112306e-104

    1. Initial program 12.2

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

      \[\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 clear-num12.3

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

    if 4.6129908231112306e-104 < b

    1. Initial program 52.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified52.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 9.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.25165686884117225057308430661709452775 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 4.612990823111230552052602417245542305295 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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