Average Error: 43.9 → 10.6
Time: 14.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 -0.04915284035387407:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}\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.04915284035387407:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3690748 = b;
        double r3690749 = -r3690748;
        double r3690750 = r3690748 * r3690748;
        double r3690751 = 3.0;
        double r3690752 = a;
        double r3690753 = r3690751 * r3690752;
        double r3690754 = c;
        double r3690755 = r3690753 * r3690754;
        double r3690756 = r3690750 - r3690755;
        double r3690757 = sqrt(r3690756);
        double r3690758 = r3690749 + r3690757;
        double r3690759 = r3690758 / r3690753;
        return r3690759;
}

double f(double a, double b, double c) {
        double r3690760 = b;
        double r3690761 = r3690760 * r3690760;
        double r3690762 = 3.0;
        double r3690763 = a;
        double r3690764 = r3690762 * r3690763;
        double r3690765 = c;
        double r3690766 = r3690764 * r3690765;
        double r3690767 = r3690761 - r3690766;
        double r3690768 = sqrt(r3690767);
        double r3690769 = -r3690760;
        double r3690770 = r3690768 + r3690769;
        double r3690771 = r3690770 / r3690764;
        double r3690772 = -0.04915284035387407;
        bool r3690773 = r3690771 <= r3690772;
        double r3690774 = r3690765 * r3690763;
        double r3690775 = -3.0;
        double r3690776 = r3690774 * r3690775;
        double r3690777 = fma(r3690760, r3690760, r3690776);
        double r3690778 = sqrt(r3690777);
        double r3690779 = r3690778 * r3690777;
        double r3690780 = r3690760 * r3690761;
        double r3690781 = r3690779 - r3690780;
        double r3690782 = r3690760 * r3690778;
        double r3690783 = r3690777 + r3690782;
        double r3690784 = fma(r3690760, r3690760, r3690783);
        double r3690785 = r3690781 / r3690784;
        double r3690786 = r3690785 / r3690764;
        double r3690787 = -0.5;
        double r3690788 = r3690765 / r3690760;
        double r3690789 = r3690787 * r3690788;
        double r3690790 = r3690773 ? r3690786 : r3690789;
        return r3690790;
}

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)) < -0.04915284035387407

    1. Initial program 21.1

      \[\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.2

      \[\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.5

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

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

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

    1. Initial program 48.6

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

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

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

Reproduce

herbie shell --seed 2019164 +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)))