Average Error: 28.6 → 14.6
Time: 13.6s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -6.169034680638637 \cdot 10^{-07}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -6.169034680638637 \cdot 10^{-07}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1906399 = b;
        double r1906400 = -r1906399;
        double r1906401 = r1906399 * r1906399;
        double r1906402 = 3.0;
        double r1906403 = a;
        double r1906404 = r1906402 * r1906403;
        double r1906405 = c;
        double r1906406 = r1906404 * r1906405;
        double r1906407 = r1906401 - r1906406;
        double r1906408 = sqrt(r1906407);
        double r1906409 = r1906400 + r1906408;
        double r1906410 = r1906409 / r1906404;
        return r1906410;
}

double f(double a, double b, double c) {
        double r1906411 = b;
        double r1906412 = r1906411 * r1906411;
        double r1906413 = 3.0;
        double r1906414 = a;
        double r1906415 = r1906413 * r1906414;
        double r1906416 = c;
        double r1906417 = r1906415 * r1906416;
        double r1906418 = r1906412 - r1906417;
        double r1906419 = sqrt(r1906418);
        double r1906420 = -r1906411;
        double r1906421 = r1906419 + r1906420;
        double r1906422 = r1906421 / r1906415;
        double r1906423 = -6.169034680638637e-07;
        bool r1906424 = r1906422 <= r1906423;
        double r1906425 = r1906418 * r1906419;
        double r1906426 = r1906411 * r1906412;
        double r1906427 = r1906425 - r1906426;
        double r1906428 = -3.0;
        double r1906429 = r1906416 * r1906414;
        double r1906430 = r1906428 * r1906429;
        double r1906431 = fma(r1906411, r1906411, r1906430);
        double r1906432 = fma(r1906411, r1906411, r1906431);
        double r1906433 = sqrt(r1906431);
        double r1906434 = r1906411 * r1906433;
        double r1906435 = r1906432 + r1906434;
        double r1906436 = r1906427 / r1906435;
        double r1906437 = r1906436 / r1906415;
        double r1906438 = -0.5;
        double r1906439 = r1906416 / r1906411;
        double r1906440 = r1906438 * r1906439;
        double r1906441 = r1906424 ? r1906437 : r1906440;
        return r1906441;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -6.169034680638637e-07

    1. Initial program 17.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 flip3-+17.9

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{3} + {\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}^{3}}{\left(-b\right) \cdot \left(-b\right) + \left(\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) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    4. Simplified17.2

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} \cdot \left(b \cdot b - c \cdot \left(a \cdot 3\right)\right) - \left(b \cdot b\right) \cdot b}}{\left(-b\right) \cdot \left(-b\right) + \left(\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) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]
    5. Simplified17.2

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

    if -6.169034680638637e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 43.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -6.169034680638637 \cdot 10^{-07}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))