Average Error: 28.8 → 14.6
Time: 18.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 -2.317492431545885165193203241926211966017 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.317492431545885165193203241926211966017 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r2622518 = b;
        double r2622519 = -r2622518;
        double r2622520 = r2622518 * r2622518;
        double r2622521 = 3.0;
        double r2622522 = a;
        double r2622523 = r2622521 * r2622522;
        double r2622524 = c;
        double r2622525 = r2622523 * r2622524;
        double r2622526 = r2622520 - r2622525;
        double r2622527 = sqrt(r2622526);
        double r2622528 = r2622519 + r2622527;
        double r2622529 = r2622528 / r2622523;
        return r2622529;
}

double f(double a, double b, double c) {
        double r2622530 = b;
        double r2622531 = r2622530 * r2622530;
        double r2622532 = 3.0;
        double r2622533 = a;
        double r2622534 = r2622532 * r2622533;
        double r2622535 = c;
        double r2622536 = r2622534 * r2622535;
        double r2622537 = r2622531 - r2622536;
        double r2622538 = sqrt(r2622537);
        double r2622539 = -r2622530;
        double r2622540 = r2622538 + r2622539;
        double r2622541 = r2622540 / r2622534;
        double r2622542 = -2.3174924315458852e-07;
        bool r2622543 = r2622541 <= r2622542;
        double r2622544 = r2622535 * r2622533;
        double r2622545 = r2622544 * r2622532;
        double r2622546 = r2622531 - r2622545;
        double r2622547 = sqrt(r2622546);
        double r2622548 = r2622546 * r2622547;
        double r2622549 = r2622530 * r2622531;
        double r2622550 = r2622548 - r2622549;
        double r2622551 = r2622547 + r2622530;
        double r2622552 = fma(r2622547, r2622551, r2622531);
        double r2622553 = r2622550 / r2622552;
        double r2622554 = r2622553 / r2622534;
        double r2622555 = -0.5;
        double r2622556 = r2622535 / r2622530;
        double r2622557 = r2622555 * r2622556;
        double r2622558 = r2622543 ? r2622554 : r2622557;
        return r2622558;
}

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

    1. Initial program 18.4

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

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

      \[\leadsto \frac{\frac{\color{blue}{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - \left(b \cdot b\right) \cdot b}}{\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. Simplified17.8

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

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

    1. Initial program 45.0

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

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

    \[\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 -2.317492431545885165193203241926211966017 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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