Average Error: 33.1 → 10.5
Time: 17.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.343328406152013 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 3.7535994007355634 \cdot 10^{-122}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{a \cdot 3} - \frac{b}{a \cdot 3}\\ \mathbf{elif}\;b \le 4.020455841328689 \cdot 10^{-79}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 3.5051690294214705 \cdot 10^{-69}:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\sqrt[3]{3}}}{a}\\ \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 -1.343328406152013 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

\mathbf{elif}\;b \le 4.020455841328689 \cdot 10^{-79}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4643531 = b;
        double r4643532 = -r4643531;
        double r4643533 = r4643531 * r4643531;
        double r4643534 = 3.0;
        double r4643535 = a;
        double r4643536 = r4643534 * r4643535;
        double r4643537 = c;
        double r4643538 = r4643536 * r4643537;
        double r4643539 = r4643533 - r4643538;
        double r4643540 = sqrt(r4643539);
        double r4643541 = r4643532 + r4643540;
        double r4643542 = r4643541 / r4643536;
        return r4643542;
}

double f(double a, double b, double c) {
        double r4643543 = b;
        double r4643544 = -1.343328406152013e+154;
        bool r4643545 = r4643543 <= r4643544;
        double r4643546 = 0.5;
        double r4643547 = c;
        double r4643548 = r4643547 / r4643543;
        double r4643549 = r4643546 * r4643548;
        double r4643550 = a;
        double r4643551 = r4643543 / r4643550;
        double r4643552 = 0.6666666666666666;
        double r4643553 = r4643551 * r4643552;
        double r4643554 = r4643549 - r4643553;
        double r4643555 = 3.7535994007355634e-122;
        bool r4643556 = r4643543 <= r4643555;
        double r4643557 = r4643543 * r4643543;
        double r4643558 = 3.0;
        double r4643559 = r4643550 * r4643558;
        double r4643560 = r4643547 * r4643559;
        double r4643561 = r4643557 - r4643560;
        double r4643562 = sqrt(r4643561);
        double r4643563 = r4643562 / r4643559;
        double r4643564 = r4643543 / r4643559;
        double r4643565 = r4643563 - r4643564;
        double r4643566 = 4.020455841328689e-79;
        bool r4643567 = r4643543 <= r4643566;
        double r4643568 = -0.5;
        double r4643569 = r4643568 * r4643548;
        double r4643570 = 3.5051690294214705e-69;
        bool r4643571 = r4643543 <= r4643570;
        double r4643572 = r4643547 * r4643550;
        double r4643573 = r4643558 * r4643572;
        double r4643574 = r4643557 - r4643573;
        double r4643575 = sqrt(r4643574);
        double r4643576 = r4643575 - r4643543;
        double r4643577 = cbrt(r4643558);
        double r4643578 = r4643577 * r4643577;
        double r4643579 = r4643576 / r4643578;
        double r4643580 = r4643579 / r4643577;
        double r4643581 = r4643580 / r4643550;
        double r4643582 = r4643571 ? r4643581 : r4643569;
        double r4643583 = r4643567 ? r4643569 : r4643582;
        double r4643584 = r4643556 ? r4643565 : r4643583;
        double r4643585 = r4643545 ? r4643554 : r4643584;
        return r4643585;
}

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 < -1.343328406152013e+154

    1. Initial program 61.0

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

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

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

    if -1.343328406152013e+154 < b < 3.7535994007355634e-122

    1. Initial program 10.9

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

      \[\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-identity10.9

      \[\leadsto \color{blue}{1 \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    5. Using strategy rm
    6. Applied div-sub10.9

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

    if 3.7535994007355634e-122 < b < 4.020455841328689e-79 or 3.5051690294214705e-69 < b

    1. Initial program 50.7

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

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

    if 4.020455841328689e-79 < b < 3.5051690294214705e-69

    1. Initial program 37.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified37.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 associate-/r*37.6

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}}\]
    5. Using strategy rm
    6. Applied sub-neg37.6

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

      \[\leadsto \frac{\frac{\sqrt{b \cdot b + \color{blue}{-3 \cdot \left(a \cdot c\right)}} - b}{3}}{a}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt37.6

      \[\leadsto \frac{\frac{\sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)} - b}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}}{a}\]
    10. Applied associate-/r*37.6

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

      \[\leadsto \frac{\frac{\color{blue}{\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}}{\sqrt[3]{3}}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification10.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.343328406152013 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 3.7535994007355634 \cdot 10^{-122}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{a \cdot 3} - \frac{b}{a \cdot 3}\\ \mathbf{elif}\;b \le 4.020455841328689 \cdot 10^{-79}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 3.5051690294214705 \cdot 10^{-69}:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\sqrt[3]{3}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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