Average Error: 33.2 → 9.8
Time: 21.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 -6.4005968496310915 \cdot 10^{+124}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 7.6551553616209435 \cdot 10^{-56}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}}{3}\\ \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 -6.4005968496310915 \cdot 10^{+124}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3254348 = b;
        double r3254349 = -r3254348;
        double r3254350 = r3254348 * r3254348;
        double r3254351 = 3.0;
        double r3254352 = a;
        double r3254353 = r3254351 * r3254352;
        double r3254354 = c;
        double r3254355 = r3254353 * r3254354;
        double r3254356 = r3254350 - r3254355;
        double r3254357 = sqrt(r3254356);
        double r3254358 = r3254349 + r3254357;
        double r3254359 = r3254358 / r3254353;
        return r3254359;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3254360 = b;
        double r3254361 = -6.4005968496310915e+124;
        bool r3254362 = r3254360 <= r3254361;
        double r3254363 = 0.5;
        double r3254364 = c;
        double r3254365 = r3254364 / r3254360;
        double r3254366 = r3254363 * r3254365;
        double r3254367 = a;
        double r3254368 = r3254360 / r3254367;
        double r3254369 = 0.6666666666666666;
        double r3254370 = r3254368 * r3254369;
        double r3254371 = r3254366 - r3254370;
        double r3254372 = 7.6551553616209435e-56;
        bool r3254373 = r3254360 <= r3254372;
        double r3254374 = r3254360 * r3254360;
        double r3254375 = 3.0;
        double r3254376 = r3254375 * r3254367;
        double r3254377 = r3254376 * r3254364;
        double r3254378 = r3254374 - r3254377;
        double r3254379 = sqrt(r3254378);
        double r3254380 = r3254379 - r3254360;
        double r3254381 = r3254380 / r3254367;
        double r3254382 = r3254381 / r3254375;
        double r3254383 = -0.5;
        double r3254384 = r3254383 * r3254365;
        double r3254385 = r3254373 ? r3254382 : r3254384;
        double r3254386 = r3254362 ? r3254371 : r3254385;
        return r3254386;
}

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 < -6.4005968496310915e+124

    1. Initial program 49.8

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

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

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

    if -6.4005968496310915e+124 < b < 7.6551553616209435e-56

    1. Initial program 12.7

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

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

      \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \color{blue}{1 \cdot b}}{3 \cdot a}\]
    5. Applied *-un-lft-identity12.7

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} - 1 \cdot b}{3 \cdot a}\]
    6. Applied distribute-lft-out--12.7

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}}\]
    8. Using strategy rm
    9. Applied associate-*l/12.7

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

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

    if 7.6551553616209435e-56 < b

    1. Initial program 53.1

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

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

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

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

Reproduce

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