Average Error: 34.5 → 10.3
Time: 18.4s
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.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{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 -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4700392 = b;
        double r4700393 = -r4700392;
        double r4700394 = r4700392 * r4700392;
        double r4700395 = 3.0;
        double r4700396 = a;
        double r4700397 = r4700395 * r4700396;
        double r4700398 = c;
        double r4700399 = r4700397 * r4700398;
        double r4700400 = r4700394 - r4700399;
        double r4700401 = sqrt(r4700400);
        double r4700402 = r4700393 + r4700401;
        double r4700403 = r4700402 / r4700397;
        return r4700403;
}

double f(double a, double b, double c) {
        double r4700404 = b;
        double r4700405 = -1.7633154797394035e+89;
        bool r4700406 = r4700404 <= r4700405;
        double r4700407 = 0.5;
        double r4700408 = c;
        double r4700409 = r4700408 / r4700404;
        double r4700410 = r4700407 * r4700409;
        double r4700411 = a;
        double r4700412 = r4700404 / r4700411;
        double r4700413 = 0.6666666666666666;
        double r4700414 = r4700412 * r4700413;
        double r4700415 = r4700410 - r4700414;
        double r4700416 = 9.136492990928292e-23;
        bool r4700417 = r4700404 <= r4700416;
        double r4700418 = r4700404 * r4700404;
        double r4700419 = 3.0;
        double r4700420 = r4700419 * r4700411;
        double r4700421 = r4700420 * r4700408;
        double r4700422 = r4700418 - r4700421;
        double r4700423 = sqrt(r4700422);
        double r4700424 = r4700423 - r4700404;
        double r4700425 = r4700424 / r4700419;
        double r4700426 = r4700425 / r4700411;
        double r4700427 = -0.5;
        double r4700428 = r4700427 * r4700409;
        double r4700429 = r4700417 ? r4700426 : r4700428;
        double r4700430 = r4700406 ? r4700415 : r4700429;
        return r4700430;
}

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 < -1.7633154797394035e+89

    1. Initial program 45.8

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

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

    if -1.7633154797394035e+89 < b < 9.136492990928292e-23

    1. Initial program 15.1

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

      \[\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 associate-/r*15.2

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

    if 9.136492990928292e-23 < b

    1. Initial program 55.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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