Average Error: 28.6 → 15.8
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 -0.001421778048839864505223373747355708474061:\\ \;\;\;\;\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)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\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.001421778048839864505223373747355708474061:\\
\;\;\;\;\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)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3430011 = b;
        double r3430012 = -r3430011;
        double r3430013 = r3430011 * r3430011;
        double r3430014 = 3.0;
        double r3430015 = a;
        double r3430016 = r3430014 * r3430015;
        double r3430017 = c;
        double r3430018 = r3430016 * r3430017;
        double r3430019 = r3430013 - r3430018;
        double r3430020 = sqrt(r3430019);
        double r3430021 = r3430012 + r3430020;
        double r3430022 = r3430021 / r3430016;
        return r3430022;
}

double f(double a, double b, double c) {
        double r3430023 = b;
        double r3430024 = r3430023 * r3430023;
        double r3430025 = 3.0;
        double r3430026 = a;
        double r3430027 = r3430025 * r3430026;
        double r3430028 = c;
        double r3430029 = r3430027 * r3430028;
        double r3430030 = r3430024 - r3430029;
        double r3430031 = sqrt(r3430030);
        double r3430032 = -r3430023;
        double r3430033 = r3430031 + r3430032;
        double r3430034 = r3430033 / r3430027;
        double r3430035 = -0.0014217780488398645;
        bool r3430036 = r3430034 <= r3430035;
        double r3430037 = r3430028 * r3430026;
        double r3430038 = r3430037 * r3430025;
        double r3430039 = r3430024 - r3430038;
        double r3430040 = sqrt(r3430039);
        double r3430041 = r3430039 * r3430040;
        double r3430042 = r3430023 * r3430024;
        double r3430043 = r3430041 - r3430042;
        double r3430044 = r3430040 + r3430023;
        double r3430045 = fma(r3430040, r3430044, r3430024);
        double r3430046 = r3430043 / r3430045;
        double r3430047 = r3430046 / r3430027;
        double r3430048 = -0.5;
        double r3430049 = r3430028 / r3430023;
        double r3430050 = r3430048 * r3430049;
        double r3430051 = r3430036 ? r3430047 : r3430050;
        return r3430051;
}

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.0014217780488398645

    1. Initial program 14.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-+14.7

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

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

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

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

    1. Initial program 35.7

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification15.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.001421778048839864505223373747355708474061:\\ \;\;\;\;\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)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\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, 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)))