Average Error: 34.3 → 9.6
Time: 15.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 -1.37605735163161503900554889908006052105 \cdot 10^{138}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 4.626043257219637986942022736183111936335 \cdot 10^{-62}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3 \cdot 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.37605735163161503900554889908006052105 \cdot 10^{138}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4178488 = b;
        double r4178489 = -r4178488;
        double r4178490 = r4178488 * r4178488;
        double r4178491 = 3.0;
        double r4178492 = a;
        double r4178493 = r4178491 * r4178492;
        double r4178494 = c;
        double r4178495 = r4178493 * r4178494;
        double r4178496 = r4178490 - r4178495;
        double r4178497 = sqrt(r4178496);
        double r4178498 = r4178489 + r4178497;
        double r4178499 = r4178498 / r4178493;
        return r4178499;
}

double f(double a, double b, double c) {
        double r4178500 = b;
        double r4178501 = -1.376057351631615e+138;
        bool r4178502 = r4178500 <= r4178501;
        double r4178503 = 0.5;
        double r4178504 = c;
        double r4178505 = r4178504 / r4178500;
        double r4178506 = r4178503 * r4178505;
        double r4178507 = a;
        double r4178508 = r4178500 / r4178507;
        double r4178509 = 0.6666666666666666;
        double r4178510 = r4178508 * r4178509;
        double r4178511 = r4178506 - r4178510;
        double r4178512 = 4.626043257219638e-62;
        bool r4178513 = r4178500 <= r4178512;
        double r4178514 = r4178500 * r4178500;
        double r4178515 = 3.0;
        double r4178516 = r4178504 * r4178515;
        double r4178517 = r4178507 * r4178516;
        double r4178518 = r4178514 - r4178517;
        double r4178519 = sqrt(r4178518);
        double r4178520 = r4178519 - r4178500;
        double r4178521 = r4178515 * r4178507;
        double r4178522 = r4178520 / r4178521;
        double r4178523 = -0.5;
        double r4178524 = r4178523 * r4178505;
        double r4178525 = r4178513 ? r4178522 : r4178524;
        double r4178526 = r4178502 ? r4178511 : r4178525;
        return r4178526;
}

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.376057351631615e+138

    1. Initial program 58.4

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

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

    if -1.376057351631615e+138 < b < 4.626043257219638e-62

    1. Initial program 12.3

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b\right) \cdot \frac{1}{3 \cdot a}}\]
    5. Using strategy rm
    6. Applied associate-*r/12.3

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

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

    if 4.626043257219638e-62 < b

    1. Initial program 53.7

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

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

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

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

Reproduce

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