Average Error: 34.5 → 10.0
Time: 5.1s
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.9873231593168173 \cdot 10^{152}:\\ \;\;\;\;1 \cdot \left(0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 5.9988552372996083 \cdot 10^{-44}:\\ \;\;\;\;1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \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.9873231593168173 \cdot 10^{152}:\\
\;\;\;\;1 \cdot \left(0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\right)\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r92385 = b;
        double r92386 = -r92385;
        double r92387 = r92385 * r92385;
        double r92388 = 3.0;
        double r92389 = a;
        double r92390 = r92388 * r92389;
        double r92391 = c;
        double r92392 = r92390 * r92391;
        double r92393 = r92387 - r92392;
        double r92394 = sqrt(r92393);
        double r92395 = r92386 + r92394;
        double r92396 = r92395 / r92390;
        return r92396;
}

double f(double a, double b, double c) {
        double r92397 = b;
        double r92398 = -4.987323159316817e+152;
        bool r92399 = r92397 <= r92398;
        double r92400 = 1.0;
        double r92401 = 0.5;
        double r92402 = c;
        double r92403 = r92402 / r92397;
        double r92404 = r92401 * r92403;
        double r92405 = 0.6666666666666666;
        double r92406 = a;
        double r92407 = r92397 / r92406;
        double r92408 = r92405 * r92407;
        double r92409 = r92404 - r92408;
        double r92410 = r92400 * r92409;
        double r92411 = 5.998855237299608e-44;
        bool r92412 = r92397 <= r92411;
        double r92413 = -r92397;
        double r92414 = r92397 * r92397;
        double r92415 = 3.0;
        double r92416 = r92415 * r92406;
        double r92417 = r92416 * r92402;
        double r92418 = r92414 - r92417;
        double r92419 = sqrt(r92418);
        double r92420 = r92413 + r92419;
        double r92421 = r92420 / r92416;
        double r92422 = r92400 * r92421;
        double r92423 = -0.5;
        double r92424 = r92423 * r92403;
        double r92425 = r92412 ? r92422 : r92424;
        double r92426 = r92399 ? r92410 : r92425;
        return r92426;
}

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 3 regimes
  2. if b < -4.987323159316817e+152

    1. Initial program 63.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 *-un-lft-identity63.3

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

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

    if -4.987323159316817e+152 < b < 5.998855237299608e-44

    1. Initial program 13.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 *-un-lft-identity13.4

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

    if 5.998855237299608e-44 < b

    1. Initial program 54.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.9873231593168173 \cdot 10^{152}:\\ \;\;\;\;1 \cdot \left(0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 5.9988552372996083 \cdot 10^{-44}:\\ \;\;\;\;1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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