Average Error: 28.7 → 16.7
Time: 4.5s
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 5947.8837641624032:\\ \;\;\;\;\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}:\\ \;\;\;\;-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 5947.8837641624032:\\
\;\;\;\;\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}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r84522 = b;
        double r84523 = -r84522;
        double r84524 = r84522 * r84522;
        double r84525 = 3.0;
        double r84526 = a;
        double r84527 = r84525 * r84526;
        double r84528 = c;
        double r84529 = r84527 * r84528;
        double r84530 = r84524 - r84529;
        double r84531 = sqrt(r84530);
        double r84532 = r84523 + r84531;
        double r84533 = r84532 / r84527;
        return r84533;
}

double f(double a, double b, double c) {
        double r84534 = b;
        double r84535 = 5947.883764162403;
        bool r84536 = r84534 <= r84535;
        double r84537 = r84534 * r84534;
        double r84538 = 3.0;
        double r84539 = a;
        double r84540 = r84538 * r84539;
        double r84541 = c;
        double r84542 = r84540 * r84541;
        double r84543 = r84537 - r84542;
        double r84544 = -r84543;
        double r84545 = fma(r84534, r84534, r84544);
        double r84546 = -r84534;
        double r84547 = sqrt(r84543);
        double r84548 = r84546 - r84547;
        double r84549 = r84545 / r84548;
        double r84550 = r84549 / r84540;
        double r84551 = -0.5;
        double r84552 = r84541 / r84534;
        double r84553 = r84551 * r84552;
        double r84554 = r84536 ? r84550 : r84553;
        return r84554;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 19.2

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

      \[\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. Simplified18.3

      \[\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 5947.883764162403 < b

    1. Initial program 37.8

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity15.2

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3 \cdot a}\]
    5. Applied times-frac15.2

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

      \[\leadsto \frac{\color{blue}{\left(-1.5 \cdot \frac{a}{1}\right) \cdot \frac{c}{b}}}{3 \cdot a}\]
    7. Simplified15.1

      \[\leadsto \frac{\color{blue}{\left(a \cdot -1.5\right)} \cdot \frac{c}{b}}{3 \cdot a}\]
    8. Taylor expanded around 0 15.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 5947.8837641624032:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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