Average Error: 28.8 → 14.8
Time: 20.5s
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 -1.713962373336343874544087512168388798273 \cdot 10^{-6}:\\ \;\;\;\;\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 -1.713962373336343874544087512168388798273 \cdot 10^{-6}:\\
\;\;\;\;\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 r4078844 = b;
        double r4078845 = -r4078844;
        double r4078846 = r4078844 * r4078844;
        double r4078847 = 3.0;
        double r4078848 = a;
        double r4078849 = r4078847 * r4078848;
        double r4078850 = c;
        double r4078851 = r4078849 * r4078850;
        double r4078852 = r4078846 - r4078851;
        double r4078853 = sqrt(r4078852);
        double r4078854 = r4078845 + r4078853;
        double r4078855 = r4078854 / r4078849;
        return r4078855;
}

double f(double a, double b, double c) {
        double r4078856 = b;
        double r4078857 = r4078856 * r4078856;
        double r4078858 = 3.0;
        double r4078859 = a;
        double r4078860 = r4078858 * r4078859;
        double r4078861 = c;
        double r4078862 = r4078860 * r4078861;
        double r4078863 = r4078857 - r4078862;
        double r4078864 = sqrt(r4078863);
        double r4078865 = -r4078856;
        double r4078866 = r4078864 + r4078865;
        double r4078867 = r4078866 / r4078860;
        double r4078868 = -1.7139623733363439e-06;
        bool r4078869 = r4078867 <= r4078868;
        double r4078870 = r4078861 * r4078859;
        double r4078871 = r4078870 * r4078858;
        double r4078872 = r4078857 - r4078871;
        double r4078873 = sqrt(r4078872);
        double r4078874 = r4078872 * r4078873;
        double r4078875 = r4078856 * r4078857;
        double r4078876 = r4078874 - r4078875;
        double r4078877 = r4078873 + r4078856;
        double r4078878 = fma(r4078873, r4078877, r4078857);
        double r4078879 = r4078876 / r4078878;
        double r4078880 = r4078879 / r4078860;
        double r4078881 = -0.5;
        double r4078882 = r4078861 / r4078856;
        double r4078883 = r4078881 * r4078882;
        double r4078884 = r4078869 ? r4078880 : r4078883;
        return r4078884;
}

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

    1. Initial program 17.8

      \[\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.9

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

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

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

    if -1.7139623733363439e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 42.0

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.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 -1.713962373336343874544087512168388798273 \cdot 10^{-6}:\\ \;\;\;\;\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 2019170 +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)))