Average Error: 43.8 → 11.2
Time: 14.2s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 0.003147622297084620886231665082277686451562:\\ \;\;\;\;\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 0.003147622297084620886231665082277686451562:\\
\;\;\;\;\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 r49677 = b;
        double r49678 = -r49677;
        double r49679 = r49677 * r49677;
        double r49680 = 3.0;
        double r49681 = a;
        double r49682 = r49680 * r49681;
        double r49683 = c;
        double r49684 = r49682 * r49683;
        double r49685 = r49679 - r49684;
        double r49686 = sqrt(r49685);
        double r49687 = r49678 + r49686;
        double r49688 = r49687 / r49682;
        return r49688;
}

double f(double a, double b, double c) {
        double r49689 = b;
        double r49690 = 0.003147622297084621;
        bool r49691 = r49689 <= r49690;
        double r49692 = r49689 * r49689;
        double r49693 = 3.0;
        double r49694 = a;
        double r49695 = r49693 * r49694;
        double r49696 = c;
        double r49697 = fma(r49695, r49696, r49692);
        double r49698 = r49692 - r49697;
        double r49699 = r49695 * r49696;
        double r49700 = r49692 - r49699;
        double r49701 = sqrt(r49700);
        double r49702 = r49701 + r49689;
        double r49703 = r49698 / r49702;
        double r49704 = r49703 / r49695;
        double r49705 = -0.5;
        double r49706 = r49696 / r49689;
        double r49707 = r49705 * r49706;
        double r49708 = r49691 ? r49704 : r49707;
        return r49708;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 21.2

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

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

      \[\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. Simplified20.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 0.003147622297084621 < b

    1. Initial program 46.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 0.003147622297084620886231665082277686451562:\\ \;\;\;\;\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 2019305 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e15) (< 1.11022e-16 b 9.0072e15) (< 1.11022e-16 c 9.0072e15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))