Average Error: 52.0 → 6.1
Time: 15.3s
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 r2345653 = b;
        double r2345654 = -r2345653;
        double r2345655 = r2345653 * r2345653;
        double r2345656 = 3.0;
        double r2345657 = a;
        double r2345658 = r2345656 * r2345657;
        double r2345659 = c;
        double r2345660 = r2345658 * r2345659;
        double r2345661 = r2345655 - r2345660;
        double r2345662 = sqrt(r2345661);
        double r2345663 = r2345654 + r2345662;
        double r2345664 = r2345663 / r2345658;
        return r2345664;
}

double f(double a, double b, double c) {
        double r2345665 = b;
        double r2345666 = r2345665 * r2345665;
        double r2345667 = c;
        double r2345668 = 3.0;
        double r2345669 = a;
        double r2345670 = r2345668 * r2345669;
        double r2345671 = r2345667 * r2345670;
        double r2345672 = r2345666 - r2345671;
        double r2345673 = sqrt(r2345672);
        double r2345674 = -r2345665;
        double r2345675 = r2345673 + r2345674;
        double r2345676 = r2345675 / r2345670;
        double r2345677 = -2.0351029443213164e-09;
        bool r2345678 = r2345676 <= r2345677;
        double r2345679 = -3.0;
        double r2345680 = r2345679 * r2345669;
        double r2345681 = fma(r2345667, r2345680, r2345666);
        double r2345682 = sqrt(r2345681);
        double r2345683 = r2345682 - r2345665;
        double r2345684 = r2345683 / r2345670;
        double r2345685 = r2345684 * r2345684;
        double r2345686 = r2345684 * r2345685;
        double r2345687 = cbrt(r2345686);
        double r2345688 = -0.5;
        double r2345689 = r2345667 / r2345665;
        double r2345690 = r2345688 * r2345689;
        double r2345691 = r2345678 ? r2345687 : r2345690;
        return r2345691;
}

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)))