Average Error: 28.5 → 16.5
Time: 14.3s
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 152.9090403020271082823455799371004104614:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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 152.9090403020271082823455799371004104614:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r62679 = b;
        double r62680 = -r62679;
        double r62681 = r62679 * r62679;
        double r62682 = 3.0;
        double r62683 = a;
        double r62684 = r62682 * r62683;
        double r62685 = c;
        double r62686 = r62684 * r62685;
        double r62687 = r62681 - r62686;
        double r62688 = sqrt(r62687);
        double r62689 = r62680 + r62688;
        double r62690 = r62689 / r62684;
        return r62690;
}

double f(double a, double b, double c) {
        double r62691 = b;
        double r62692 = 152.9090403020271;
        bool r62693 = r62691 <= r62692;
        double r62694 = r62691 * r62691;
        double r62695 = 3.0;
        double r62696 = a;
        double r62697 = r62695 * r62696;
        double r62698 = c;
        double r62699 = r62697 * r62698;
        double r62700 = fma(r62691, r62691, r62699);
        double r62701 = r62694 - r62700;
        double r62702 = r62694 - r62699;
        double r62703 = sqrt(r62702);
        double r62704 = r62691 + r62703;
        double r62705 = r62701 / r62704;
        double r62706 = r62705 / r62697;
        double r62707 = -0.5;
        double r62708 = r62698 / r62691;
        double r62709 = r62707 * r62708;
        double r62710 = r62693 ? r62706 : r62709;
        return r62710;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 15.4

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

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

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

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

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

    if 152.9090403020271 < b

    1. Initial program 34.9

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

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

Reproduce

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