Average Error: 43.5 → 11.4
Time: 34.7s
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.00125353222550368486286342939450833000592:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b \cdot b\right)}}{a \cdot 3}\\ \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.00125353222550368486286342939450833000592:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b \cdot b\right)}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4547705 = b;
        double r4547706 = -r4547705;
        double r4547707 = r4547705 * r4547705;
        double r4547708 = 3.0;
        double r4547709 = a;
        double r4547710 = r4547708 * r4547709;
        double r4547711 = c;
        double r4547712 = r4547710 * r4547711;
        double r4547713 = r4547707 - r4547712;
        double r4547714 = sqrt(r4547713);
        double r4547715 = r4547706 + r4547714;
        double r4547716 = r4547715 / r4547710;
        return r4547716;
}

double f(double a, double b, double c) {
        double r4547717 = b;
        double r4547718 = 0.0012535322255036849;
        bool r4547719 = r4547717 <= r4547718;
        double r4547720 = r4547717 * r4547717;
        double r4547721 = c;
        double r4547722 = a;
        double r4547723 = r4547721 * r4547722;
        double r4547724 = 3.0;
        double r4547725 = r4547723 * r4547724;
        double r4547726 = r4547720 - r4547725;
        double r4547727 = sqrt(r4547726);
        double r4547728 = r4547726 * r4547727;
        double r4547729 = r4547720 * r4547717;
        double r4547730 = r4547728 - r4547729;
        double r4547731 = r4547717 + r4547727;
        double r4547732 = fma(r4547727, r4547731, r4547720);
        double r4547733 = r4547730 / r4547732;
        double r4547734 = r4547722 * r4547724;
        double r4547735 = r4547733 / r4547734;
        double r4547736 = -0.5;
        double r4547737 = r4547721 / r4547717;
        double r4547738 = r4547736 * r4547737;
        double r4547739 = r4547719 ? r4547735 : r4547738;
        return r4547739;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 20.3

      \[\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-+20.5

      \[\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. Simplified19.9

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} \cdot \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right) - 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. Simplified19.9

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

    if 0.0012535322255036849 < b

    1. Initial program 45.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 0.00125353222550368486286342939450833000592:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b \cdot b\right)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))