Average Error: 29.0 → 16.4
Time: 6.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}\;b \le 228.26278739030357:\\ \;\;\;\;\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}:\\ \;\;\;\;-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 228.26278739030357:\\
\;\;\;\;\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}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r132448 = b;
        double r132449 = -r132448;
        double r132450 = r132448 * r132448;
        double r132451 = 3.0;
        double r132452 = a;
        double r132453 = r132451 * r132452;
        double r132454 = c;
        double r132455 = r132453 * r132454;
        double r132456 = r132450 - r132455;
        double r132457 = sqrt(r132456);
        double r132458 = r132449 + r132457;
        double r132459 = r132458 / r132453;
        return r132459;
}

double f(double a, double b, double c) {
        double r132460 = b;
        double r132461 = 228.26278739030357;
        bool r132462 = r132460 <= r132461;
        double r132463 = r132460 * r132460;
        double r132464 = c;
        double r132465 = 3.0;
        double r132466 = a;
        double r132467 = r132465 * r132466;
        double r132468 = r132464 * r132467;
        double r132469 = fma(r132460, r132460, r132468);
        double r132470 = r132463 - r132469;
        double r132471 = r132467 * r132464;
        double r132472 = r132463 - r132471;
        double r132473 = sqrt(r132472);
        double r132474 = r132473 + r132460;
        double r132475 = r132470 / r132474;
        double r132476 = r132475 / r132467;
        double r132477 = -0.5;
        double r132478 = r132464 / r132460;
        double r132479 = r132477 * r132478;
        double r132480 = r132462 ? r132476 : r132479;
        return r132480;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 16.3

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

      \[\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--16.3

      \[\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. Simplified15.6

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

    1. Initial program 35.6

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

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

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

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3 \cdot a}\]
    6. Applied times-frac16.8

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

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

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

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

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

Reproduce

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