Average Error: 44.1 → 11.1
Time: 26.5s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\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.6209007775013438 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b + \left(a \cdot c\right) \cdot -3\right) \cdot \sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(b \cdot b + \left(a \cdot c\right) \cdot -3\right)\right) + b \cdot \sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3}}}{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 1.6209007775013438 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b + \left(a \cdot c\right) \cdot -3\right) \cdot \sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(b \cdot b + \left(a \cdot c\right) \cdot -3\right)\right) + b \cdot \sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3}}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4643059 = b;
        double r4643060 = -r4643059;
        double r4643061 = r4643059 * r4643059;
        double r4643062 = 3.0;
        double r4643063 = a;
        double r4643064 = r4643062 * r4643063;
        double r4643065 = c;
        double r4643066 = r4643064 * r4643065;
        double r4643067 = r4643061 - r4643066;
        double r4643068 = sqrt(r4643067);
        double r4643069 = r4643060 + r4643068;
        double r4643070 = r4643069 / r4643064;
        return r4643070;
}

double f(double a, double b, double c) {
        double r4643071 = b;
        double r4643072 = 1.6209007775013438e-05;
        bool r4643073 = r4643071 <= r4643072;
        double r4643074 = r4643071 * r4643071;
        double r4643075 = a;
        double r4643076 = c;
        double r4643077 = r4643075 * r4643076;
        double r4643078 = -3.0;
        double r4643079 = r4643077 * r4643078;
        double r4643080 = r4643074 + r4643079;
        double r4643081 = sqrt(r4643080);
        double r4643082 = r4643080 * r4643081;
        double r4643083 = r4643074 * r4643071;
        double r4643084 = r4643082 - r4643083;
        double r4643085 = r4643074 + r4643080;
        double r4643086 = r4643071 * r4643081;
        double r4643087 = r4643085 + r4643086;
        double r4643088 = r4643084 / r4643087;
        double r4643089 = 3.0;
        double r4643090 = r4643075 * r4643089;
        double r4643091 = r4643088 / r4643090;
        double r4643092 = -0.5;
        double r4643093 = r4643076 / r4643071;
        double r4643094 = r4643092 * r4643093;
        double r4643095 = r4643073 ? r4643091 : r4643094;
        return r4643095;
}

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.6209007775013438e-05

    1. Initial program 17.7

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

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

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

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

    if 1.6209007775013438e-05 < b

    1. Initial program 45.5

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

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

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

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

Reproduce

herbie shell --seed 2019158 
(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 a) c)))) (* 3 a)))