Average Error: 43.6 → 10.3
Time: 13.3s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\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 -4.151250236746473 \cdot 10^{-05}:\\ \;\;\;\;\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 -4.151250236746473 \cdot 10^{-05}:\\
\;\;\;\;\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 r1076350 = b;
        double r1076351 = -r1076350;
        double r1076352 = r1076350 * r1076350;
        double r1076353 = 3.0;
        double r1076354 = a;
        double r1076355 = r1076353 * r1076354;
        double r1076356 = c;
        double r1076357 = r1076355 * r1076356;
        double r1076358 = r1076352 - r1076357;
        double r1076359 = sqrt(r1076358);
        double r1076360 = r1076351 + r1076359;
        double r1076361 = r1076360 / r1076355;
        return r1076361;
}

double f(double a, double b, double c) {
        double r1076362 = b;
        double r1076363 = r1076362 * r1076362;
        double r1076364 = 3.0;
        double r1076365 = a;
        double r1076366 = r1076364 * r1076365;
        double r1076367 = c;
        double r1076368 = r1076366 * r1076367;
        double r1076369 = r1076363 - r1076368;
        double r1076370 = sqrt(r1076369);
        double r1076371 = -r1076362;
        double r1076372 = r1076370 + r1076371;
        double r1076373 = r1076372 / r1076366;
        double r1076374 = -4.151250236746473e-05;
        bool r1076375 = r1076373 <= r1076374;
        double r1076376 = r1076369 * r1076370;
        double r1076377 = r1076362 * r1076363;
        double r1076378 = r1076376 - r1076377;
        double r1076379 = -3.0;
        double r1076380 = r1076367 * r1076365;
        double r1076381 = r1076379 * r1076380;
        double r1076382 = fma(r1076362, r1076362, r1076381);
        double r1076383 = fma(r1076362, r1076362, r1076382);
        double r1076384 = sqrt(r1076382);
        double r1076385 = r1076362 * r1076384;
        double r1076386 = r1076383 + r1076385;
        double r1076387 = r1076378 / r1076386;
        double r1076388 = r1076387 / r1076366;
        double r1076389 = -0.5;
        double r1076390 = r1076367 / r1076362;
        double r1076391 = r1076389 * r1076390;
        double r1076392 = r1076375 ? r1076388 : r1076391;
        return r1076392;
}

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)) < -4.151250236746473e-05

    1. Initial program 21.1

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

      \[\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. Simplified20.5

      \[\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. Simplified20.5

      \[\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 -4.151250236746473e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 50.9

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

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

    \[\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 -4.151250236746473 \cdot 10^{-05}:\\ \;\;\;\;\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, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))