Average Error: 33.5 → 9.9
Time: 11.2s
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 -1.269895755919419994119426060411821031835 \cdot 10^{99}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 5.480131987291899458594157601719520740479 \cdot 10^{-168}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{elif}\;b \le 6.194358139220983814753525365719850242403 \cdot 10^{-110} \lor \neg \left(b \le 39737576445817151488\right):\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \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 -1.269895755919419994119426060411821031835 \cdot 10^{99}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 6.194358139220983814753525365719850242403 \cdot 10^{-110} \lor \neg \left(b \le 39737576445817151488\right):\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r101430 = b;
        double r101431 = -r101430;
        double r101432 = r101430 * r101430;
        double r101433 = 3.0;
        double r101434 = a;
        double r101435 = r101433 * r101434;
        double r101436 = c;
        double r101437 = r101435 * r101436;
        double r101438 = r101432 - r101437;
        double r101439 = sqrt(r101438);
        double r101440 = r101431 + r101439;
        double r101441 = r101440 / r101435;
        return r101441;
}

double f(double a, double b, double c) {
        double r101442 = b;
        double r101443 = -1.26989575591942e+99;
        bool r101444 = r101442 <= r101443;
        double r101445 = 0.5;
        double r101446 = c;
        double r101447 = r101446 / r101442;
        double r101448 = r101445 * r101447;
        double r101449 = 0.6666666666666666;
        double r101450 = a;
        double r101451 = r101442 / r101450;
        double r101452 = r101449 * r101451;
        double r101453 = r101448 - r101452;
        double r101454 = 5.480131987291899e-168;
        bool r101455 = r101442 <= r101454;
        double r101456 = -r101442;
        double r101457 = r101442 * r101442;
        double r101458 = 3.0;
        double r101459 = r101458 * r101450;
        double r101460 = r101459 * r101446;
        double r101461 = r101457 - r101460;
        double r101462 = sqrt(r101461);
        double r101463 = r101456 + r101462;
        double r101464 = 1.0;
        double r101465 = r101464 / r101459;
        double r101466 = r101463 * r101465;
        double r101467 = 6.194358139220984e-110;
        bool r101468 = r101442 <= r101467;
        double r101469 = 3.973757644581715e+19;
        bool r101470 = r101442 <= r101469;
        double r101471 = !r101470;
        bool r101472 = r101468 || r101471;
        double r101473 = -0.5;
        double r101474 = r101473 * r101447;
        double r101475 = r101456 - r101462;
        double r101476 = r101460 / r101475;
        double r101477 = r101476 / r101459;
        double r101478 = r101472 ? r101474 : r101477;
        double r101479 = r101455 ? r101466 : r101478;
        double r101480 = r101444 ? r101453 : r101479;
        return r101480;
}

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 < -1.26989575591942e+99

    1. Initial program 46.5

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

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

    if -1.26989575591942e+99 < b < 5.480131987291899e-168

    1. Initial program 10.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv10.4

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

    if 5.480131987291899e-168 < b < 6.194358139220984e-110 or 3.973757644581715e+19 < b

    1. Initial program 52.0

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

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

    if 6.194358139220984e-110 < b < 3.973757644581715e+19

    1. Initial program 37.3

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

      \[\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. Simplified16.2

      \[\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}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.269895755919419994119426060411821031835 \cdot 10^{99}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 5.480131987291899458594157601719520740479 \cdot 10^{-168}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{elif}\;b \le 6.194358139220983814753525365719850242403 \cdot 10^{-110} \lor \neg \left(b \le 39737576445817151488\right):\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019350 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))