Average Error: 34.6 → 10.7
Time: 28.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 -2.766818940874854722177248139872145176232 \cdot 10^{100}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 7.923524897992036987166355557663274472861 \cdot 10^{-153}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 3} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \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.766818940874854722177248139872145176232 \cdot 10^{100}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r5567338 = b;
        double r5567339 = -r5567338;
        double r5567340 = r5567338 * r5567338;
        double r5567341 = 3.0;
        double r5567342 = a;
        double r5567343 = r5567341 * r5567342;
        double r5567344 = c;
        double r5567345 = r5567343 * r5567344;
        double r5567346 = r5567340 - r5567345;
        double r5567347 = sqrt(r5567346);
        double r5567348 = r5567339 + r5567347;
        double r5567349 = r5567348 / r5567343;
        return r5567349;
}

double f(double a, double b, double c) {
        double r5567350 = b;
        double r5567351 = -2.7668189408748547e+100;
        bool r5567352 = r5567350 <= r5567351;
        double r5567353 = 0.5;
        double r5567354 = c;
        double r5567355 = r5567354 / r5567350;
        double r5567356 = r5567353 * r5567355;
        double r5567357 = 0.6666666666666666;
        double r5567358 = a;
        double r5567359 = r5567350 / r5567358;
        double r5567360 = r5567357 * r5567359;
        double r5567361 = r5567356 - r5567360;
        double r5567362 = 7.923524897992037e-153;
        bool r5567363 = r5567350 <= r5567362;
        double r5567364 = r5567350 * r5567350;
        double r5567365 = r5567358 * r5567354;
        double r5567366 = 3.0;
        double r5567367 = r5567365 * r5567366;
        double r5567368 = r5567364 - r5567367;
        double r5567369 = sqrt(r5567368);
        double r5567370 = r5567369 - r5567350;
        double r5567371 = r5567370 / r5567366;
        double r5567372 = r5567371 / r5567358;
        double r5567373 = -0.5;
        double r5567374 = r5567355 * r5567373;
        double r5567375 = r5567363 ? r5567372 : r5567374;
        double r5567376 = r5567352 ? r5567361 : r5567375;
        return r5567376;
}

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.7668189408748547e+100

    1. Initial program 47.2

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

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

    if -2.7668189408748547e+100 < b < 7.923524897992037e-153

    1. Initial program 10.9

      \[\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*11.0

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

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

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

    if 7.923524897992037e-153 < b

    1. Initial program 50.5

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

      \[\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.766818940874854722177248139872145176232 \cdot 10^{100}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 7.923524897992036987166355557663274472861 \cdot 10^{-153}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 3} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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