Average Error: 43.6 → 11.1
Time: 1.1m
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}\;b \le 8.984490456930243999777996322109174798243 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) \cdot \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}, b, b \cdot b + \left(b \cdot b - c \cdot \left(3 \cdot a\right)\right)\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}\;b \le 8.984490456930243999777996322109174798243 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) \cdot \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}, b, b \cdot b + \left(b \cdot b - c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4100243 = b;
        double r4100244 = -r4100243;
        double r4100245 = r4100243 * r4100243;
        double r4100246 = 3.0;
        double r4100247 = a;
        double r4100248 = r4100246 * r4100247;
        double r4100249 = c;
        double r4100250 = r4100248 * r4100249;
        double r4100251 = r4100245 - r4100250;
        double r4100252 = sqrt(r4100251);
        double r4100253 = r4100244 + r4100252;
        double r4100254 = r4100253 / r4100248;
        return r4100254;
}

double f(double a, double b, double c) {
        double r4100255 = b;
        double r4100256 = 8.984490456930244e-05;
        bool r4100257 = r4100255 <= r4100256;
        double r4100258 = r4100255 * r4100255;
        double r4100259 = c;
        double r4100260 = 3.0;
        double r4100261 = a;
        double r4100262 = r4100260 * r4100261;
        double r4100263 = r4100259 * r4100262;
        double r4100264 = r4100258 - r4100263;
        double r4100265 = sqrt(r4100264);
        double r4100266 = r4100264 * r4100265;
        double r4100267 = r4100258 * r4100255;
        double r4100268 = r4100266 - r4100267;
        double r4100269 = r4100258 + r4100264;
        double r4100270 = fma(r4100265, r4100255, r4100269);
        double r4100271 = r4100268 / r4100270;
        double r4100272 = r4100271 / r4100262;
        double r4100273 = -0.5;
        double r4100274 = r4100259 / r4100255;
        double r4100275 = r4100273 * r4100274;
        double r4100276 = r4100257 ? r4100272 : r4100275;
        return r4100276;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 8.984490456930244e-05

    1. Initial program 17.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified17.3

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}}\]
    3. Using strategy rm
    4. Applied flip3--17.4

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}^{3} - {b}^{3}}{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} \cdot \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} + \left(b \cdot b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} \cdot b\right)}}}{a \cdot 3}\]
    5. Simplified16.8

      \[\leadsto \frac{\frac{\color{blue}{\left(b \cdot b - \left(a \cdot 3\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b \cdot \left(b \cdot b\right)}}{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} \cdot \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} + \left(b \cdot b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} \cdot b\right)}}{a \cdot 3}\]
    6. Simplified16.8

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

    if 8.984490456930244e-05 < b

    1. Initial program 45.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified45.5

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}}\]
    3. Taylor expanded around inf 10.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 8.984490456930243999777996322109174798243 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) \cdot \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}, b, b \cdot b + \left(b \cdot b - c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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