Average Error: 34.7 → 10.3
Time: 40.6s
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 1.744031351412432972171902712116585209201 \cdot 10^{-142}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3}}{a}\\ \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 1.744031351412432972171902712116585209201 \cdot 10^{-142}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4769877 = b;
        double r4769878 = -r4769877;
        double r4769879 = r4769877 * r4769877;
        double r4769880 = 3.0;
        double r4769881 = a;
        double r4769882 = r4769880 * r4769881;
        double r4769883 = c;
        double r4769884 = r4769882 * r4769883;
        double r4769885 = r4769879 - r4769884;
        double r4769886 = sqrt(r4769885);
        double r4769887 = r4769878 + r4769886;
        double r4769888 = r4769887 / r4769882;
        return r4769888;
}

double f(double a, double b, double c) {
        double r4769889 = b;
        double r4769890 = -1.2705286994550075e+152;
        bool r4769891 = r4769889 <= r4769890;
        double r4769892 = 0.5;
        double r4769893 = c;
        double r4769894 = r4769893 / r4769889;
        double r4769895 = r4769892 * r4769894;
        double r4769896 = a;
        double r4769897 = r4769889 / r4769896;
        double r4769898 = 0.6666666666666666;
        double r4769899 = r4769897 * r4769898;
        double r4769900 = r4769895 - r4769899;
        double r4769901 = 1.744031351412433e-142;
        bool r4769902 = r4769889 <= r4769901;
        double r4769903 = r4769889 * r4769889;
        double r4769904 = 3.0;
        double r4769905 = r4769893 * r4769904;
        double r4769906 = r4769896 * r4769905;
        double r4769907 = r4769903 - r4769906;
        double r4769908 = sqrt(r4769907);
        double r4769909 = r4769908 - r4769889;
        double r4769910 = r4769909 / r4769904;
        double r4769911 = r4769910 / r4769896;
        double r4769912 = -0.5;
        double r4769913 = r4769912 * r4769894;
        double r4769914 = r4769902 ? r4769911 : r4769913;
        double r4769915 = r4769891 ? r4769900 : r4769914;
        return r4769915;
}

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 < -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. Simplified62.9

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. 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 < 1.744031351412433e-142

    1. Initial program 10.5

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

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

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}}\]
    6. Using strategy rm
    7. Applied associate-*r/10.6

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

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

    if 1.744031351412433e-142 < b

    1. Initial program 50.6

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

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

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

    \[\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 1.744031351412432972171902712116585209201 \cdot 10^{-142}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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