Average Error: 34.5 → 10.7
Time: 20.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 r4468991 = b;
        double r4468992 = -r4468991;
        double r4468993 = r4468991 * r4468991;
        double r4468994 = 3.0;
        double r4468995 = a;
        double r4468996 = r4468994 * r4468995;
        double r4468997 = c;
        double r4468998 = r4468996 * r4468997;
        double r4468999 = r4468993 - r4468998;
        double r4469000 = sqrt(r4468999);
        double r4469001 = r4468992 + r4469000;
        double r4469002 = r4469001 / r4468996;
        return r4469002;
}

double f(double a, double b, double c) {
        double r4469003 = b;
        double r4469004 = -2.2866170111505574e+129;
        bool r4469005 = r4469003 <= r4469004;
        double r4469006 = 0.5;
        double r4469007 = c;
        double r4469008 = r4469007 / r4469003;
        double r4469009 = r4469006 * r4469008;
        double r4469010 = a;
        double r4469011 = r4469003 / r4469010;
        double r4469012 = 0.6666666666666666;
        double r4469013 = r4469011 * r4469012;
        double r4469014 = r4469009 - r4469013;
        double r4469015 = 3.264293321664548e-35;
        bool r4469016 = r4469003 <= r4469015;
        double r4469017 = r4469003 * r4469003;
        double r4469018 = 3.0;
        double r4469019 = r4469018 * r4469010;
        double r4469020 = r4469019 * r4469007;
        double r4469021 = r4469017 - r4469020;
        double r4469022 = sqrt(r4469021);
        double r4469023 = r4469022 / r4469019;
        double r4469024 = r4469003 / r4469019;
        double r4469025 = r4469023 - r4469024;
        double r4469026 = -0.5;
        double r4469027 = r4469026 * r4469008;
        double r4469028 = r4469016 ? r4469025 : r4469027;
        double r4469029 = r4469005 ? r4469014 : r4469028;
        return r4469029;
}

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)))