Average Error: 28.6 → 15.8
Time: 17.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(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}:\\ \;\;\;\;\frac{\frac{1}{b}}{a} \cdot \frac{-1.5 \cdot \left(c \cdot a\right)}{3}\\ \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(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}:\\
\;\;\;\;\frac{\frac{1}{b}}{a} \cdot \frac{-1.5 \cdot \left(c \cdot a\right)}{3}\\

\end{array}
double f(double a, double b, double c) {
        double r3215245 = b;
        double r3215246 = -r3215245;
        double r3215247 = r3215245 * r3215245;
        double r3215248 = 3.0;
        double r3215249 = a;
        double r3215250 = r3215248 * r3215249;
        double r3215251 = c;
        double r3215252 = r3215250 * r3215251;
        double r3215253 = r3215247 - r3215252;
        double r3215254 = sqrt(r3215253);
        double r3215255 = r3215246 + r3215254;
        double r3215256 = r3215255 / r3215250;
        return r3215256;
}

double f(double a, double b, double c) {
        double r3215257 = b;
        double r3215258 = r3215257 * r3215257;
        double r3215259 = 3.0;
        double r3215260 = a;
        double r3215261 = r3215259 * r3215260;
        double r3215262 = c;
        double r3215263 = r3215261 * r3215262;
        double r3215264 = r3215258 - r3215263;
        double r3215265 = sqrt(r3215264);
        double r3215266 = -r3215257;
        double r3215267 = r3215265 + r3215266;
        double r3215268 = r3215267 / r3215261;
        double r3215269 = -0.0014217780488398645;
        bool r3215270 = r3215268 <= r3215269;
        double r3215271 = r3215259 * r3215262;
        double r3215272 = r3215271 * r3215260;
        double r3215273 = r3215258 - r3215272;
        double r3215274 = sqrt(r3215273);
        double r3215275 = r3215273 * r3215274;
        double r3215276 = r3215257 * r3215258;
        double r3215277 = r3215275 - r3215276;
        double r3215278 = fma(r3215257, r3215274, r3215273);
        double r3215279 = r3215258 + r3215278;
        double r3215280 = r3215277 / r3215279;
        double r3215281 = r3215280 / r3215261;
        double r3215282 = 1.0;
        double r3215283 = r3215282 / r3215257;
        double r3215284 = r3215283 / r3215260;
        double r3215285 = -1.5;
        double r3215286 = r3215262 * r3215260;
        double r3215287 = r3215285 * r3215286;
        double r3215288 = r3215287 / r3215259;
        double r3215289 = r3215284 * r3215288;
        double r3215290 = r3215270 ? r3215281 : r3215289;
        return r3215290;
}

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(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. Simplified14.0

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied div-inv16.8

      \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\left(a \cdot c\right) \cdot \frac{1}{b}\right)}}{3 \cdot a}\]
    5. Applied associate-*r*16.8

      \[\leadsto \frac{\color{blue}{\left(-1.5 \cdot \left(a \cdot c\right)\right) \cdot \frac{1}{b}}}{3 \cdot a}\]
    6. Using strategy rm
    7. Applied times-frac16.8

      \[\leadsto \color{blue}{\frac{-1.5 \cdot \left(a \cdot c\right)}{3} \cdot \frac{\frac{1}{b}}{a}}\]
  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(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}:\\ \;\;\;\;\frac{\frac{1}{b}}{a} \cdot \frac{-1.5 \cdot \left(c \cdot a\right)}{3}\\ \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)))