Average Error: 52.3 → 5.6
Time: 17.0s
Precision: 64
\[4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt a \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt b \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt c \lt 20282409603651670423947251286016\]
\[\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 -2.406534768104977956118843349098135320219 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b, b \cdot b - \left(c \cdot a\right) \cdot 3\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 -2.406534768104977956118843349098135320219 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b, b \cdot b - \left(c \cdot a\right) \cdot 3\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3805240 = b;
        double r3805241 = -r3805240;
        double r3805242 = r3805240 * r3805240;
        double r3805243 = 3.0;
        double r3805244 = a;
        double r3805245 = r3805243 * r3805244;
        double r3805246 = c;
        double r3805247 = r3805245 * r3805246;
        double r3805248 = r3805242 - r3805247;
        double r3805249 = sqrt(r3805248);
        double r3805250 = r3805241 + r3805249;
        double r3805251 = r3805250 / r3805245;
        return r3805251;
}

double f(double a, double b, double c) {
        double r3805252 = b;
        double r3805253 = r3805252 * r3805252;
        double r3805254 = 3.0;
        double r3805255 = a;
        double r3805256 = r3805254 * r3805255;
        double r3805257 = c;
        double r3805258 = r3805256 * r3805257;
        double r3805259 = r3805253 - r3805258;
        double r3805260 = sqrt(r3805259);
        double r3805261 = -r3805252;
        double r3805262 = r3805260 + r3805261;
        double r3805263 = r3805262 / r3805256;
        double r3805264 = -2.406534768104978e-06;
        bool r3805265 = r3805263 <= r3805264;
        double r3805266 = r3805257 * r3805255;
        double r3805267 = r3805266 * r3805254;
        double r3805268 = r3805253 - r3805267;
        double r3805269 = sqrt(r3805268);
        double r3805270 = r3805268 * r3805269;
        double r3805271 = r3805252 * r3805253;
        double r3805272 = r3805270 - r3805271;
        double r3805273 = fma(r3805269, r3805252, r3805268);
        double r3805274 = r3805253 + r3805273;
        double r3805275 = r3805272 / r3805274;
        double r3805276 = r3805275 / r3805256;
        double r3805277 = -0.5;
        double r3805278 = r3805257 / r3805252;
        double r3805279 = r3805277 * r3805278;
        double r3805280 = r3805265 ? r3805276 : r3805279;
        return r3805280;
}

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

    1. Initial program 22.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-+22.4

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

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

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

    if -2.406534768104978e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 57.0

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.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 -2.406534768104977956118843349098135320219 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b, b \cdot b - \left(c \cdot a\right) \cdot 3\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :pre (and (< 4.930380657631324e-32 a 2.028240960365167e+31) (< 4.930380657631324e-32 b 2.028240960365167e+31) (< 4.930380657631324e-32 c 2.028240960365167e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))