Average Error: 28.6 → 16.1
Time: 17.1s
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 835.2343651472419878700748085975646972656:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{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 835.2343651472419878700748085975646972656:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2670173 = b;
        double r2670174 = -r2670173;
        double r2670175 = r2670173 * r2670173;
        double r2670176 = 3.0;
        double r2670177 = a;
        double r2670178 = r2670176 * r2670177;
        double r2670179 = c;
        double r2670180 = r2670178 * r2670179;
        double r2670181 = r2670175 - r2670180;
        double r2670182 = sqrt(r2670181);
        double r2670183 = r2670174 + r2670182;
        double r2670184 = r2670183 / r2670178;
        return r2670184;
}

double f(double a, double b, double c) {
        double r2670185 = b;
        double r2670186 = 835.234365147242;
        bool r2670187 = r2670185 <= r2670186;
        double r2670188 = r2670185 * r2670185;
        double r2670189 = c;
        double r2670190 = 3.0;
        double r2670191 = a;
        double r2670192 = r2670190 * r2670191;
        double r2670193 = r2670189 * r2670192;
        double r2670194 = r2670188 - r2670193;
        double r2670195 = r2670194 - r2670188;
        double r2670196 = sqrt(r2670194);
        double r2670197 = r2670185 + r2670196;
        double r2670198 = r2670195 / r2670197;
        double r2670199 = r2670198 / r2670192;
        double r2670200 = -0.5;
        double r2670201 = r2670189 / r2670185;
        double r2670202 = r2670200 * r2670201;
        double r2670203 = r2670187 ? r2670199 : r2670202;
        return r2670203;
}

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

    1. Initial program 16.8

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

      \[\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 flip--16.8

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

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

    if 835.234365147242 < b

    1. Initial program 36.3

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

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

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

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

Reproduce

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