Average Error: 44.0 → 10.0
Time: 17.2s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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.004961147766964667943367928160114388447255:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(b, \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a}, b \cdot b - \left(3 \cdot c\right) \cdot a\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \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.004961147766964667943367928160114388447255:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot c\right) \cdot a\right) \cdot \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(b, \sqrt{b \cdot b - \left(3 \cdot c\right) \cdot a}, b \cdot b - \left(3 \cdot c\right) \cdot a\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3129230 = b;
        double r3129231 = -r3129230;
        double r3129232 = r3129230 * r3129230;
        double r3129233 = 3.0;
        double r3129234 = a;
        double r3129235 = r3129233 * r3129234;
        double r3129236 = c;
        double r3129237 = r3129235 * r3129236;
        double r3129238 = r3129232 - r3129237;
        double r3129239 = sqrt(r3129238);
        double r3129240 = r3129231 + r3129239;
        double r3129241 = r3129240 / r3129235;
        return r3129241;
}

double f(double a, double b, double c) {
        double r3129242 = b;
        double r3129243 = r3129242 * r3129242;
        double r3129244 = 3.0;
        double r3129245 = a;
        double r3129246 = r3129244 * r3129245;
        double r3129247 = c;
        double r3129248 = r3129246 * r3129247;
        double r3129249 = r3129243 - r3129248;
        double r3129250 = sqrt(r3129249);
        double r3129251 = -r3129242;
        double r3129252 = r3129250 + r3129251;
        double r3129253 = r3129252 / r3129246;
        double r3129254 = -0.004961147766964668;
        bool r3129255 = r3129253 <= r3129254;
        double r3129256 = r3129244 * r3129247;
        double r3129257 = r3129256 * r3129245;
        double r3129258 = r3129243 - r3129257;
        double r3129259 = sqrt(r3129258);
        double r3129260 = r3129258 * r3129259;
        double r3129261 = r3129242 * r3129243;
        double r3129262 = r3129260 - r3129261;
        double r3129263 = fma(r3129242, r3129259, r3129258);
        double r3129264 = r3129243 + r3129263;
        double r3129265 = r3129262 / r3129264;
        double r3129266 = r3129265 / r3129246;
        double r3129267 = -0.5;
        double r3129268 = r3129247 / r3129242;
        double r3129269 = r3129267 * r3129268;
        double r3129270 = r3129255 ? r3129266 : r3129269;
        return r3129270;
}

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.0 a) c)))) (* 3.0 a)) < -0.004961147766964668

    1. Initial program 20.0

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

      \[\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. Simplified19.4

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

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

    if -0.004961147766964668 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 49.9

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

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

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

Reproduce

herbie shell --seed 2019172 +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.0 a) c)))) (* 3.0 a)))