Average Error: 43.2 → 11.7
Time: 18.8s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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.143841598112384838194601800742677966127 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{3 \cdot 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.143841598112384838194601800742677966127 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4197841 = b;
        double r4197842 = -r4197841;
        double r4197843 = r4197841 * r4197841;
        double r4197844 = 3.0;
        double r4197845 = a;
        double r4197846 = r4197844 * r4197845;
        double r4197847 = c;
        double r4197848 = r4197846 * r4197847;
        double r4197849 = r4197843 - r4197848;
        double r4197850 = sqrt(r4197849);
        double r4197851 = r4197842 + r4197850;
        double r4197852 = r4197851 / r4197846;
        return r4197852;
}

double f(double a, double b, double c) {
        double r4197853 = b;
        double r4197854 = 1.1438415981123848e-06;
        bool r4197855 = r4197853 <= r4197854;
        double r4197856 = r4197853 * r4197853;
        double r4197857 = c;
        double r4197858 = 3.0;
        double r4197859 = a;
        double r4197860 = r4197858 * r4197859;
        double r4197861 = r4197857 * r4197860;
        double r4197862 = r4197856 - r4197861;
        double r4197863 = r4197862 - r4197856;
        double r4197864 = sqrt(r4197862);
        double r4197865 = r4197853 + r4197864;
        double r4197866 = r4197863 / r4197865;
        double r4197867 = r4197866 / r4197860;
        double r4197868 = -0.5;
        double r4197869 = r4197857 / r4197853;
        double r4197870 = r4197868 * r4197869;
        double r4197871 = r4197855 ? r4197867 : r4197870;
        return r4197871;
}

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 2 regimes
  2. if b < 1.1438415981123848e-06

    1. Initial program 14.9

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

      \[\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 flip--14.9

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

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

    if 1.1438415981123848e-06 < b

    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{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Taylor expanded around inf 11.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.143841598112384838194601800742677966127 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))