Average Error: 28.4 → 16.7
Time: 19.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}\;b \le 60.51244836482759836826517130248248577118:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 3\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - a \cdot \left(c \cdot 3\right)\right) + b \cdot \left(b + \sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)}\right)}}{a \cdot 3}\\ \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 60.51244836482759836826517130248248577118:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 3\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - a \cdot \left(c \cdot 3\right)\right) + b \cdot \left(b + \sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)}\right)}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3393127 = b;
        double r3393128 = -r3393127;
        double r3393129 = r3393127 * r3393127;
        double r3393130 = 3.0;
        double r3393131 = a;
        double r3393132 = r3393130 * r3393131;
        double r3393133 = c;
        double r3393134 = r3393132 * r3393133;
        double r3393135 = r3393129 - r3393134;
        double r3393136 = sqrt(r3393135);
        double r3393137 = r3393128 + r3393136;
        double r3393138 = r3393137 / r3393132;
        return r3393138;
}

double f(double a, double b, double c) {
        double r3393139 = b;
        double r3393140 = 60.5124483648276;
        bool r3393141 = r3393139 <= r3393140;
        double r3393142 = r3393139 * r3393139;
        double r3393143 = a;
        double r3393144 = c;
        double r3393145 = 3.0;
        double r3393146 = r3393144 * r3393145;
        double r3393147 = r3393143 * r3393146;
        double r3393148 = r3393142 - r3393147;
        double r3393149 = sqrt(r3393148);
        double r3393150 = r3393148 * r3393149;
        double r3393151 = r3393142 * r3393139;
        double r3393152 = r3393150 - r3393151;
        double r3393153 = r3393139 + r3393149;
        double r3393154 = r3393139 * r3393153;
        double r3393155 = r3393148 + r3393154;
        double r3393156 = r3393152 / r3393155;
        double r3393157 = r3393143 * r3393145;
        double r3393158 = r3393156 / r3393157;
        double r3393159 = -0.5;
        double r3393160 = r3393144 / r3393139;
        double r3393161 = r3393159 * r3393160;
        double r3393162 = r3393141 ? r3393158 : r3393161;
        return r3393162;
}

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

    1. Initial program 14.5

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

      \[\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--14.6

      \[\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. Simplified13.9

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

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

    if 60.5124483648276 < b

    1. Initial program 34.2

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

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

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

Reproduce

herbie shell --seed 2019172 
(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)))