Average Error: 28.5 → 16.4
Time: 7.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 904.955392750566375:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5}{3} \cdot \frac{\frac{a \cdot c}{b}}{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}\;b \le 904.955392750566375:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r63339 = b;
        double r63340 = -r63339;
        double r63341 = r63339 * r63339;
        double r63342 = 3.0;
        double r63343 = a;
        double r63344 = r63342 * r63343;
        double r63345 = c;
        double r63346 = r63344 * r63345;
        double r63347 = r63341 - r63346;
        double r63348 = sqrt(r63347);
        double r63349 = r63340 + r63348;
        double r63350 = r63349 / r63344;
        return r63350;
}

double f(double a, double b, double c) {
        double r63351 = b;
        double r63352 = 904.9553927505664;
        bool r63353 = r63351 <= r63352;
        double r63354 = r63351 * r63351;
        double r63355 = c;
        double r63356 = 3.0;
        double r63357 = a;
        double r63358 = r63356 * r63357;
        double r63359 = r63355 * r63358;
        double r63360 = fma(r63351, r63351, r63359);
        double r63361 = r63354 - r63360;
        double r63362 = r63358 * r63355;
        double r63363 = r63354 - r63362;
        double r63364 = sqrt(r63363);
        double r63365 = r63364 + r63351;
        double r63366 = r63361 / r63365;
        double r63367 = r63366 / r63358;
        double r63368 = -1.5;
        double r63369 = r63368 / r63356;
        double r63370 = r63357 * r63355;
        double r63371 = r63370 / r63351;
        double r63372 = r63371 / r63357;
        double r63373 = r63369 * r63372;
        double r63374 = r63353 ? r63367 : r63373;
        return r63374;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 17.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified17.2

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--17.2

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}}{3 \cdot a}\]
    5. Simplified16.4

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

    if 904.9553927505664 < b

    1. Initial program 36.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified36.2

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Taylor expanded around inf 16.4

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied times-frac16.3

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

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

Reproduce

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