Average Error: 43.5 → 11.4
Time: 14.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}\;b \le 0.0012535322255036849:\\ \;\;\;\;\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}{\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)}}{a \cdot 3}\\ \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}\;b \le 0.0012535322255036849:\\
\;\;\;\;\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}{\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)}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4206990 = b;
        double r4206991 = -r4206990;
        double r4206992 = r4206990 * r4206990;
        double r4206993 = 3.0;
        double r4206994 = a;
        double r4206995 = r4206993 * r4206994;
        double r4206996 = c;
        double r4206997 = r4206995 * r4206996;
        double r4206998 = r4206992 - r4206997;
        double r4206999 = sqrt(r4206998);
        double r4207000 = r4206991 + r4206999;
        double r4207001 = r4207000 / r4206995;
        return r4207001;
}

double f(double a, double b, double c) {
        double r4207002 = b;
        double r4207003 = 0.0012535322255036849;
        bool r4207004 = r4207002 <= r4207003;
        double r4207005 = -3.0;
        double r4207006 = c;
        double r4207007 = a;
        double r4207008 = r4207006 * r4207007;
        double r4207009 = r4207005 * r4207008;
        double r4207010 = fma(r4207002, r4207002, r4207009);
        double r4207011 = sqrt(r4207010);
        double r4207012 = r4207011 * r4207010;
        double r4207013 = r4207002 * r4207002;
        double r4207014 = r4207013 * r4207002;
        double r4207015 = r4207012 - r4207014;
        double r4207016 = r4207011 * r4207002;
        double r4207017 = r4207010 + r4207016;
        double r4207018 = fma(r4207002, r4207002, r4207017);
        double r4207019 = r4207015 / r4207018;
        double r4207020 = 3.0;
        double r4207021 = r4207007 * r4207020;
        double r4207022 = r4207019 / r4207021;
        double r4207023 = -0.5;
        double r4207024 = r4207006 / r4207002;
        double r4207025 = r4207023 * r4207024;
        double r4207026 = r4207004 ? r4207022 : r4207025;
        return r4207026;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 0.0012535322255036849

    1. Initial program 20.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-+20.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.0

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

      \[\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.0012535322255036849 < b

    1. Initial program 45.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 0.0012535322255036849:\\ \;\;\;\;\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}{\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)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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