Average Error: 33.3 → 7.1
Time: 5.5m
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 -8.051625061919553 \cdot 10^{+68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{3}{2}, \left(\frac{a}{\frac{b}{c}}\right), \left(b \cdot -2\right)\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le -2.959343619656092 \cdot 10^{-128}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\left(\sqrt[3]{b} \cdot \left(-\sqrt[3]{b}\right)\right), \left(\sqrt[3]{b}\right), \left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.6108067723837524 \cdot 10^{+115}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\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}\;b \le -8.051625061919553 \cdot 10^{+68}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{3}{2}, \left(\frac{a}{\frac{b}{c}}\right), \left(b \cdot -2\right)\right)}{3 \cdot a}\\

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

\mathbf{elif}\;b \le 1.6108067723837524 \cdot 10^{+115}:\\
\;\;\;\;\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r33059834 = b;
        double r33059835 = -r33059834;
        double r33059836 = r33059834 * r33059834;
        double r33059837 = 3.0;
        double r33059838 = a;
        double r33059839 = r33059837 * r33059838;
        double r33059840 = c;
        double r33059841 = r33059839 * r33059840;
        double r33059842 = r33059836 - r33059841;
        double r33059843 = sqrt(r33059842);
        double r33059844 = r33059835 + r33059843;
        double r33059845 = r33059844 / r33059839;
        return r33059845;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r33059846 = b;
        double r33059847 = -8.051625061919553e+68;
        bool r33059848 = r33059846 <= r33059847;
        double r33059849 = 1.5;
        double r33059850 = a;
        double r33059851 = c;
        double r33059852 = r33059846 / r33059851;
        double r33059853 = r33059850 / r33059852;
        double r33059854 = -2.0;
        double r33059855 = r33059846 * r33059854;
        double r33059856 = fma(r33059849, r33059853, r33059855);
        double r33059857 = 3.0;
        double r33059858 = r33059857 * r33059850;
        double r33059859 = r33059856 / r33059858;
        double r33059860 = -2.959343619656092e-128;
        bool r33059861 = r33059846 <= r33059860;
        double r33059862 = cbrt(r33059846);
        double r33059863 = -r33059862;
        double r33059864 = r33059862 * r33059863;
        double r33059865 = r33059846 * r33059846;
        double r33059866 = r33059858 * r33059851;
        double r33059867 = r33059865 - r33059866;
        double r33059868 = sqrt(r33059867);
        double r33059869 = fma(r33059864, r33059862, r33059868);
        double r33059870 = r33059869 / r33059858;
        double r33059871 = 1.6108067723837524e+115;
        bool r33059872 = r33059846 <= r33059871;
        double r33059873 = -r33059846;
        double r33059874 = -3.0;
        double r33059875 = r33059874 * r33059850;
        double r33059876 = fma(r33059851, r33059875, r33059865);
        double r33059877 = sqrt(r33059876);
        double r33059878 = r33059873 - r33059877;
        double r33059879 = r33059851 / r33059878;
        double r33059880 = -0.5;
        double r33059881 = r33059851 / r33059846;
        double r33059882 = r33059880 * r33059881;
        double r33059883 = r33059872 ? r33059879 : r33059882;
        double r33059884 = r33059861 ? r33059870 : r33059883;
        double r33059885 = r33059848 ? r33059859 : r33059884;
        return r33059885;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 4 regimes
  2. if b < -8.051625061919553e+68

    1. Initial program 38.9

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

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

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

    if -8.051625061919553e+68 < b < -2.959343619656092e-128

    1. Initial program 6.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-cube-cbrt6.7

      \[\leadsto \frac{\left(-\color{blue}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    4. Applied distribute-lft-neg-in6.7

      \[\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}\]
    5. Applied fma-def6.7

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

    if -2.959343619656092e-128 < b < 1.6108067723837524e+115

    1. Initial program 28.0

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

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

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(3 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity16.4

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    7. Applied *-un-lft-identity16.4

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    8. Applied distribute-lft-out--16.4

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    9. Applied times-frac15.8

      \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    10. Applied associate-/l*12.2

      \[\leadsto \color{blue}{\frac{\frac{c}{1}}{\frac{3 \cdot a}{\frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}\]
    11. Simplified10.8

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

    if 1.6108067723837524e+115 < b

    1. Initial program 59.6

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

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

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(3 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity33.3

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    7. Applied *-un-lft-identity33.3

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    8. Applied distribute-lft-out--33.3

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    9. Applied times-frac33.9

      \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    10. Applied associate-/l*33.6

      \[\leadsto \color{blue}{\frac{\frac{c}{1}}{\frac{3 \cdot a}{\frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}\]
    11. Simplified31.8

      \[\leadsto \frac{\frac{c}{1}}{\color{blue}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)}}}\]
    12. Using strategy rm
    13. Applied add-sqr-sqrt31.8

      \[\leadsto \frac{\frac{c}{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)}}\]
    14. Applied *-un-lft-identity31.8

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot c}}{\sqrt{1} \cdot \sqrt{1}}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)}}\]
    15. Applied times-frac31.8

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1}} \cdot \frac{c}{\sqrt{1}}}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)}}\]
    16. Applied associate-/l*32.0

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

      \[\leadsto \frac{\frac{1}{\sqrt{1}}}{\color{blue}{-\frac{b + \sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)}}{c}}}\]
    18. Taylor expanded around inf 2.1

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

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

Reproduce

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