Average Error: 33.2 → 10.0
Time: 18.1s
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.1550838670737497 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 5.930445637544082 \cdot 10^{-86}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \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 -2.1550838670737497 \cdot 10^{+152}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4537905 = b;
        double r4537906 = -r4537905;
        double r4537907 = r4537905 * r4537905;
        double r4537908 = 3.0;
        double r4537909 = a;
        double r4537910 = r4537908 * r4537909;
        double r4537911 = c;
        double r4537912 = r4537910 * r4537911;
        double r4537913 = r4537907 - r4537912;
        double r4537914 = sqrt(r4537913);
        double r4537915 = r4537906 + r4537914;
        double r4537916 = r4537915 / r4537910;
        return r4537916;
}

double f(double a, double b, double c) {
        double r4537917 = b;
        double r4537918 = -2.1550838670737497e+152;
        bool r4537919 = r4537917 <= r4537918;
        double r4537920 = 0.5;
        double r4537921 = c;
        double r4537922 = r4537921 / r4537917;
        double r4537923 = r4537920 * r4537922;
        double r4537924 = a;
        double r4537925 = r4537917 / r4537924;
        double r4537926 = 0.6666666666666666;
        double r4537927 = r4537925 * r4537926;
        double r4537928 = r4537923 - r4537927;
        double r4537929 = 5.930445637544082e-86;
        bool r4537930 = r4537917 <= r4537929;
        double r4537931 = r4537917 * r4537917;
        double r4537932 = 3.0;
        double r4537933 = r4537932 * r4537924;
        double r4537934 = r4537933 * r4537921;
        double r4537935 = r4537931 - r4537934;
        double r4537936 = sqrt(r4537935);
        double r4537937 = r4537936 - r4537917;
        double r4537938 = r4537937 / r4537933;
        double r4537939 = -0.5;
        double r4537940 = r4537939 * r4537922;
        double r4537941 = r4537930 ? r4537938 : r4537940;
        double r4537942 = r4537919 ? r4537928 : r4537941;
        return r4537942;
}

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.1550838670737497e+152

    1. Initial program 60.0

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

      \[\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.6

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

    if -2.1550838670737497e+152 < b < 5.930445637544082e-86

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

      \[\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 div-inv11.8

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

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

    if 5.930445637544082e-86 < b

    1. Initial program 52.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.1550838670737497 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 5.930445637544082 \cdot 10^{-86}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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