Average Error: 43.9 → 9.8
Time: 35.7s
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 -7.3943044717856285 \cdot 10^{-06}:\\ \;\;\;\;\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)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} + \mathsf{fma}\left(b, b, \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 -7.3943044717856285 \cdot 10^{-06}:\\
\;\;\;\;\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)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} + \mathsf{fma}\left(b, b, \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 r3892755 = b;
        double r3892756 = -r3892755;
        double r3892757 = r3892755 * r3892755;
        double r3892758 = 3.0;
        double r3892759 = a;
        double r3892760 = r3892758 * r3892759;
        double r3892761 = c;
        double r3892762 = r3892760 * r3892761;
        double r3892763 = r3892757 - r3892762;
        double r3892764 = sqrt(r3892763);
        double r3892765 = r3892756 + r3892764;
        double r3892766 = r3892765 / r3892760;
        return r3892766;
}

double f(double a, double b, double c) {
        double r3892767 = b;
        double r3892768 = r3892767 * r3892767;
        double r3892769 = 3.0;
        double r3892770 = a;
        double r3892771 = r3892769 * r3892770;
        double r3892772 = c;
        double r3892773 = r3892771 * r3892772;
        double r3892774 = r3892768 - r3892773;
        double r3892775 = sqrt(r3892774);
        double r3892776 = -r3892767;
        double r3892777 = r3892775 + r3892776;
        double r3892778 = r3892777 / r3892771;
        double r3892779 = -7.3943044717856285e-06;
        bool r3892780 = r3892778 <= r3892779;
        double r3892781 = r3892772 * r3892770;
        double r3892782 = -3.0;
        double r3892783 = r3892781 * r3892782;
        double r3892784 = fma(r3892767, r3892767, r3892783);
        double r3892785 = sqrt(r3892784);
        double r3892786 = r3892785 * r3892784;
        double r3892787 = r3892767 * r3892768;
        double r3892788 = r3892786 - r3892787;
        double r3892789 = r3892767 * r3892785;
        double r3892790 = fma(r3892767, r3892767, r3892784);
        double r3892791 = r3892789 + r3892790;
        double r3892792 = r3892788 / r3892791;
        double r3892793 = r3892792 / r3892771;
        double r3892794 = -0.5;
        double r3892795 = r3892772 / r3892767;
        double r3892796 = r3892794 * r3892795;
        double r3892797 = r3892780 ? r3892793 : r3892796;
        return r3892797;
}

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)) < -7.3943044717856285e-06

    1. Initial program 20.8

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

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

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

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

    if -7.3943044717856285e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 52.0

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

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied associate-/r*6.4

      \[\leadsto \color{blue}{\frac{\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{3}}{a}}\]
    5. Simplified6.3

      \[\leadsto \frac{\color{blue}{\left(\frac{-1}{2} \cdot \frac{a}{b}\right) \cdot c}}{a}\]
    6. Taylor expanded around 0 6.1

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

    \[\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 -7.3943044717856285 \cdot 10^{-06}:\\ \;\;\;\;\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)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} + \mathsf{fma}\left(b, b, \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 2019149 +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)))