Average Error: 33.8 → 8.8
Time: 17.8s
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 -2.847204280282031663920354805138023860461 \cdot 10^{48}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 3.246218444991030358555013112397707766315 \cdot 10^{-248}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 4.265883575317037501760620997399796494232 \cdot 10^{111}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{3 \cdot a}}{\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 -2.847204280282031663920354805138023860461 \cdot 10^{48}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 4.265883575317037501760620997399796494232 \cdot 10^{111}:\\
\;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{3 \cdot a}}{\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 r96996 = b;
        double r96997 = -r96996;
        double r96998 = r96996 * r96996;
        double r96999 = 3.0;
        double r97000 = a;
        double r97001 = r96999 * r97000;
        double r97002 = c;
        double r97003 = r97001 * r97002;
        double r97004 = r96998 - r97003;
        double r97005 = sqrt(r97004);
        double r97006 = r96997 + r97005;
        double r97007 = r97006 / r97001;
        return r97007;
}

double f(double a, double b, double c) {
        double r97008 = b;
        double r97009 = -2.8472042802820317e+48;
        bool r97010 = r97008 <= r97009;
        double r97011 = 0.5;
        double r97012 = c;
        double r97013 = r97012 / r97008;
        double r97014 = r97011 * r97013;
        double r97015 = 0.6666666666666666;
        double r97016 = a;
        double r97017 = r97008 / r97016;
        double r97018 = r97015 * r97017;
        double r97019 = r97014 - r97018;
        double r97020 = 3.2462184449910304e-248;
        bool r97021 = r97008 <= r97020;
        double r97022 = 1.0;
        double r97023 = 3.0;
        double r97024 = r97023 * r97016;
        double r97025 = r97008 * r97008;
        double r97026 = r97024 * r97012;
        double r97027 = r97025 - r97026;
        double r97028 = sqrt(r97027);
        double r97029 = r97028 - r97008;
        double r97030 = r97024 / r97029;
        double r97031 = r97022 / r97030;
        double r97032 = 4.2658835753170375e+111;
        bool r97033 = r97008 <= r97032;
        double r97034 = r97012 * r97024;
        double r97035 = r97034 / r97024;
        double r97036 = -r97008;
        double r97037 = r97036 - r97028;
        double r97038 = r97035 / r97037;
        double r97039 = -0.5;
        double r97040 = r97039 * r97013;
        double r97041 = r97033 ? r97038 : r97040;
        double r97042 = r97021 ? r97031 : r97041;
        double r97043 = r97010 ? r97019 : r97042;
        return r97043;
}

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 < -2.8472042802820317e+48

    1. Initial program 38.2

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

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

    if -2.8472042802820317e+48 < b < 3.2462184449910304e-248

    1. Initial program 10.7

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

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

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

    if 3.2462184449910304e-248 < b < 4.2658835753170375e+111

    1. Initial program 34.1

      \[\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-+34.1

      \[\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. Simplified15.6

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

      \[\leadsto \color{blue}{\frac{0 + \left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \frac{1}{3 \cdot a}}\]
    7. Using strategy rm
    8. Applied pow115.6

      \[\leadsto \frac{0 + \left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \color{blue}{{\left(\frac{1}{3 \cdot a}\right)}^{1}}\]
    9. Applied pow115.6

      \[\leadsto \color{blue}{{\left(\frac{0 + \left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right)}^{1}} \cdot {\left(\frac{1}{3 \cdot a}\right)}^{1}\]
    10. Applied pow-prod-down15.6

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

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

    if 4.2658835753170375e+111 < b

    1. Initial program 59.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.847204280282031663920354805138023860461 \cdot 10^{48}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 3.246218444991030358555013112397707766315 \cdot 10^{-248}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 4.265883575317037501760620997399796494232 \cdot 10^{111}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{3 \cdot a}}{\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 2019212 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))