Average Error: 28.5 → 16.5
Time: 15.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 230.5116632738639736999175511300563812256:\\ \;\;\;\;\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 230.5116632738639736999175511300563812256:\\
\;\;\;\;\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 r35559 = b;
        double r35560 = -r35559;
        double r35561 = r35559 * r35559;
        double r35562 = 3.0;
        double r35563 = a;
        double r35564 = r35562 * r35563;
        double r35565 = c;
        double r35566 = r35564 * r35565;
        double r35567 = r35561 - r35566;
        double r35568 = sqrt(r35567);
        double r35569 = r35560 + r35568;
        double r35570 = r35569 / r35564;
        return r35570;
}

double f(double a, double b, double c) {
        double r35571 = b;
        double r35572 = 230.51166327386397;
        bool r35573 = r35571 <= r35572;
        double r35574 = r35571 * r35571;
        double r35575 = 3.0;
        double r35576 = a;
        double r35577 = r35575 * r35576;
        double r35578 = c;
        double r35579 = fma(r35577, r35578, r35574);
        double r35580 = r35574 - r35579;
        double r35581 = r35577 * r35578;
        double r35582 = r35574 - r35581;
        double r35583 = sqrt(r35582);
        double r35584 = r35583 + r35571;
        double r35585 = r35580 / r35584;
        double r35586 = r35585 / r35577;
        double r35587 = -0.5;
        double r35588 = r35578 / r35571;
        double r35589 = r35587 * r35588;
        double r35590 = r35573 ? r35586 : r35589;
        return r35590;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    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.2

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

    1. Initial program 35.1

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Taylor expanded around inf 17.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 230.5116632738639736999175511300563812256:\\ \;\;\;\;\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 2019212 +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)))