Average Error: 28.7 → 14.3
Time: 42.0s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.514396250744807153068517604349585425894 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{b \cdot b - \left(b \cdot b - \left(3 \cdot a\right) \cdot c\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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.514396250744807153068517604349585425894 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{b \cdot b - \left(b \cdot b - \left(3 \cdot a\right) \cdot c\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 r3829838 = b;
        double r3829839 = -r3829838;
        double r3829840 = r3829838 * r3829838;
        double r3829841 = 3.0;
        double r3829842 = a;
        double r3829843 = r3829841 * r3829842;
        double r3829844 = c;
        double r3829845 = r3829843 * r3829844;
        double r3829846 = r3829840 - r3829845;
        double r3829847 = sqrt(r3829846);
        double r3829848 = r3829839 + r3829847;
        double r3829849 = r3829848 / r3829843;
        return r3829849;
}

double f(double a, double b, double c) {
        double r3829850 = b;
        double r3829851 = r3829850 * r3829850;
        double r3829852 = 3.0;
        double r3829853 = a;
        double r3829854 = r3829852 * r3829853;
        double r3829855 = c;
        double r3829856 = r3829854 * r3829855;
        double r3829857 = r3829851 - r3829856;
        double r3829858 = sqrt(r3829857);
        double r3829859 = -r3829850;
        double r3829860 = r3829858 + r3829859;
        double r3829861 = r3829860 / r3829854;
        double r3829862 = -2.514396250744807e-07;
        bool r3829863 = r3829861 <= r3829862;
        double r3829864 = r3829851 - r3829857;
        double r3829865 = r3829859 - r3829858;
        double r3829866 = r3829864 / r3829865;
        double r3829867 = r3829866 / r3829854;
        double r3829868 = -0.5;
        double r3829869 = r3829855 / r3829850;
        double r3829870 = r3829868 * r3829869;
        double r3829871 = r3829863 ? r3829867 : r3829870;
        return r3829871;
}

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) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) < -2.514396250744807e-07

    1. Initial program 18.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-+18.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. Simplified17.2

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

    if -2.514396250744807e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 44.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.514396250744807153068517604349585425894 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{b \cdot b - \left(b \cdot b - \left(3 \cdot a\right) \cdot c\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 2019168 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))