Average Error: 28.7 → 15.0
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 -2.536263872934144771492713868465962434584 \cdot 10^{-6}:\\ \;\;\;\;\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}:\\ \;\;\;\;-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.536263872934144771492713868465962434584 \cdot 10^{-6}:\\
\;\;\;\;\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}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r4671483 = b;
        double r4671484 = -r4671483;
        double r4671485 = r4671483 * r4671483;
        double r4671486 = 3.0;
        double r4671487 = a;
        double r4671488 = r4671486 * r4671487;
        double r4671489 = c;
        double r4671490 = r4671488 * r4671489;
        double r4671491 = r4671485 - r4671490;
        double r4671492 = sqrt(r4671491);
        double r4671493 = r4671484 + r4671492;
        double r4671494 = r4671493 / r4671488;
        return r4671494;
}

double f(double a, double b, double c) {
        double r4671495 = b;
        double r4671496 = r4671495 * r4671495;
        double r4671497 = 3.0;
        double r4671498 = a;
        double r4671499 = r4671497 * r4671498;
        double r4671500 = c;
        double r4671501 = r4671499 * r4671500;
        double r4671502 = r4671496 - r4671501;
        double r4671503 = sqrt(r4671502);
        double r4671504 = -r4671495;
        double r4671505 = r4671503 + r4671504;
        double r4671506 = r4671505 / r4671499;
        double r4671507 = -2.5362638729341448e-06;
        bool r4671508 = r4671506 <= r4671507;
        double r4671509 = r4671497 * r4671500;
        double r4671510 = r4671509 * r4671498;
        double r4671511 = r4671496 - r4671510;
        double r4671512 = sqrt(r4671511);
        double r4671513 = r4671511 * r4671512;
        double r4671514 = r4671495 * r4671496;
        double r4671515 = r4671513 - r4671514;
        double r4671516 = fma(r4671495, r4671512, r4671511);
        double r4671517 = r4671496 + r4671516;
        double r4671518 = r4671515 / r4671517;
        double r4671519 = r4671518 / r4671499;
        double r4671520 = -0.5;
        double r4671521 = r4671500 / r4671495;
        double r4671522 = r4671520 * r4671521;
        double r4671523 = r4671508 ? r4671519 : r4671522;
        return r4671523;
}

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.5362638729341448e-06

    1. Initial program 18.0

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

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

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

      \[\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 -2.5362638729341448e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 41.6

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

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

    \[\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.536263872934144771492713868465962434584 \cdot 10^{-6}:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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