Average Error: 28.6 → 14.7
Time: 4.7s
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}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -7.45076962416815215 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3}}{a}\\ \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{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -7.45076962416815215 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3}}{a}\\

\end{array}
double f(double a, double b, double c) {
        double r72157 = b;
        double r72158 = -r72157;
        double r72159 = r72157 * r72157;
        double r72160 = 3.0;
        double r72161 = a;
        double r72162 = r72160 * r72161;
        double r72163 = c;
        double r72164 = r72162 * r72163;
        double r72165 = r72159 - r72164;
        double r72166 = sqrt(r72165);
        double r72167 = r72158 + r72166;
        double r72168 = r72167 / r72162;
        return r72168;
}

double f(double a, double b, double c) {
        double r72169 = b;
        double r72170 = -r72169;
        double r72171 = r72169 * r72169;
        double r72172 = 3.0;
        double r72173 = a;
        double r72174 = r72172 * r72173;
        double r72175 = c;
        double r72176 = r72174 * r72175;
        double r72177 = r72171 - r72176;
        double r72178 = sqrt(r72177);
        double r72179 = r72170 + r72178;
        double r72180 = r72179 / r72174;
        double r72181 = -7.450769624168152e-07;
        bool r72182 = r72180 <= r72181;
        double r72183 = -r72177;
        double r72184 = fma(r72169, r72169, r72183);
        double r72185 = r72170 - r72178;
        double r72186 = r72184 / r72185;
        double r72187 = r72186 / r72174;
        double r72188 = -1.5;
        double r72189 = r72173 * r72175;
        double r72190 = r72189 / r72169;
        double r72191 = r72188 * r72190;
        double r72192 = r72191 / r72172;
        double r72193 = r72192 / r72173;
        double r72194 = r72182 ? r72187 : r72193;
        return r72194;
}

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)) < -7.450769624168152e-07

    1. Initial program 17.9

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

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

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

    if -7.450769624168152e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 42.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -7.45076962416815215 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3}}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :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 a) c)))) (* 3 a)))