Average Error: 33.8 → 7.0
Time: 5.4s
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 -8.86725877741104776 \cdot 10^{108}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.20299949522124904 \cdot 10^{-205}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.65606521985004176 \cdot 10^{131}:\\ \;\;\;\;\frac{c}{1} \cdot \frac{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 -8.86725877741104776 \cdot 10^{108}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 3.65606521985004176 \cdot 10^{131}:\\
\;\;\;\;\frac{c}{1} \cdot \frac{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 r118163 = b;
        double r118164 = -r118163;
        double r118165 = r118163 * r118163;
        double r118166 = 3.0;
        double r118167 = a;
        double r118168 = r118166 * r118167;
        double r118169 = c;
        double r118170 = r118168 * r118169;
        double r118171 = r118165 - r118170;
        double r118172 = sqrt(r118171);
        double r118173 = r118164 + r118172;
        double r118174 = r118173 / r118168;
        return r118174;
}

double f(double a, double b, double c) {
        double r118175 = b;
        double r118176 = -8.867258777411048e+108;
        bool r118177 = r118175 <= r118176;
        double r118178 = 0.5;
        double r118179 = c;
        double r118180 = r118179 / r118175;
        double r118181 = r118178 * r118180;
        double r118182 = 0.6666666666666666;
        double r118183 = a;
        double r118184 = r118175 / r118183;
        double r118185 = r118182 * r118184;
        double r118186 = r118181 - r118185;
        double r118187 = -1.202999495221249e-205;
        bool r118188 = r118175 <= r118187;
        double r118189 = -r118175;
        double r118190 = r118175 * r118175;
        double r118191 = 3.0;
        double r118192 = r118191 * r118183;
        double r118193 = r118192 * r118179;
        double r118194 = r118190 - r118193;
        double r118195 = sqrt(r118194);
        double r118196 = r118189 + r118195;
        double r118197 = 1.0;
        double r118198 = r118197 / r118192;
        double r118199 = r118196 * r118198;
        double r118200 = 3.656065219850042e+131;
        bool r118201 = r118175 <= r118200;
        double r118202 = 1.0;
        double r118203 = r118179 / r118202;
        double r118204 = r118189 - r118195;
        double r118205 = r118197 / r118204;
        double r118206 = r118203 * r118205;
        double r118207 = -0.5;
        double r118208 = r118207 * r118180;
        double r118209 = r118201 ? r118206 : r118208;
        double r118210 = r118188 ? r118199 : r118209;
        double r118211 = r118177 ? r118186 : r118210;
        return r118211;
}

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 < -8.867258777411048e+108

    1. Initial program 46.7

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

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

    if -8.867258777411048e+108 < b < -1.202999495221249e-205

    1. Initial program 7.3

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

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

    if -1.202999495221249e-205 < b < 3.656065219850042e+131

    1. Initial program 31.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 flip-+31.9

      \[\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. Simplified17.0

      \[\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 clear-num17.2

      \[\leadsto \color{blue}{\frac{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}}}}}\]
    7. Simplified16.2

      \[\leadsto \frac{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)}}\]
    8. Taylor expanded around 0 10.6

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

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

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

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

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

    if 3.656065219850042e+131 < b

    1. Initial program 61.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.86725877741104776 \cdot 10^{108}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.20299949522124904 \cdot 10^{-205}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.65606521985004176 \cdot 10^{131}:\\ \;\;\;\;\frac{c}{1} \cdot \frac{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 2020100 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))