Average Error: 34.6 → 8.4
Time: 24.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 -2.8920328608199634 \cdot 10^{82}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -3.3528823044057167 \cdot 10^{-206}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 3.593830924265355 \cdot 10^{-35}:\\ \;\;\;\;\frac{\left(a \cdot 3\right) \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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.8920328608199634 \cdot 10^{82}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r86211 = b;
        double r86212 = -r86211;
        double r86213 = r86211 * r86211;
        double r86214 = 3.0;
        double r86215 = a;
        double r86216 = r86214 * r86215;
        double r86217 = c;
        double r86218 = r86216 * r86217;
        double r86219 = r86213 - r86218;
        double r86220 = sqrt(r86219);
        double r86221 = r86212 + r86220;
        double r86222 = r86221 / r86216;
        return r86222;
}

double f(double a, double b, double c) {
        double r86223 = b;
        double r86224 = -2.8920328608199634e+82;
        bool r86225 = r86223 <= r86224;
        double r86226 = 0.5;
        double r86227 = c;
        double r86228 = r86227 / r86223;
        double r86229 = r86226 * r86228;
        double r86230 = 0.6666666666666666;
        double r86231 = a;
        double r86232 = r86223 / r86231;
        double r86233 = r86230 * r86232;
        double r86234 = r86229 - r86233;
        double r86235 = -3.3528823044057167e-206;
        bool r86236 = r86223 <= r86235;
        double r86237 = r86223 * r86223;
        double r86238 = 3.0;
        double r86239 = r86238 * r86231;
        double r86240 = r86239 * r86227;
        double r86241 = r86237 - r86240;
        double r86242 = sqrt(r86241);
        double r86243 = r86242 - r86223;
        double r86244 = r86243 / r86238;
        double r86245 = r86244 / r86231;
        double r86246 = 3.593830924265355e-35;
        bool r86247 = r86223 <= r86246;
        double r86248 = r86231 * r86238;
        double r86249 = -r86223;
        double r86250 = r86249 - r86242;
        double r86251 = r86227 / r86250;
        double r86252 = r86248 * r86251;
        double r86253 = r86252 / r86239;
        double r86254 = -0.5;
        double r86255 = r86254 * r86228;
        double r86256 = r86247 ? r86253 : r86255;
        double r86257 = r86236 ? r86245 : r86256;
        double r86258 = r86225 ? r86234 : r86257;
        return r86258;
}

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.8920328608199634e+82

    1. Initial program 44.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 4.1

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

    if -2.8920328608199634e+82 < b < -3.3528823044057167e-206

    1. Initial program 7.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*7.9

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

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

    if -3.3528823044057167e-206 < b < 3.593830924265355e-35

    1. Initial program 21.5

      \[\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-+21.7

      \[\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. Simplified17.5

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

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}}{a}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity17.6

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3}}{a}\]
    10. Applied times-frac14.8

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

      \[\leadsto \frac{\frac{\color{blue}{\left(a \cdot 3\right)} \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}{a}\]
    12. Using strategy rm
    13. Applied div-inv14.8

      \[\leadsto \frac{\color{blue}{\left(\left(a \cdot 3\right) \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right) \cdot \frac{1}{3}}}{a}\]
    14. Applied associate-/l*14.8

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

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

    if 3.593830924265355e-35 < b

    1. Initial program 55.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 6.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.8920328608199634 \cdot 10^{82}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -3.3528823044057167 \cdot 10^{-206}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 3.593830924265355 \cdot 10^{-35}:\\ \;\;\;\;\frac{\left(a \cdot 3\right) \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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