Average Error: 34.2 → 10.0
Time: 5.3s
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.4052299045085703 \cdot 10^{151}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 1.2529910715609764 \cdot 10^{-90}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{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.4052299045085703 \cdot 10^{151}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r122595 = b;
        double r122596 = -r122595;
        double r122597 = r122595 * r122595;
        double r122598 = 3.0;
        double r122599 = a;
        double r122600 = r122598 * r122599;
        double r122601 = c;
        double r122602 = r122600 * r122601;
        double r122603 = r122597 - r122602;
        double r122604 = sqrt(r122603);
        double r122605 = r122596 + r122604;
        double r122606 = r122605 / r122600;
        return r122606;
}

double f(double a, double b, double c) {
        double r122607 = b;
        double r122608 = -1.4052299045085703e+151;
        bool r122609 = r122607 <= r122608;
        double r122610 = 0.5;
        double r122611 = c;
        double r122612 = r122611 / r122607;
        double r122613 = r122610 * r122612;
        double r122614 = 0.6666666666666666;
        double r122615 = a;
        double r122616 = r122607 / r122615;
        double r122617 = r122614 * r122616;
        double r122618 = r122613 - r122617;
        double r122619 = 1.2529910715609764e-90;
        bool r122620 = r122607 <= r122619;
        double r122621 = -r122607;
        double r122622 = r122607 * r122607;
        double r122623 = 3.0;
        double r122624 = r122623 * r122615;
        double r122625 = r122624 * r122611;
        double r122626 = r122622 - r122625;
        double r122627 = sqrt(r122626);
        double r122628 = r122621 + r122627;
        double r122629 = r122628 / r122624;
        double r122630 = -0.5;
        double r122631 = r122630 * r122612;
        double r122632 = r122620 ? r122629 : r122631;
        double r122633 = r122609 ? r122618 : r122632;
        return r122633;
}

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.4052299045085703e+151

    1. Initial program 63.1

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

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

    if -1.4052299045085703e+151 < b < 1.2529910715609764e-90

    1. Initial program 12.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*12.2

      \[\leadsto \color{blue}{\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv12.3

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

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

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

    if 1.2529910715609764e-90 < 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. Taylor expanded around inf 9.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.4052299045085703 \cdot 10^{151}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 1.2529910715609764 \cdot 10^{-90}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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