Average Error: 43.8 → 9.9
Time: 32.5s
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 -0.0005208276581362506:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + b, b \cdot b\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 -0.0005208276581362506:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + b, b \cdot b\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3835932 = b;
        double r3835933 = -r3835932;
        double r3835934 = r3835932 * r3835932;
        double r3835935 = 3.0;
        double r3835936 = a;
        double r3835937 = r3835935 * r3835936;
        double r3835938 = c;
        double r3835939 = r3835937 * r3835938;
        double r3835940 = r3835934 - r3835939;
        double r3835941 = sqrt(r3835940);
        double r3835942 = r3835933 + r3835941;
        double r3835943 = r3835942 / r3835937;
        return r3835943;
}

double f(double a, double b, double c) {
        double r3835944 = b;
        double r3835945 = r3835944 * r3835944;
        double r3835946 = 3.0;
        double r3835947 = a;
        double r3835948 = r3835946 * r3835947;
        double r3835949 = c;
        double r3835950 = r3835948 * r3835949;
        double r3835951 = r3835945 - r3835950;
        double r3835952 = sqrt(r3835951);
        double r3835953 = -r3835944;
        double r3835954 = r3835952 + r3835953;
        double r3835955 = r3835954 / r3835948;
        double r3835956 = -0.0005208276581362506;
        bool r3835957 = r3835955 <= r3835956;
        double r3835958 = -3.0;
        double r3835959 = r3835958 * r3835949;
        double r3835960 = fma(r3835947, r3835959, r3835945);
        double r3835961 = sqrt(r3835960);
        double r3835962 = r3835960 * r3835961;
        double r3835963 = r3835944 * r3835945;
        double r3835964 = r3835962 - r3835963;
        double r3835965 = r3835961 + r3835944;
        double r3835966 = fma(r3835961, r3835965, r3835945);
        double r3835967 = r3835964 / r3835966;
        double r3835968 = r3835967 / r3835948;
        double r3835969 = -0.5;
        double r3835970 = r3835949 / r3835944;
        double r3835971 = r3835969 * r3835970;
        double r3835972 = r3835957 ? r3835968 : r3835971;
        return r3835972;
}

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)) < -0.0005208276581362506

    1. Initial program 19.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.0

      \[\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. Simplified19.2

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

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

    if -0.0005208276581362506 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 50.3

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

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

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

Reproduce

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