Average Error: 28.3 → 16.3
Time: 16.1s
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}\;b \le 431.6335353201244515730650164186954498291:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(3 \cdot a, c, b \cdot b\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 431.6335353201244515730650164186954498291:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(3 \cdot a, c, b \cdot b\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 r122048 = b;
        double r122049 = -r122048;
        double r122050 = r122048 * r122048;
        double r122051 = 3.0;
        double r122052 = a;
        double r122053 = r122051 * r122052;
        double r122054 = c;
        double r122055 = r122053 * r122054;
        double r122056 = r122050 - r122055;
        double r122057 = sqrt(r122056);
        double r122058 = r122049 + r122057;
        double r122059 = r122058 / r122053;
        return r122059;
}

double f(double a, double b, double c) {
        double r122060 = b;
        double r122061 = 431.63353532012445;
        bool r122062 = r122060 <= r122061;
        double r122063 = r122060 * r122060;
        double r122064 = 3.0;
        double r122065 = a;
        double r122066 = r122064 * r122065;
        double r122067 = c;
        double r122068 = fma(r122066, r122067, r122063);
        double r122069 = r122063 - r122068;
        double r122070 = r122066 * r122067;
        double r122071 = r122063 - r122070;
        double r122072 = sqrt(r122071);
        double r122073 = r122072 + r122060;
        double r122074 = r122069 / r122073;
        double r122075 = r122074 / r122066;
        double r122076 = -0.5;
        double r122077 = r122067 / r122060;
        double r122078 = r122076 * r122077;
        double r122079 = r122062 ? r122075 : r122078;
        return r122079;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 16.1

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

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

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

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

    if 431.63353532012445 < b

    1. Initial program 35.5

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

      \[\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 \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 431.6335353201244515730650164186954498291:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(3 \cdot a, c, b \cdot b\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 2019209 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.05367121277235087e-8 a 94906265.6242515594) (< 1.05367121277235087e-8 b 94906265.6242515594) (< 1.05367121277235087e-8 c 94906265.6242515594))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))