Average Error: 34.8 → 9.3
Time: 6.2s
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 -9.19678115322534318 \cdot 10^{150}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 5.0355868398843843 \cdot 10^{-134}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 8.0911772821281571 \cdot 10^{46}:\\ \;\;\;\;\frac{\frac{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}\\ \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 -9.19678115322534318 \cdot 10^{150}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 8.0911772821281571 \cdot 10^{46}:\\
\;\;\;\;\frac{\frac{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}\\

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

\end{array}
double f(double a, double b, double c) {
        double r130097 = b;
        double r130098 = -r130097;
        double r130099 = r130097 * r130097;
        double r130100 = 3.0;
        double r130101 = a;
        double r130102 = r130100 * r130101;
        double r130103 = c;
        double r130104 = r130102 * r130103;
        double r130105 = r130099 - r130104;
        double r130106 = sqrt(r130105);
        double r130107 = r130098 + r130106;
        double r130108 = r130107 / r130102;
        return r130108;
}

double f(double a, double b, double c) {
        double r130109 = b;
        double r130110 = -9.196781153225343e+150;
        bool r130111 = r130109 <= r130110;
        double r130112 = 0.5;
        double r130113 = c;
        double r130114 = r130113 / r130109;
        double r130115 = r130112 * r130114;
        double r130116 = 0.6666666666666666;
        double r130117 = a;
        double r130118 = r130109 / r130117;
        double r130119 = r130116 * r130118;
        double r130120 = r130115 - r130119;
        double r130121 = 5.035586839884384e-134;
        bool r130122 = r130109 <= r130121;
        double r130123 = -r130109;
        double r130124 = r130109 * r130109;
        double r130125 = 3.0;
        double r130126 = r130125 * r130117;
        double r130127 = r130126 * r130113;
        double r130128 = r130124 - r130127;
        double r130129 = sqrt(r130128);
        double r130130 = r130123 + r130129;
        double r130131 = r130130 / r130125;
        double r130132 = r130131 / r130117;
        double r130133 = 8.091177282128157e+46;
        bool r130134 = r130109 <= r130133;
        double r130135 = 0.0;
        double r130136 = r130117 * r130113;
        double r130137 = r130125 * r130136;
        double r130138 = r130135 + r130137;
        double r130139 = r130123 - r130129;
        double r130140 = r130138 / r130139;
        double r130141 = r130140 / r130126;
        double r130142 = -0.5;
        double r130143 = r130142 * r130114;
        double r130144 = r130134 ? r130141 : r130143;
        double r130145 = r130122 ? r130132 : r130144;
        double r130146 = r130111 ? r130120 : r130145;
        return r130146;
}

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 < -9.196781153225343e+150

    1. Initial program 62.9

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

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

    if -9.196781153225343e+150 < b < 5.035586839884384e-134

    1. Initial program 11.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 associate-/r*11.6

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

    if 5.035586839884384e-134 < b < 8.091177282128157e+46

    1. Initial program 37.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-+37.0

      \[\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.8

      \[\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}\]

    if 8.091177282128157e+46 < b

    1. Initial program 56.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -9.19678115322534318 \cdot 10^{150}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 5.0355868398843843 \cdot 10^{-134}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 8.0911772821281571 \cdot 10^{46}:\\ \;\;\;\;\frac{\frac{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}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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