Average Error: 28.9 → 16.2
Time: 19.3s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\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 1699.5142564511543:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) + \left(b \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} + b \cdot b\right)}}{a \cdot 3}\\ \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 1699.5142564511543:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) + \left(b \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} + b \cdot b\right)}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3928072 = b;
        double r3928073 = -r3928072;
        double r3928074 = r3928072 * r3928072;
        double r3928075 = 3.0;
        double r3928076 = a;
        double r3928077 = r3928075 * r3928076;
        double r3928078 = c;
        double r3928079 = r3928077 * r3928078;
        double r3928080 = r3928074 - r3928079;
        double r3928081 = sqrt(r3928080);
        double r3928082 = r3928073 + r3928081;
        double r3928083 = r3928082 / r3928077;
        return r3928083;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3928084 = b;
        double r3928085 = 1699.5142564511543;
        bool r3928086 = r3928084 <= r3928085;
        double r3928087 = r3928084 * r3928084;
        double r3928088 = 3.0;
        double r3928089 = c;
        double r3928090 = r3928088 * r3928089;
        double r3928091 = a;
        double r3928092 = r3928090 * r3928091;
        double r3928093 = r3928087 - r3928092;
        double r3928094 = sqrt(r3928093);
        double r3928095 = r3928093 * r3928094;
        double r3928096 = r3928087 * r3928084;
        double r3928097 = r3928095 - r3928096;
        double r3928098 = r3928084 * r3928094;
        double r3928099 = r3928098 + r3928087;
        double r3928100 = r3928093 + r3928099;
        double r3928101 = r3928097 / r3928100;
        double r3928102 = r3928091 * r3928088;
        double r3928103 = r3928101 / r3928102;
        double r3928104 = -0.5;
        double r3928105 = r3928089 / r3928084;
        double r3928106 = r3928104 * r3928105;
        double r3928107 = r3928086 ? r3928103 : r3928106;
        return r3928107;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < 1699.5142564511543

    1. Initial program 17.6

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

      \[\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 flip3--17.7

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}^{3} - {b}^{3}}{\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 \cdot b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot b\right)}}}{3 \cdot a}\]
    5. Simplified17.0

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

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

    if 1699.5142564511543 < b

    1. Initial program 37.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified37.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 15.7

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt15.8

      \[\leadsto \frac{\frac{-3}{2} \cdot \frac{a \cdot c}{\color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{3 \cdot a}\]
    6. Applied times-frac15.8

      \[\leadsto \frac{\frac{-3}{2} \cdot \color{blue}{\left(\frac{a}{\sqrt{b}} \cdot \frac{c}{\sqrt{b}}\right)}}{3 \cdot a}\]
    7. Applied associate-*r*15.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1699.5142564511543:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) + \left(b \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} + b \cdot b\right)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019133 
(FPCore (a b c d)
  :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 a) c)))) (* 3 a)))