Average Error: 43.2 → 10.1
Time: 17.5s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 -3.125067702281917015824392463985148538086 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(b, \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a}, b \cdot b - \left(3 \cdot c\right) \cdot a\right)}}{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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -3.125067702281917015824392463985148538086 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(b, \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a}, b \cdot b - \left(3 \cdot c\right) \cdot a\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2982480 = b;
        double r2982481 = -r2982480;
        double r2982482 = r2982480 * r2982480;
        double r2982483 = 3.0;
        double r2982484 = a;
        double r2982485 = r2982483 * r2982484;
        double r2982486 = c;
        double r2982487 = r2982485 * r2982486;
        double r2982488 = r2982482 - r2982487;
        double r2982489 = sqrt(r2982488);
        double r2982490 = r2982481 + r2982489;
        double r2982491 = r2982490 / r2982485;
        return r2982491;
}

double f(double a, double b, double c) {
        double r2982492 = b;
        double r2982493 = r2982492 * r2982492;
        double r2982494 = 3.0;
        double r2982495 = a;
        double r2982496 = r2982494 * r2982495;
        double r2982497 = c;
        double r2982498 = r2982496 * r2982497;
        double r2982499 = r2982493 - r2982498;
        double r2982500 = sqrt(r2982499);
        double r2982501 = -r2982492;
        double r2982502 = r2982500 + r2982501;
        double r2982503 = r2982502 / r2982496;
        double r2982504 = -3.125067702281917e-07;
        bool r2982505 = r2982503 <= r2982504;
        double r2982506 = r2982494 * r2982497;
        double r2982507 = r2982506 * r2982495;
        double r2982508 = r2982493 - r2982507;
        double r2982509 = sqrt(r2982508);
        double r2982510 = r2982508 * r2982509;
        double r2982511 = r2982492 * r2982493;
        double r2982512 = r2982510 - r2982511;
        double r2982513 = fma(r2982492, r2982509, r2982508);
        double r2982514 = r2982493 + r2982513;
        double r2982515 = r2982512 / r2982514;
        double r2982516 = r2982515 / r2982496;
        double r2982517 = -0.5;
        double r2982518 = r2982497 / r2982492;
        double r2982519 = r2982517 * r2982518;
        double r2982520 = r2982505 ? r2982516 : r2982519;
        return r2982520;
}

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.0 a) c)))) (* 3.0 a)) < -3.125067702281917e-07

    1. Initial program 21.2

      \[\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.3

      \[\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.6

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

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

    if -3.125067702281917e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 53.1

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

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

    \[\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 -3.125067702281917015824392463985148538086 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(b, \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a}, b \cdot b - \left(3 \cdot c\right) \cdot a\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +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.0 a) c)))) (* 3.0 a)))