Average Error: 34.3 → 15.4
Time: 19.9s
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.350676057343211554491874986591947593393 \cdot 10^{154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 4.102989996811911866204947960625153691584 \cdot 10^{-44}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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.350676057343211554491874986591947593393 \cdot 10^{154}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}{3 \cdot a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r43406 = b;
        double r43407 = -r43406;
        double r43408 = r43406 * r43406;
        double r43409 = 3.0;
        double r43410 = a;
        double r43411 = r43409 * r43410;
        double r43412 = c;
        double r43413 = r43411 * r43412;
        double r43414 = r43408 - r43413;
        double r43415 = sqrt(r43414);
        double r43416 = r43407 + r43415;
        double r43417 = r43416 / r43411;
        return r43417;
}

double f(double a, double b, double c) {
        double r43418 = b;
        double r43419 = -1.3506760573432116e+154;
        bool r43420 = r43418 <= r43419;
        double r43421 = a;
        double r43422 = c;
        double r43423 = r43421 * r43422;
        double r43424 = r43423 / r43418;
        double r43425 = 1.5;
        double r43426 = -2.0;
        double r43427 = r43426 * r43418;
        double r43428 = fma(r43424, r43425, r43427);
        double r43429 = 3.0;
        double r43430 = r43429 * r43421;
        double r43431 = r43428 / r43430;
        double r43432 = 4.102989996811912e-44;
        bool r43433 = r43418 <= r43432;
        double r43434 = r43418 * r43418;
        double r43435 = r43430 * r43422;
        double r43436 = r43434 - r43435;
        double r43437 = sqrt(r43436);
        double r43438 = r43437 - r43418;
        double r43439 = r43438 / r43430;
        double r43440 = -1.5;
        double r43441 = r43440 * r43424;
        double r43442 = r43441 / r43430;
        double r43443 = r43433 ? r43439 : r43442;
        double r43444 = r43420 ? r43431 : r43443;
        return r43444;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.3506760573432116e+154

    1. Initial program 64.0

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

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

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    4. Simplified12.0

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}}{3 \cdot a}\]

    if -1.3506760573432116e+154 < b < 4.102989996811912e-44

    1. Initial program 13.5

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

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

    if 4.102989996811912e-44 < b

    1. Initial program 54.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.350676057343211554491874986591947593393 \cdot 10^{154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 4.102989996811911866204947960625153691584 \cdot 10^{-44}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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