Average Error: 44.1 → 10.1
Time: 18.2s
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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.00012965274390629056:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\ \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.00012965274390629056:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2663327 = b;
        double r2663328 = -r2663327;
        double r2663329 = r2663327 * r2663327;
        double r2663330 = 3.0;
        double r2663331 = a;
        double r2663332 = r2663330 * r2663331;
        double r2663333 = c;
        double r2663334 = r2663332 * r2663333;
        double r2663335 = r2663329 - r2663334;
        double r2663336 = sqrt(r2663335);
        double r2663337 = r2663328 + r2663336;
        double r2663338 = r2663337 / r2663332;
        return r2663338;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2663339 = b;
        double r2663340 = r2663339 * r2663339;
        double r2663341 = 3.0;
        double r2663342 = a;
        double r2663343 = r2663341 * r2663342;
        double r2663344 = c;
        double r2663345 = r2663343 * r2663344;
        double r2663346 = r2663340 - r2663345;
        double r2663347 = sqrt(r2663346);
        double r2663348 = -r2663339;
        double r2663349 = r2663347 + r2663348;
        double r2663350 = r2663349 / r2663343;
        double r2663351 = -0.00012965274390629056;
        bool r2663352 = r2663350 <= r2663351;
        double r2663353 = r2663344 * r2663342;
        double r2663354 = r2663353 * r2663341;
        double r2663355 = r2663340 - r2663354;
        double r2663356 = sqrt(r2663355);
        double r2663357 = r2663355 * r2663356;
        double r2663358 = r2663339 * r2663340;
        double r2663359 = r2663357 - r2663358;
        double r2663360 = r2663356 + r2663339;
        double r2663361 = fma(r2663356, r2663360, r2663340);
        double r2663362 = r2663359 / r2663361;
        double r2663363 = r2663362 / r2663343;
        double r2663364 = -0.5;
        double r2663365 = r2663344 / r2663339;
        double r2663366 = r2663364 * r2663365;
        double r2663367 = r2663352 ? r2663363 : r2663366;
        return r2663367;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -0.00012965274390629056

    1. Initial program 21.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip3-+21.5

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

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

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

    if -0.00012965274390629056 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 50.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 7.1

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

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

Reproduce

herbie shell --seed 2019134 +o rules:numerics
(FPCore (a b c d)
  :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)))