Average Error: 43.9 → 10.9
Time: 13.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 3.648715584836924622977316623462229472352 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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 3.648715584836924622977316623462229472352 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{b \cdot b - \left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r90851 = b;
        double r90852 = -r90851;
        double r90853 = r90851 * r90851;
        double r90854 = 3.0;
        double r90855 = a;
        double r90856 = r90854 * r90855;
        double r90857 = c;
        double r90858 = r90856 * r90857;
        double r90859 = r90853 - r90858;
        double r90860 = sqrt(r90859);
        double r90861 = r90852 + r90860;
        double r90862 = r90861 / r90856;
        return r90862;
}

double f(double a, double b, double c) {
        double r90863 = b;
        double r90864 = 0.00036487155848369246;
        bool r90865 = r90863 <= r90864;
        double r90866 = r90863 * r90863;
        double r90867 = 3.0;
        double r90868 = a;
        double r90869 = c;
        double r90870 = r90868 * r90869;
        double r90871 = r90867 * r90870;
        double r90872 = r90866 - r90871;
        double r90873 = r90866 - r90872;
        double r90874 = -r90863;
        double r90875 = r90867 * r90868;
        double r90876 = r90875 * r90869;
        double r90877 = r90866 - r90876;
        double r90878 = sqrt(r90877);
        double r90879 = r90874 - r90878;
        double r90880 = r90873 / r90879;
        double r90881 = r90880 / r90875;
        double r90882 = -0.5;
        double r90883 = r90869 / r90863;
        double r90884 = r90882 * r90883;
        double r90885 = r90865 ? r90881 : r90884;
        return r90885;
}

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

    1. Initial program 19.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+19.2

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

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

    if 0.00036487155848369246 < b

    1. Initial program 46.0

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

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

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

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e15) (< 1.11022e-16 b 9.0072e15) (< 1.11022e-16 c 9.0072e15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))