Average Error: 43.8 → 11.1
Time: 6.5s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\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 1.7936624356974993 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\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 1.7936624356974993 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\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 r117871 = b;
        double r117872 = -r117871;
        double r117873 = r117871 * r117871;
        double r117874 = 3.0;
        double r117875 = a;
        double r117876 = r117874 * r117875;
        double r117877 = c;
        double r117878 = r117876 * r117877;
        double r117879 = r117873 - r117878;
        double r117880 = sqrt(r117879);
        double r117881 = r117872 + r117880;
        double r117882 = r117881 / r117876;
        return r117882;
}

double f(double a, double b, double c) {
        double r117883 = b;
        double r117884 = 0.00017936624356974993;
        bool r117885 = r117883 <= r117884;
        double r117886 = r117883 * r117883;
        double r117887 = c;
        double r117888 = 3.0;
        double r117889 = a;
        double r117890 = r117888 * r117889;
        double r117891 = r117887 * r117890;
        double r117892 = fma(r117883, r117883, r117891);
        double r117893 = r117886 - r117892;
        double r117894 = r117890 * r117887;
        double r117895 = r117886 - r117894;
        double r117896 = sqrt(r117895);
        double r117897 = r117896 + r117883;
        double r117898 = r117893 / r117897;
        double r117899 = r117898 / r117890;
        double r117900 = -0.5;
        double r117901 = r117887 / r117883;
        double r117902 = r117900 * r117901;
        double r117903 = r117885 ? r117899 : r117902;
        return r117903;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified18.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--18.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. Simplified17.7

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

    if 0.00017936624356974993 < b

    1. Initial program 45.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.7936624356974993 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\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 2020047 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))