Average Error: 33.9 → 8.9
Time: 10.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 -4.2673012400424376 \cdot 10^{128}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.2257887393429622 \cdot 10^{-183}:\\ \;\;\;\;\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 1.0646128438355895 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{\frac{3 \cdot \left(a \cdot c\right)}{3}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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.2673012400424376 \cdot 10^{128}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 2.2257887393429622 \cdot 10^{-183}:\\
\;\;\;\;\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 1.0646128438355895 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{\frac{3 \cdot \left(a \cdot c\right)}{3}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r99298 = b;
        double r99299 = -r99298;
        double r99300 = r99298 * r99298;
        double r99301 = 3.0;
        double r99302 = a;
        double r99303 = r99301 * r99302;
        double r99304 = c;
        double r99305 = r99303 * r99304;
        double r99306 = r99300 - r99305;
        double r99307 = sqrt(r99306);
        double r99308 = r99299 + r99307;
        double r99309 = r99308 / r99303;
        return r99309;
}

double f(double a, double b, double c) {
        double r99310 = b;
        double r99311 = -4.2673012400424376e+128;
        bool r99312 = r99310 <= r99311;
        double r99313 = 0.5;
        double r99314 = c;
        double r99315 = r99314 / r99310;
        double r99316 = r99313 * r99315;
        double r99317 = 0.6666666666666666;
        double r99318 = a;
        double r99319 = r99310 / r99318;
        double r99320 = r99317 * r99319;
        double r99321 = r99316 - r99320;
        double r99322 = 2.225788739342962e-183;
        bool r99323 = r99310 <= r99322;
        double r99324 = -r99310;
        double r99325 = r99310 * r99310;
        double r99326 = 3.0;
        double r99327 = r99326 * r99318;
        double r99328 = r99327 * r99314;
        double r99329 = r99325 - r99328;
        double r99330 = sqrt(r99329);
        double r99331 = r99324 + r99330;
        double r99332 = 1.0;
        double r99333 = r99332 / r99327;
        double r99334 = r99331 * r99333;
        double r99335 = 1.0646128438355895e-10;
        bool r99336 = r99310 <= r99335;
        double r99337 = r99318 * r99314;
        double r99338 = r99326 * r99337;
        double r99339 = r99338 / r99326;
        double r99340 = r99324 - r99330;
        double r99341 = r99339 / r99340;
        double r99342 = r99341 / r99318;
        double r99343 = -0.5;
        double r99344 = r99343 * r99315;
        double r99345 = r99336 ? r99342 : r99344;
        double r99346 = r99323 ? r99334 : r99345;
        double r99347 = r99312 ? r99321 : r99346;
        return r99347;
}

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 < -4.2673012400424376e+128

    1. Initial program 54.1

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

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

    if -4.2673012400424376e+128 < b < 2.225788739342962e-183

    1. Initial program 10.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 div-inv10.2

      \[\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 2.225788739342962e-183 < b < 1.0646128438355895e-10

    1. Initial program 30.0

      \[\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-+30.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. Simplified19.3

      \[\leadsto \frac{\frac{\color{blue}{b \cdot \left(b - b\right) + 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 associate-/r*19.2

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

      \[\leadsto \frac{\color{blue}{\frac{3 \cdot \left(a \cdot c\right) + 0}{3 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{a}\]
    8. Using strategy rm
    9. Applied associate-/r*19.2

      \[\leadsto \frac{\color{blue}{\frac{\frac{3 \cdot \left(a \cdot c\right) + 0}{3}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{a}\]
    10. Simplified19.2

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

    if 1.0646128438355895e-10 < b

    1. Initial program 55.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.2673012400424376 \cdot 10^{128}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.2257887393429622 \cdot 10^{-183}:\\ \;\;\;\;\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 1.0646128438355895 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{\frac{3 \cdot \left(a \cdot c\right)}{3}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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