Average Error: 44.2 → 9.7
Time: 17.5s
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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.542653353240975780532803773859029661253 \cdot 10^{-5}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-c, 3 \cdot a, \left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)} + \left(-b\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.542653353240975780532803773859029661253 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-c, 3 \cdot a, \left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)} + \left(-b\right)}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4620865 = b;
        double r4620866 = -r4620865;
        double r4620867 = r4620865 * r4620865;
        double r4620868 = 3.0;
        double r4620869 = a;
        double r4620870 = r4620868 * r4620869;
        double r4620871 = c;
        double r4620872 = r4620870 * r4620871;
        double r4620873 = r4620867 - r4620872;
        double r4620874 = sqrt(r4620873);
        double r4620875 = r4620866 + r4620874;
        double r4620876 = r4620875 / r4620870;
        return r4620876;
}

double f(double a, double b, double c) {
        double r4620877 = b;
        double r4620878 = r4620877 * r4620877;
        double r4620879 = 3.0;
        double r4620880 = a;
        double r4620881 = r4620879 * r4620880;
        double r4620882 = c;
        double r4620883 = r4620881 * r4620882;
        double r4620884 = r4620878 - r4620883;
        double r4620885 = sqrt(r4620884);
        double r4620886 = -r4620877;
        double r4620887 = r4620885 + r4620886;
        double r4620888 = r4620887 / r4620881;
        double r4620889 = -1.5426533532409758e-05;
        bool r4620890 = r4620888 <= r4620889;
        double r4620891 = -r4620882;
        double r4620892 = fma(r4620891, r4620881, r4620883);
        double r4620893 = -r4620883;
        double r4620894 = fma(r4620877, r4620877, r4620893);
        double r4620895 = r4620892 + r4620894;
        double r4620896 = sqrt(r4620895);
        double r4620897 = r4620896 + r4620886;
        double r4620898 = r4620897 / r4620881;
        double r4620899 = r4620882 / r4620877;
        double r4620900 = -0.5;
        double r4620901 = r4620899 * r4620900;
        double r4620902 = r4620890 ? r4620898 : r4620901;
        return r4620902;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) < -1.5426533532409758e-05

    1. Initial program 20.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied prod-diff20.5

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

    if -1.5426533532409758e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 52.0

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

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

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

Reproduce

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