Average Error: 33.7 → 10.2
Time: 20.8s
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 -4.00811574602446 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 1.509873637702203 \cdot 10^{-80}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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 -4.00811574602446 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2698348 = b;
        double r2698349 = -r2698348;
        double r2698350 = r2698348 * r2698348;
        double r2698351 = 3.0;
        double r2698352 = a;
        double r2698353 = r2698351 * r2698352;
        double r2698354 = c;
        double r2698355 = r2698353 * r2698354;
        double r2698356 = r2698350 - r2698355;
        double r2698357 = sqrt(r2698356);
        double r2698358 = r2698349 + r2698357;
        double r2698359 = r2698358 / r2698353;
        return r2698359;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2698360 = b;
        double r2698361 = -4.00811574602446e+153;
        bool r2698362 = r2698360 <= r2698361;
        double r2698363 = 0.5;
        double r2698364 = c;
        double r2698365 = r2698364 / r2698360;
        double r2698366 = r2698363 * r2698365;
        double r2698367 = a;
        double r2698368 = r2698360 / r2698367;
        double r2698369 = 0.6666666666666666;
        double r2698370 = r2698368 * r2698369;
        double r2698371 = r2698366 - r2698370;
        double r2698372 = 1.509873637702203e-80;
        bool r2698373 = r2698360 <= r2698372;
        double r2698374 = r2698360 * r2698360;
        double r2698375 = 3.0;
        double r2698376 = r2698375 * r2698367;
        double r2698377 = r2698376 * r2698364;
        double r2698378 = r2698374 - r2698377;
        double r2698379 = sqrt(r2698378);
        double r2698380 = r2698379 - r2698360;
        double r2698381 = r2698380 / r2698376;
        double r2698382 = -0.5;
        double r2698383 = r2698382 * r2698365;
        double r2698384 = r2698373 ? r2698381 : r2698383;
        double r2698385 = r2698362 ? r2698371 : r2698384;
        return r2698385;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -4.00811574602446e+153

    1. Initial program 60.6

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

      \[\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.9

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b} - \frac{2}{3} \cdot \frac{b}{a}}\]

    if -4.00811574602446e+153 < b < 1.509873637702203e-80

    1. Initial program 12.4

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

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

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

    if 1.509873637702203e-80 < b

    1. Initial program 52.5

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

      \[\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 *-un-lft-identity52.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.00811574602446 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 1.509873637702203 \cdot 10^{-80}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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