Average Error: 43.7 → 10.1
Time: 38.4s
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 -1.0998007329479 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - b \cdot \left(b \cdot b\right)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} + \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\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 -1.0998007329479 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - b \cdot \left(b \cdot b\right)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} + \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\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 r4291588 = b;
        double r4291589 = -r4291588;
        double r4291590 = r4291588 * r4291588;
        double r4291591 = 3.0;
        double r4291592 = a;
        double r4291593 = r4291591 * r4291592;
        double r4291594 = c;
        double r4291595 = r4291593 * r4291594;
        double r4291596 = r4291590 - r4291595;
        double r4291597 = sqrt(r4291596);
        double r4291598 = r4291589 + r4291597;
        double r4291599 = r4291598 / r4291593;
        return r4291599;
}

double f(double a, double b, double c) {
        double r4291600 = b;
        double r4291601 = r4291600 * r4291600;
        double r4291602 = 3.0;
        double r4291603 = a;
        double r4291604 = r4291602 * r4291603;
        double r4291605 = c;
        double r4291606 = r4291604 * r4291605;
        double r4291607 = r4291601 - r4291606;
        double r4291608 = sqrt(r4291607);
        double r4291609 = -r4291600;
        double r4291610 = r4291608 + r4291609;
        double r4291611 = r4291610 / r4291604;
        double r4291612 = -1.0998007329479e-05;
        bool r4291613 = r4291611 <= r4291612;
        double r4291614 = r4291605 * r4291603;
        double r4291615 = -3.0;
        double r4291616 = r4291614 * r4291615;
        double r4291617 = fma(r4291600, r4291600, r4291616);
        double r4291618 = sqrt(r4291617);
        double r4291619 = r4291618 * r4291617;
        double r4291620 = r4291600 * r4291601;
        double r4291621 = r4291619 - r4291620;
        double r4291622 = r4291600 * r4291618;
        double r4291623 = fma(r4291600, r4291600, r4291617);
        double r4291624 = r4291622 + r4291623;
        double r4291625 = r4291621 / r4291624;
        double r4291626 = r4291625 / r4291604;
        double r4291627 = -0.5;
        double r4291628 = r4291605 / r4291600;
        double r4291629 = r4291627 * r4291628;
        double r4291630 = r4291613 ? r4291626 : r4291629;
        return r4291630;
}

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

    1. Initial program 20.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-+20.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. Simplified20.3

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

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

    if -1.0998007329479e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 51.3

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

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

Reproduce

herbie shell --seed 2019144 +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)))