Average Error: 28.6 → 14.7
Time: 18.7s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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.649757669353515561819212287275604467141 \cdot 10^{-6}:\\ \;\;\;\;\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 -4.649757669353515561819212287275604467141 \cdot 10^{-6}:\\
\;\;\;\;\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 r3932947 = b;
        double r3932948 = -r3932947;
        double r3932949 = r3932947 * r3932947;
        double r3932950 = 3.0;
        double r3932951 = a;
        double r3932952 = r3932950 * r3932951;
        double r3932953 = c;
        double r3932954 = r3932952 * r3932953;
        double r3932955 = r3932949 - r3932954;
        double r3932956 = sqrt(r3932955);
        double r3932957 = r3932948 + r3932956;
        double r3932958 = r3932957 / r3932952;
        return r3932958;
}

double f(double a, double b, double c) {
        double r3932959 = b;
        double r3932960 = r3932959 * r3932959;
        double r3932961 = 3.0;
        double r3932962 = a;
        double r3932963 = r3932961 * r3932962;
        double r3932964 = c;
        double r3932965 = r3932963 * r3932964;
        double r3932966 = r3932960 - r3932965;
        double r3932967 = sqrt(r3932966);
        double r3932968 = -r3932959;
        double r3932969 = r3932967 + r3932968;
        double r3932970 = r3932969 / r3932963;
        double r3932971 = -4.6497576693535156e-06;
        bool r3932972 = r3932970 <= r3932971;
        double r3932973 = r3932961 * r3932964;
        double r3932974 = r3932973 * r3932962;
        double r3932975 = r3932960 - r3932974;
        double r3932976 = sqrt(r3932975);
        double r3932977 = r3932975 * r3932976;
        double r3932978 = r3932959 * r3932960;
        double r3932979 = r3932977 - r3932978;
        double r3932980 = fma(r3932959, r3932976, r3932975);
        double r3932981 = r3932960 + r3932980;
        double r3932982 = r3932979 / r3932981;
        double r3932983 = r3932982 / r3932963;
        double r3932984 = -0.5;
        double r3932985 = r3932964 / r3932959;
        double r3932986 = r3932984 * r3932985;
        double r3932987 = r3932972 ? r3932983 : r3932986;
        return r3932987;
}

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)) < -4.6497576693535156e-06

    1. Initial program 17.4

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

      \[\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. Simplified16.8

      \[\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. Simplified16.8

      \[\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 -4.6497576693535156e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 40.9

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

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

    \[\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.649757669353515561819212287275604467141 \cdot 10^{-6}:\\ \;\;\;\;\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 2019192 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))