Average Error: 52.0 → 6.1
Time: 16.4s
Precision: 64
\[4.930380657631324 \cdot 10^{-32} \lt a \lt 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} \lt b \lt 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} \lt c \lt 2.028240960365167 \cdot 10^{+31}\]
\[\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 - c \cdot \left(3 \cdot a\right)} + \left(-b\right)}{3 \cdot a} \le -2.0351029443213164 \cdot 10^{-09}:\\ \;\;\;\;\sqrt[3]{\frac{\sqrt{\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)} - b}{3 \cdot a} \cdot \left(\frac{\sqrt{\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)} - b}{3 \cdot a} \cdot \frac{\sqrt{\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)} - b}{3 \cdot a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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}\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} + \left(-b\right)}{3 \cdot a} \le -2.0351029443213164 \cdot 10^{-09}:\\
\;\;\;\;\sqrt[3]{\frac{\sqrt{\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)} - b}{3 \cdot a} \cdot \left(\frac{\sqrt{\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)} - b}{3 \cdot a} \cdot \frac{\sqrt{\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)} - b}{3 \cdot a}\right)}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3199997 = b;
        double r3199998 = -r3199997;
        double r3199999 = r3199997 * r3199997;
        double r3200000 = 3.0;
        double r3200001 = a;
        double r3200002 = r3200000 * r3200001;
        double r3200003 = c;
        double r3200004 = r3200002 * r3200003;
        double r3200005 = r3199999 - r3200004;
        double r3200006 = sqrt(r3200005);
        double r3200007 = r3199998 + r3200006;
        double r3200008 = r3200007 / r3200002;
        return r3200008;
}

double f(double a, double b, double c) {
        double r3200009 = b;
        double r3200010 = r3200009 * r3200009;
        double r3200011 = c;
        double r3200012 = 3.0;
        double r3200013 = a;
        double r3200014 = r3200012 * r3200013;
        double r3200015 = r3200011 * r3200014;
        double r3200016 = r3200010 - r3200015;
        double r3200017 = sqrt(r3200016);
        double r3200018 = -r3200009;
        double r3200019 = r3200017 + r3200018;
        double r3200020 = r3200019 / r3200014;
        double r3200021 = -2.0351029443213164e-09;
        bool r3200022 = r3200020 <= r3200021;
        double r3200023 = -3.0;
        double r3200024 = r3200023 * r3200013;
        double r3200025 = fma(r3200011, r3200024, r3200010);
        double r3200026 = sqrt(r3200025);
        double r3200027 = r3200026 - r3200009;
        double r3200028 = r3200027 / r3200014;
        double r3200029 = r3200028 * r3200028;
        double r3200030 = r3200028 * r3200029;
        double r3200031 = cbrt(r3200030);
        double r3200032 = -0.5;
        double r3200033 = r3200011 / r3200009;
        double r3200034 = r3200032 * r3200033;
        double r3200035 = r3200022 ? r3200031 : r3200034;
        return r3200035;
}

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 a) c)))) (* 3 a)) < -2.0351029443213164e-09

    1. Initial program 23.4

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot \color{blue}{\sqrt[3]{\left(a \cdot a\right) \cdot a}}}\]
    4. Applied add-cbrt-cube23.5

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\sqrt[3]{\left(3 \cdot 3\right) \cdot 3}} \cdot \sqrt[3]{\left(a \cdot a\right) \cdot a}}\]
    5. Applied cbrt-unprod23.5

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\sqrt[3]{\left(\left(3 \cdot 3\right) \cdot 3\right) \cdot \left(\left(a \cdot a\right) \cdot a\right)}}}\]
    6. Applied add-cbrt-cube23.5

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{\sqrt[3]{\left(\left(3 \cdot 3\right) \cdot 3\right) \cdot \left(\left(a \cdot a\right) \cdot a\right)}}\]
    7. Applied cbrt-undiv23.5

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\left(\left(3 \cdot 3\right) \cdot 3\right) \cdot \left(\left(a \cdot a\right) \cdot a\right)}}}\]
    8. Simplified23.5

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

    if -2.0351029443213164e-09 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 57.7

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

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

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

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :pre (and (< 4.930380657631324e-32 a 2.028240960365167e+31) (< 4.930380657631324e-32 b 2.028240960365167e+31) (< 4.930380657631324e-32 c 2.028240960365167e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))