Average Error: 34.3 → 8.1
Time: 6.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 -5.9551520595513616 \cdot 10^{118}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.53142763806062239 \cdot 10^{-259}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 5.3300268467023164 \cdot 10^{29}:\\ \;\;\;\;\frac{1 \cdot \frac{3}{\frac{1}{a} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{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 -5.9551520595513616 \cdot 10^{118}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r144232 = b;
        double r144233 = -r144232;
        double r144234 = r144232 * r144232;
        double r144235 = 3.0;
        double r144236 = a;
        double r144237 = r144235 * r144236;
        double r144238 = c;
        double r144239 = r144237 * r144238;
        double r144240 = r144234 - r144239;
        double r144241 = sqrt(r144240);
        double r144242 = r144233 + r144241;
        double r144243 = r144242 / r144237;
        return r144243;
}

double f(double a, double b, double c) {
        double r144244 = b;
        double r144245 = -5.955152059551362e+118;
        bool r144246 = r144244 <= r144245;
        double r144247 = 0.5;
        double r144248 = c;
        double r144249 = r144248 / r144244;
        double r144250 = r144247 * r144249;
        double r144251 = 0.6666666666666666;
        double r144252 = a;
        double r144253 = r144244 / r144252;
        double r144254 = r144251 * r144253;
        double r144255 = r144250 - r144254;
        double r144256 = -1.5314276380606224e-259;
        bool r144257 = r144244 <= r144256;
        double r144258 = -r144244;
        double r144259 = r144244 * r144244;
        double r144260 = 3.0;
        double r144261 = r144260 * r144252;
        double r144262 = r144261 * r144248;
        double r144263 = r144259 - r144262;
        double r144264 = sqrt(r144263);
        double r144265 = r144258 + r144264;
        double r144266 = r144265 / r144260;
        double r144267 = r144266 / r144252;
        double r144268 = 5.3300268467023164e+29;
        bool r144269 = r144244 <= r144268;
        double r144270 = 1.0;
        double r144271 = r144270 / r144252;
        double r144272 = r144258 - r144264;
        double r144273 = r144272 / r144248;
        double r144274 = r144271 * r144273;
        double r144275 = r144260 / r144274;
        double r144276 = r144270 * r144275;
        double r144277 = r144276 / r144261;
        double r144278 = -0.5;
        double r144279 = r144278 * r144249;
        double r144280 = r144269 ? r144277 : r144279;
        double r144281 = r144257 ? r144267 : r144280;
        double r144282 = r144246 ? r144255 : r144281;
        return r144282;
}

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 < -5.955152059551362e+118

    1. Initial program 52.2

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

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

    if -5.955152059551362e+118 < b < -1.5314276380606224e-259

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

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

    if -1.5314276380606224e-259 < b < 5.3300268467023164e+29

    1. Initial program 26.5

      \[\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-+26.6

      \[\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. Simplified16.9

      \[\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 *-un-lft-identity16.9

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

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

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

      \[\leadsto \frac{\color{blue}{1} \cdot \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}\]
    10. Simplified16.9

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{3}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a \cdot c}}}}{3 \cdot a}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity16.9

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

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

    if 5.3300268467023164e+29 < b

    1. Initial program 56.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.9551520595513616 \cdot 10^{118}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.53142763806062239 \cdot 10^{-259}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 5.3300268467023164 \cdot 10^{29}:\\ \;\;\;\;\frac{1 \cdot \frac{3}{\frac{1}{a} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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