Average Error: 34.3 → 10.3
Time: 5.9s
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.39290314529454019 \cdot 10^{111}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le -4.9276367402926466 \cdot 10^{-151}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.49923300867171427 \cdot 10^{153}:\\ \;\;\;\;\frac{\frac{1}{-1}}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{-\left(2 \cdot b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}{3 \cdot a}\\ \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.39290314529454019 \cdot 10^{111}:\\
\;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{-\left(2 \cdot b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r97233 = b;
        double r97234 = -r97233;
        double r97235 = r97233 * r97233;
        double r97236 = 3.0;
        double r97237 = a;
        double r97238 = r97236 * r97237;
        double r97239 = c;
        double r97240 = r97238 * r97239;
        double r97241 = r97235 - r97240;
        double r97242 = sqrt(r97241);
        double r97243 = r97234 + r97242;
        double r97244 = r97243 / r97238;
        return r97244;
}

double f(double a, double b, double c) {
        double r97245 = b;
        double r97246 = -2.3929031452945402e+111;
        bool r97247 = r97245 <= r97246;
        double r97248 = 1.5;
        double r97249 = a;
        double r97250 = c;
        double r97251 = r97249 * r97250;
        double r97252 = r97251 / r97245;
        double r97253 = r97248 * r97252;
        double r97254 = 2.0;
        double r97255 = r97254 * r97245;
        double r97256 = r97253 - r97255;
        double r97257 = 3.0;
        double r97258 = r97257 * r97249;
        double r97259 = r97256 / r97258;
        double r97260 = -4.9276367402926466e-151;
        bool r97261 = r97245 <= r97260;
        double r97262 = -r97245;
        double r97263 = r97245 * r97245;
        double r97264 = r97258 * r97250;
        double r97265 = r97263 - r97264;
        double r97266 = sqrt(r97265);
        double r97267 = sqrt(r97266);
        double r97268 = cbrt(r97265);
        double r97269 = fabs(r97268);
        double r97270 = sqrt(r97268);
        double r97271 = r97269 * r97270;
        double r97272 = sqrt(r97271);
        double r97273 = r97267 * r97272;
        double r97274 = r97262 + r97273;
        double r97275 = r97274 / r97258;
        double r97276 = 1.4992330086717143e+153;
        bool r97277 = r97245 <= r97276;
        double r97278 = 1.0;
        double r97279 = -r97278;
        double r97280 = r97278 / r97279;
        double r97281 = r97245 + r97266;
        double r97282 = r97281 / r97250;
        double r97283 = r97280 / r97282;
        double r97284 = 0.0;
        double r97285 = r97284 + r97264;
        double r97286 = r97255 - r97253;
        double r97287 = -r97286;
        double r97288 = r97285 / r97287;
        double r97289 = r97288 / r97258;
        double r97290 = r97277 ? r97283 : r97289;
        double r97291 = r97261 ? r97275 : r97290;
        double r97292 = r97247 ? r97259 : r97291;
        return r97292;
}

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.3929031452945402e+111

    1. Initial program 49.3

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

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

    if -2.3929031452945402e+111 < b < -4.9276367402926466e-151

    1. Initial program 6.6

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

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

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

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

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

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

    if -4.9276367402926466e-151 < b < 1.4992330086717143e+153

    1. Initial program 30.4

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

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

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

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

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

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

      \[\leadsto \frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{-\color{blue}{1 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    11. Applied distribute-lft-neg-in15.6

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

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

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

      \[\leadsto \frac{\frac{1}{-1} \cdot \color{blue}{\frac{3 \cdot a}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}}}{3 \cdot a}\]
    15. Using strategy rm
    16. Applied associate-/l*14.1

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

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

    if 1.4992330086717143e+153 < b

    1. Initial program 63.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 add-sqr-sqrt63.9

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

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

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

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

      \[\leadsto \frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{\color{blue}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    9. Taylor expanded around inf 15.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.39290314529454019 \cdot 10^{111}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le -4.9276367402926466 \cdot 10^{-151}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.49923300867171427 \cdot 10^{153}:\\ \;\;\;\;\frac{\frac{1}{-1}}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{-\left(2 \cdot b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}{3 \cdot a}\\ \end{array}\]

Reproduce

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