Average Error: 44.4 → 11.3
Time: 13.3s
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 3.826212081602258 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(3 \cdot c\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\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)}}{a \cdot 3}\\ \mathbf{elif}\;b \le 0.015132399096455612:\\ \;\;\;\;\frac{\left(\frac{a}{\sqrt{b}} \cdot \frac{-3}{2}\right) \cdot \frac{c}{\sqrt{b}}}{a \cdot 3}\\ \mathbf{elif}\;b \le 1.3718256577401997:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(3 \cdot c\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\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)}}{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 3.826212081602258 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(3 \cdot c\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\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)}}{a \cdot 3}\\

\mathbf{elif}\;b \le 0.015132399096455612:\\
\;\;\;\;\frac{\left(\frac{a}{\sqrt{b}} \cdot \frac{-3}{2}\right) \cdot \frac{c}{\sqrt{b}}}{a \cdot 3}\\

\mathbf{elif}\;b \le 1.3718256577401997:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(3 \cdot c\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\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)}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1698224 = b;
        double r1698225 = -r1698224;
        double r1698226 = r1698224 * r1698224;
        double r1698227 = 3.0;
        double r1698228 = a;
        double r1698229 = r1698227 * r1698228;
        double r1698230 = c;
        double r1698231 = r1698229 * r1698230;
        double r1698232 = r1698226 - r1698231;
        double r1698233 = sqrt(r1698232);
        double r1698234 = r1698225 + r1698233;
        double r1698235 = r1698234 / r1698229;
        return r1698235;
}

double f(double a, double b, double c) {
        double r1698236 = b;
        double r1698237 = 3.826212081602258e-05;
        bool r1698238 = r1698236 <= r1698237;
        double r1698239 = r1698236 * r1698236;
        double r1698240 = a;
        double r1698241 = 3.0;
        double r1698242 = c;
        double r1698243 = r1698241 * r1698242;
        double r1698244 = r1698240 * r1698243;
        double r1698245 = r1698239 - r1698244;
        double r1698246 = sqrt(r1698245);
        double r1698247 = r1698245 * r1698246;
        double r1698248 = r1698239 * r1698236;
        double r1698249 = r1698247 - r1698248;
        double r1698250 = r1698236 * r1698246;
        double r1698251 = r1698250 + r1698239;
        double r1698252 = r1698245 + r1698251;
        double r1698253 = r1698249 / r1698252;
        double r1698254 = r1698240 * r1698241;
        double r1698255 = r1698253 / r1698254;
        double r1698256 = 0.015132399096455612;
        bool r1698257 = r1698236 <= r1698256;
        double r1698258 = sqrt(r1698236);
        double r1698259 = r1698240 / r1698258;
        double r1698260 = -1.5;
        double r1698261 = r1698259 * r1698260;
        double r1698262 = r1698242 / r1698258;
        double r1698263 = r1698261 * r1698262;
        double r1698264 = r1698263 / r1698254;
        double r1698265 = 1.3718256577401997;
        bool r1698266 = r1698236 <= r1698265;
        double r1698267 = -0.5;
        double r1698268 = r1698242 / r1698236;
        double r1698269 = r1698267 * r1698268;
        double r1698270 = r1698266 ? r1698255 : r1698269;
        double r1698271 = r1698257 ? r1698264 : r1698270;
        double r1698272 = r1698238 ? r1698255 : r1698271;
        return r1698272;
}

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 3 regimes
  2. if b < 3.826212081602258e-05 or 0.015132399096455612 < b < 1.3718256577401997

    1. Initial program 24.8

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

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

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

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

    if 3.826212081602258e-05 < b < 0.015132399096455612

    1. Initial program 26.4

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

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

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

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

      \[\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*24.9

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

    if 1.3718256577401997 < b

    1. Initial program 48.0

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

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

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Taylor expanded around 0 8.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 3.826212081602258 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(3 \cdot c\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\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)}}{a \cdot 3}\\ \mathbf{elif}\;b \le 0.015132399096455612:\\ \;\;\;\;\frac{\left(\frac{a}{\sqrt{b}} \cdot \frac{-3}{2}\right) \cdot \frac{c}{\sqrt{b}}}{a \cdot 3}\\ \mathbf{elif}\;b \le 1.3718256577401997:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(3 \cdot c\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\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)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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