Average Error: 33.6 → 6.9
Time: 6.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 -4.0323767944871679 \cdot 10^{127}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -2.5112969209967258 \cdot 10^{-271}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 4.12298741547621415 \cdot 10^{92}:\\ \;\;\;\;\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot c\right) \cdot \frac{\sqrt[3]{1}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\\ \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 -4.0323767944871679 \cdot 10^{127}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 4.12298741547621415 \cdot 10^{92}:\\
\;\;\;\;\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot c\right) \cdot \frac{\sqrt[3]{1}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\\

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

\end{array}
double f(double a, double b, double c) {
        double r102524 = b;
        double r102525 = -r102524;
        double r102526 = r102524 * r102524;
        double r102527 = 3.0;
        double r102528 = a;
        double r102529 = r102527 * r102528;
        double r102530 = c;
        double r102531 = r102529 * r102530;
        double r102532 = r102526 - r102531;
        double r102533 = sqrt(r102532);
        double r102534 = r102525 + r102533;
        double r102535 = r102534 / r102529;
        return r102535;
}

double f(double a, double b, double c) {
        double r102536 = b;
        double r102537 = -4.032376794487168e+127;
        bool r102538 = r102536 <= r102537;
        double r102539 = 0.5;
        double r102540 = c;
        double r102541 = r102540 / r102536;
        double r102542 = r102539 * r102541;
        double r102543 = 0.6666666666666666;
        double r102544 = a;
        double r102545 = r102536 / r102544;
        double r102546 = r102543 * r102545;
        double r102547 = r102542 - r102546;
        double r102548 = -2.511296920996726e-271;
        bool r102549 = r102536 <= r102548;
        double r102550 = -r102536;
        double r102551 = r102536 * r102536;
        double r102552 = 3.0;
        double r102553 = r102552 * r102544;
        double r102554 = r102553 * r102540;
        double r102555 = r102551 - r102554;
        double r102556 = sqrt(r102555);
        double r102557 = r102550 + r102556;
        double r102558 = r102557 / r102552;
        double r102559 = r102558 / r102544;
        double r102560 = 4.122987415476214e+92;
        bool r102561 = r102536 <= r102560;
        double r102562 = 1.0;
        double r102563 = cbrt(r102562);
        double r102564 = r102563 * r102563;
        double r102565 = 1.0;
        double r102566 = r102564 / r102565;
        double r102567 = r102566 * r102540;
        double r102568 = r102550 - r102556;
        double r102569 = r102563 / r102568;
        double r102570 = r102567 * r102569;
        double r102571 = -0.5;
        double r102572 = r102571 * r102541;
        double r102573 = r102561 ? r102570 : r102572;
        double r102574 = r102549 ? r102559 : r102573;
        double r102575 = r102538 ? r102547 : r102574;
        return r102575;
}

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 4 regimes
  2. if b < -4.032376794487168e+127

    1. Initial program 53.2

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

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

    if -4.032376794487168e+127 < b < -2.511296920996726e-271

    1. Initial program 8.9

      \[\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*8.9

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

    if -2.511296920996726e-271 < b < 4.122987415476214e+92

    1. Initial program 30.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+30.6

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

      \[\leadsto \frac{\frac{\color{blue}{0 + 3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity16.5

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{1}}{\color{blue}{\frac{1}{c}} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}\]
    12. Using strategy rm
    13. Applied add-cube-cbrt9.5

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

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

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

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

    if 4.122987415476214e+92 < b

    1. Initial program 59.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.0323767944871679 \cdot 10^{127}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -2.5112969209967258 \cdot 10^{-271}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 4.12298741547621415 \cdot 10^{92}:\\ \;\;\;\;\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot c\right) \cdot \frac{\sqrt[3]{1}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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