Average Error: 52.4 → 5.8
Time: 18.5s
Precision: 64
\[4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt a \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt b \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt c \lt 20282409603651670423947251286016\]
\[\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.3182234137632997672540113853756338357925:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b, b \cdot b - \left(c \cdot a\right) \cdot 3\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 -0.3182234137632997672540113853756338357925:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b, b \cdot b - \left(c \cdot a\right) \cdot 3\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2917935 = b;
        double r2917936 = -r2917935;
        double r2917937 = r2917935 * r2917935;
        double r2917938 = 3.0;
        double r2917939 = a;
        double r2917940 = r2917938 * r2917939;
        double r2917941 = c;
        double r2917942 = r2917940 * r2917941;
        double r2917943 = r2917937 - r2917942;
        double r2917944 = sqrt(r2917943);
        double r2917945 = r2917936 + r2917944;
        double r2917946 = r2917945 / r2917940;
        return r2917946;
}

double f(double a, double b, double c) {
        double r2917947 = b;
        double r2917948 = r2917947 * r2917947;
        double r2917949 = 3.0;
        double r2917950 = a;
        double r2917951 = r2917949 * r2917950;
        double r2917952 = c;
        double r2917953 = r2917951 * r2917952;
        double r2917954 = r2917948 - r2917953;
        double r2917955 = sqrt(r2917954);
        double r2917956 = -r2917947;
        double r2917957 = r2917955 + r2917956;
        double r2917958 = r2917957 / r2917951;
        double r2917959 = -0.31822341376329977;
        bool r2917960 = r2917958 <= r2917959;
        double r2917961 = r2917952 * r2917950;
        double r2917962 = r2917961 * r2917949;
        double r2917963 = r2917948 - r2917962;
        double r2917964 = sqrt(r2917963);
        double r2917965 = r2917963 * r2917964;
        double r2917966 = r2917947 * r2917948;
        double r2917967 = r2917965 - r2917966;
        double r2917968 = fma(r2917964, r2917947, r2917963);
        double r2917969 = r2917948 + r2917968;
        double r2917970 = r2917967 / r2917969;
        double r2917971 = r2917970 / r2917951;
        double r2917972 = -0.5;
        double r2917973 = r2917952 / r2917947;
        double r2917974 = r2917972 * r2917973;
        double r2917975 = r2917960 ? r2917971 : r2917974;
        return r2917975;
}

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

    1. Initial program 22.6

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

      \[\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. Simplified22.0

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

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

    if -0.31822341376329977 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 55.7

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

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

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

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :pre (and (< 4.930380657631324e-32 a 2.028240960365167e+31) (< 4.930380657631324e-32 b 2.028240960365167e+31) (< 4.930380657631324e-32 c 2.028240960365167e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))