Average Error: 28.8 → 16.2
Time: 16.2s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le 315.484838761318258:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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}\;b \le 315.484838761318258:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r58905 = b;
        double r58906 = -r58905;
        double r58907 = r58905 * r58905;
        double r58908 = 3.0;
        double r58909 = a;
        double r58910 = r58908 * r58909;
        double r58911 = c;
        double r58912 = r58910 * r58911;
        double r58913 = r58907 - r58912;
        double r58914 = sqrt(r58913);
        double r58915 = r58906 + r58914;
        double r58916 = r58915 / r58910;
        return r58916;
}

double f(double a, double b, double c) {
        double r58917 = b;
        double r58918 = 315.48483876131826;
        bool r58919 = r58917 <= r58918;
        double r58920 = r58917 * r58917;
        double r58921 = 3.0;
        double r58922 = a;
        double r58923 = r58921 * r58922;
        double r58924 = c;
        double r58925 = r58923 * r58924;
        double r58926 = -r58925;
        double r58927 = fma(r58917, r58917, r58926);
        double r58928 = r58920 - r58927;
        double r58929 = -r58917;
        double r58930 = r58920 - r58925;
        double r58931 = sqrt(r58930);
        double r58932 = r58929 - r58931;
        double r58933 = r58928 / r58932;
        double r58934 = r58933 / r58923;
        double r58935 = -0.5;
        double r58936 = r58924 / r58917;
        double r58937 = r58935 * r58936;
        double r58938 = r58919 ? r58934 : r58937;
        return r58938;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 315.48483876131826

    1. Initial program 16.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 flip-+16.4

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

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

    if 315.48483876131826 < b

    1. Initial program 36.0

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied associate-/r*16.6

      \[\leadsto \color{blue}{\frac{\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3}}{a}}\]
    5. Taylor expanded around 0 16.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 315.484838761318258:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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