Average Error: 43.7 → 10.1
Time: 32.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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -5.702004622527394 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + 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 -5.702004622527394 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + 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 r3638414 = b;
        double r3638415 = -r3638414;
        double r3638416 = r3638414 * r3638414;
        double r3638417 = 3.0;
        double r3638418 = a;
        double r3638419 = r3638417 * r3638418;
        double r3638420 = c;
        double r3638421 = r3638419 * r3638420;
        double r3638422 = r3638416 - r3638421;
        double r3638423 = sqrt(r3638422);
        double r3638424 = r3638415 + r3638423;
        double r3638425 = r3638424 / r3638419;
        return r3638425;
}

double f(double a, double b, double c) {
        double r3638426 = b;
        double r3638427 = r3638426 * r3638426;
        double r3638428 = 3.0;
        double r3638429 = a;
        double r3638430 = r3638428 * r3638429;
        double r3638431 = c;
        double r3638432 = r3638430 * r3638431;
        double r3638433 = r3638427 - r3638432;
        double r3638434 = sqrt(r3638433);
        double r3638435 = -r3638426;
        double r3638436 = r3638434 + r3638435;
        double r3638437 = r3638436 / r3638430;
        double r3638438 = -5.702004622527394e-10;
        bool r3638439 = r3638437 <= r3638438;
        double r3638440 = -3.0;
        double r3638441 = r3638440 * r3638431;
        double r3638442 = fma(r3638429, r3638441, r3638427);
        double r3638443 = sqrt(r3638442);
        double r3638444 = r3638442 * r3638443;
        double r3638445 = r3638426 * r3638427;
        double r3638446 = r3638444 - r3638445;
        double r3638447 = r3638443 + r3638426;
        double r3638448 = fma(r3638443, r3638447, r3638427);
        double r3638449 = r3638446 / r3638448;
        double r3638450 = r3638449 / r3638430;
        double r3638451 = -0.5;
        double r3638452 = r3638431 / r3638426;
        double r3638453 = r3638451 * r3638452;
        double r3638454 = r3638439 ? r3638450 : r3638453;
        return r3638454;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 22.2

      \[\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-+22.3

      \[\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. Simplified21.6

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} \cdot \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\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. Simplified21.6

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

    if -5.702004622527394e-10 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 55.7

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

      \[\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 -5.702004622527394 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + b, b \cdot b\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019141 +o rules:numerics
(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)))