Average Error: 34.2 → 15.5
Time: 5.5s
Precision: 64
\[\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 -2.0697892322852844 \cdot 10^{57}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 5.08229739317807349 \cdot 10^{-29}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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 -2.0697892322852844 \cdot 10^{57}:\\
\;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\

\mathbf{elif}\;b \le 5.08229739317807349 \cdot 10^{-29}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r89821 = b;
        double r89822 = -r89821;
        double r89823 = r89821 * r89821;
        double r89824 = 3.0;
        double r89825 = a;
        double r89826 = r89824 * r89825;
        double r89827 = c;
        double r89828 = r89826 * r89827;
        double r89829 = r89823 - r89828;
        double r89830 = sqrt(r89829);
        double r89831 = r89822 + r89830;
        double r89832 = r89831 / r89826;
        return r89832;
}

double f(double a, double b, double c) {
        double r89833 = b;
        double r89834 = -2.0697892322852844e+57;
        bool r89835 = r89833 <= r89834;
        double r89836 = 1.5;
        double r89837 = a;
        double r89838 = c;
        double r89839 = r89837 * r89838;
        double r89840 = r89839 / r89833;
        double r89841 = r89836 * r89840;
        double r89842 = 2.0;
        double r89843 = r89842 * r89833;
        double r89844 = r89841 - r89843;
        double r89845 = 3.0;
        double r89846 = r89845 * r89837;
        double r89847 = r89844 / r89846;
        double r89848 = 5.082297393178073e-29;
        bool r89849 = r89833 <= r89848;
        double r89850 = -r89833;
        double r89851 = cbrt(r89850);
        double r89852 = r89851 * r89851;
        double r89853 = r89833 * r89833;
        double r89854 = r89846 * r89838;
        double r89855 = r89853 - r89854;
        double r89856 = sqrt(r89855);
        double r89857 = fma(r89852, r89851, r89856);
        double r89858 = r89857 / r89846;
        double r89859 = -1.5;
        double r89860 = r89859 * r89840;
        double r89861 = r89860 / r89846;
        double r89862 = r89849 ? r89858 : r89861;
        double r89863 = r89835 ? r89847 : r89862;
        return r89863;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.0697892322852844e+57

    1. Initial program 39.2

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

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]

    if -2.0697892322852844e+57 < b < 5.082297393178073e-29

    1. Initial program 16.1

      \[\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-cube-cbrt16.3

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

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

    if 5.082297393178073e-29 < b

    1. Initial program 54.3

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.0697892322852844 \cdot 10^{57}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 5.08229739317807349 \cdot 10^{-29}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020033 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))