Average Error: 34.5 → 10.3
Time: 19.5s
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 -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{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 -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4676318 = b;
        double r4676319 = -r4676318;
        double r4676320 = r4676318 * r4676318;
        double r4676321 = 3.0;
        double r4676322 = a;
        double r4676323 = r4676321 * r4676322;
        double r4676324 = c;
        double r4676325 = r4676323 * r4676324;
        double r4676326 = r4676320 - r4676325;
        double r4676327 = sqrt(r4676326);
        double r4676328 = r4676319 + r4676327;
        double r4676329 = r4676328 / r4676323;
        return r4676329;
}

double f(double a, double b, double c) {
        double r4676330 = b;
        double r4676331 = -1.7633154797394035e+89;
        bool r4676332 = r4676330 <= r4676331;
        double r4676333 = 0.5;
        double r4676334 = c;
        double r4676335 = r4676334 / r4676330;
        double r4676336 = r4676333 * r4676335;
        double r4676337 = a;
        double r4676338 = r4676330 / r4676337;
        double r4676339 = 0.6666666666666666;
        double r4676340 = r4676338 * r4676339;
        double r4676341 = r4676336 - r4676340;
        double r4676342 = 9.136492990928292e-23;
        bool r4676343 = r4676330 <= r4676342;
        double r4676344 = r4676330 * r4676330;
        double r4676345 = 3.0;
        double r4676346 = r4676345 * r4676337;
        double r4676347 = r4676346 * r4676334;
        double r4676348 = r4676344 - r4676347;
        double r4676349 = sqrt(r4676348);
        double r4676350 = r4676349 - r4676330;
        double r4676351 = r4676350 / r4676345;
        double r4676352 = r4676351 / r4676337;
        double r4676353 = -0.5;
        double r4676354 = r4676353 * r4676335;
        double r4676355 = r4676343 ? r4676352 : r4676354;
        double r4676356 = r4676332 ? r4676341 : r4676355;
        return r4676356;
}

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 < -1.7633154797394035e+89

    1. Initial program 45.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified45.8

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

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

    if -1.7633154797394035e+89 < b < 9.136492990928292e-23

    1. Initial program 15.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified15.1

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

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

    if 9.136492990928292e-23 < b

    1. Initial program 55.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified55.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))