Average Error: 34.7 → 8.6
Time: 42.0s
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 -1.270528699455007486596308100489334356636 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 3.371096935837412091901713410518855444106 \cdot 10^{-203}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 6703153098321860493312:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{\left(3 \cdot a\right) \cdot c + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\ \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 -1.270528699455007486596308100489334356636 \cdot 10^{152}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

\mathbf{elif}\;b \le 6703153098321860493312:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{\left(3 \cdot a\right) \cdot c + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4294861 = b;
        double r4294862 = -r4294861;
        double r4294863 = r4294861 * r4294861;
        double r4294864 = 3.0;
        double r4294865 = a;
        double r4294866 = r4294864 * r4294865;
        double r4294867 = c;
        double r4294868 = r4294866 * r4294867;
        double r4294869 = r4294863 - r4294868;
        double r4294870 = sqrt(r4294869);
        double r4294871 = r4294862 + r4294870;
        double r4294872 = r4294871 / r4294866;
        return r4294872;
}

double f(double a, double b, double c) {
        double r4294873 = b;
        double r4294874 = -1.2705286994550075e+152;
        bool r4294875 = r4294873 <= r4294874;
        double r4294876 = 0.5;
        double r4294877 = c;
        double r4294878 = r4294877 / r4294873;
        double r4294879 = r4294876 * r4294878;
        double r4294880 = a;
        double r4294881 = r4294873 / r4294880;
        double r4294882 = 0.6666666666666666;
        double r4294883 = r4294881 * r4294882;
        double r4294884 = r4294879 - r4294883;
        double r4294885 = 3.371096935837412e-203;
        bool r4294886 = r4294873 <= r4294885;
        double r4294887 = r4294873 * r4294873;
        double r4294888 = 3.0;
        double r4294889 = r4294888 * r4294880;
        double r4294890 = r4294889 * r4294877;
        double r4294891 = r4294887 - r4294890;
        double r4294892 = sqrt(r4294891);
        double r4294893 = r4294892 - r4294873;
        double r4294894 = r4294893 / r4294888;
        double r4294895 = r4294894 / r4294880;
        double r4294896 = 6.70315309832186e+21;
        bool r4294897 = r4294873 <= r4294896;
        double r4294898 = 1.0;
        double r4294899 = r4294887 - r4294887;
        double r4294900 = r4294890 + r4294899;
        double r4294901 = -r4294873;
        double r4294902 = r4294901 - r4294892;
        double r4294903 = r4294900 / r4294902;
        double r4294904 = r4294889 / r4294903;
        double r4294905 = r4294898 / r4294904;
        double r4294906 = -0.5;
        double r4294907 = r4294906 * r4294878;
        double r4294908 = r4294897 ? r4294905 : r4294907;
        double r4294909 = r4294886 ? r4294895 : r4294908;
        double r4294910 = r4294875 ? r4294884 : r4294909;
        return r4294910;
}

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 4 regimes
  2. if b < -1.2705286994550075e+152

    1. Initial program 62.9

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

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

    if -1.2705286994550075e+152 < b < 3.371096935837412e-203

    1. Initial program 9.8

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    3. Simplified9.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - a \cdot \left(3 \cdot c\right)}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied associate-/r*9.8

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

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

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

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

    if 3.371096935837412e-203 < b < 6.70315309832186e+21

    1. Initial program 33.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 clear-num33.0

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\]
    4. Using strategy rm
    5. Applied flip-+33.1

      \[\leadsto \frac{1}{\frac{3 \cdot a}{\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}}}}}\]
    6. Simplified18.3

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

    if 6.70315309832186e+21 < b

    1. Initial program 56.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.270528699455007486596308100489334356636 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 3.371096935837412091901713410518855444106 \cdot 10^{-203}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 6703153098321860493312:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{\left(3 \cdot a\right) \cdot c + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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