Average Error: 44.4 → 10.2
Time: 32.1s
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.08079221226609472:\\ \;\;\;\;\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{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.0021130712332977203:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{1}{\frac{b}{c \cdot a}}}{3 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.045888882004455 \cdot 10^{-07}:\\ \;\;\;\;\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{c}{b} \cdot \frac{-1}{2}\\ \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.08079221226609472:\\
\;\;\;\;\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{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.0021130712332977203:\\
\;\;\;\;\frac{\frac{-3}{2} \cdot \frac{1}{\frac{b}{c \cdot a}}}{3 \cdot a}\\

\mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.045888882004455 \cdot 10^{-07}:\\
\;\;\;\;\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{c}{b} \cdot \frac{-1}{2}\\

\end{array}
double f(double a, double b, double c) {
        double r4206693 = b;
        double r4206694 = -r4206693;
        double r4206695 = r4206693 * r4206693;
        double r4206696 = 3.0;
        double r4206697 = a;
        double r4206698 = r4206696 * r4206697;
        double r4206699 = c;
        double r4206700 = r4206698 * r4206699;
        double r4206701 = r4206695 - r4206700;
        double r4206702 = sqrt(r4206701);
        double r4206703 = r4206694 + r4206702;
        double r4206704 = r4206703 / r4206698;
        return r4206704;
}

double f(double a, double b, double c) {
        double r4206705 = b;
        double r4206706 = r4206705 * r4206705;
        double r4206707 = 3.0;
        double r4206708 = a;
        double r4206709 = r4206707 * r4206708;
        double r4206710 = c;
        double r4206711 = r4206709 * r4206710;
        double r4206712 = r4206706 - r4206711;
        double r4206713 = sqrt(r4206712);
        double r4206714 = -r4206705;
        double r4206715 = r4206713 + r4206714;
        double r4206716 = r4206715 / r4206709;
        double r4206717 = -0.08079221226609472;
        bool r4206718 = r4206716 <= r4206717;
        double r4206719 = r4206710 * r4206708;
        double r4206720 = -3.0;
        double r4206721 = r4206719 * r4206720;
        double r4206722 = fma(r4206705, r4206705, r4206721);
        double r4206723 = sqrt(r4206722);
        double r4206724 = r4206723 * r4206722;
        double r4206725 = r4206705 * r4206706;
        double r4206726 = r4206724 - r4206725;
        double r4206727 = r4206705 * r4206723;
        double r4206728 = fma(r4206705, r4206705, r4206722);
        double r4206729 = r4206727 + r4206728;
        double r4206730 = r4206726 / r4206729;
        double r4206731 = r4206730 / r4206709;
        double r4206732 = -0.0021130712332977203;
        bool r4206733 = r4206716 <= r4206732;
        double r4206734 = -1.5;
        double r4206735 = 1.0;
        double r4206736 = r4206705 / r4206719;
        double r4206737 = r4206735 / r4206736;
        double r4206738 = r4206734 * r4206737;
        double r4206739 = r4206738 / r4206709;
        double r4206740 = -1.045888882004455e-07;
        bool r4206741 = r4206716 <= r4206740;
        double r4206742 = r4206710 / r4206705;
        double r4206743 = -0.5;
        double r4206744 = r4206742 * r4206743;
        double r4206745 = r4206741 ? r4206731 : r4206744;
        double r4206746 = r4206733 ? r4206739 : r4206745;
        double r4206747 = r4206718 ? r4206731 : r4206746;
        return r4206747;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -0.08079221226609472 or -0.0021130712332977203 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -1.045888882004455e-07

    1. Initial program 22.4

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

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

      \[\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 -0.08079221226609472 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -0.0021130712332977203

    1. Initial program 22.7

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

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied clear-num26.6

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

    if -1.045888882004455e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 54.0

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

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

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

    \[\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.08079221226609472:\\ \;\;\;\;\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{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.0021130712332977203:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{1}{\frac{b}{c \cdot a}}}{3 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.045888882004455 \cdot 10^{-07}:\\ \;\;\;\;\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{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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