Average Error: 34.6 → 10.5
Time: 20.3s
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.8920328608199634 \cdot 10^{82}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.45811587950602871 \cdot 10^{-136}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a \cdot 3} - \frac{b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \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 -2.8920328608199634 \cdot 10^{82}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 2.45811587950602871 \cdot 10^{-136}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a \cdot 3} - \frac{b}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c) {
        double r84890 = b;
        double r84891 = -r84890;
        double r84892 = r84890 * r84890;
        double r84893 = 3.0;
        double r84894 = a;
        double r84895 = r84893 * r84894;
        double r84896 = c;
        double r84897 = r84895 * r84896;
        double r84898 = r84892 - r84897;
        double r84899 = sqrt(r84898);
        double r84900 = r84891 + r84899;
        double r84901 = r84900 / r84895;
        return r84901;
}

double f(double a, double b, double c) {
        double r84902 = b;
        double r84903 = -2.8920328608199634e+82;
        bool r84904 = r84902 <= r84903;
        double r84905 = 0.5;
        double r84906 = c;
        double r84907 = r84906 / r84902;
        double r84908 = r84905 * r84907;
        double r84909 = 0.6666666666666666;
        double r84910 = a;
        double r84911 = r84902 / r84910;
        double r84912 = r84909 * r84911;
        double r84913 = r84908 - r84912;
        double r84914 = 2.4581158795060287e-136;
        bool r84915 = r84902 <= r84914;
        double r84916 = r84902 * r84902;
        double r84917 = 3.0;
        double r84918 = r84917 * r84910;
        double r84919 = r84918 * r84906;
        double r84920 = r84916 - r84919;
        double r84921 = sqrt(r84920);
        double r84922 = r84910 * r84917;
        double r84923 = r84921 / r84922;
        double r84924 = r84902 / r84922;
        double r84925 = r84923 - r84924;
        double r84926 = -0.5;
        double r84927 = r84926 * r84907;
        double r84928 = r84915 ? r84925 : r84927;
        double r84929 = r84904 ? r84913 : r84928;
        return r84929;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -2.8920328608199634e+82

    1. Initial program 44.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified44.3

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}}\]
    3. Taylor expanded around -inf 4.1

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}}\]

    if -2.8920328608199634e+82 < b < 2.4581158795060287e-136

    1. Initial program 11.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified11.8

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}}\]
    3. Using strategy rm
    4. Applied div-inv11.9

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{\frac{a}{\frac{1}{3}}}}\]
    6. Simplified11.7

      \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{\color{blue}{a \cdot 3}}\]
    7. Using strategy rm
    8. Applied div-sub11.7

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

    if 2.4581158795060287e-136 < b

    1. Initial program 50.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified50.8

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}}\]
    3. Taylor expanded around inf 12.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.8920328608199634 \cdot 10^{82}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.45811587950602871 \cdot 10^{-136}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a \cdot 3} - \frac{b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019199 
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))