Average Error: 43.6 → 11.1
Time: 1.0m
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 r4715383 = b;
        double r4715384 = -r4715383;
        double r4715385 = r4715383 * r4715383;
        double r4715386 = 3.0;
        double r4715387 = a;
        double r4715388 = r4715386 * r4715387;
        double r4715389 = c;
        double r4715390 = r4715388 * r4715389;
        double r4715391 = r4715385 - r4715390;
        double r4715392 = sqrt(r4715391);
        double r4715393 = r4715384 + r4715392;
        double r4715394 = r4715393 / r4715388;
        return r4715394;
}

double f(double a, double b, double c) {
        double r4715395 = b;
        double r4715396 = 8.984490456930244e-05;
        bool r4715397 = r4715395 <= r4715396;
        double r4715398 = r4715395 * r4715395;
        double r4715399 = c;
        double r4715400 = 3.0;
        double r4715401 = a;
        double r4715402 = r4715400 * r4715401;
        double r4715403 = r4715399 * r4715402;
        double r4715404 = r4715398 - r4715403;
        double r4715405 = sqrt(r4715404);
        double r4715406 = r4715404 * r4715405;
        double r4715407 = r4715398 * r4715395;
        double r4715408 = r4715406 - r4715407;
        double r4715409 = r4715398 + r4715404;
        double r4715410 = fma(r4715405, r4715395, r4715409);
        double r4715411 = r4715408 / r4715410;
        double r4715412 = r4715411 / r4715402;
        double r4715413 = -0.5;
        double r4715414 = r4715399 / r4715395;
        double r4715415 = r4715413 * r4715414;
        double r4715416 = r4715397 ? r4715412 : r4715415;
        return r4715416;
}

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)))