Average Error: 28.7 → 16.3
Time: 15.9s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\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 2495.5039318207096:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}, b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}, b \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 2495.5039318207096:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}, b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}, b \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 r1946404 = b;
        double r1946405 = -r1946404;
        double r1946406 = r1946404 * r1946404;
        double r1946407 = 3.0;
        double r1946408 = a;
        double r1946409 = r1946407 * r1946408;
        double r1946410 = c;
        double r1946411 = r1946409 * r1946410;
        double r1946412 = r1946406 - r1946411;
        double r1946413 = sqrt(r1946412);
        double r1946414 = r1946405 + r1946413;
        double r1946415 = r1946414 / r1946409;
        return r1946415;
}

double f(double a, double b, double c) {
        double r1946416 = b;
        double r1946417 = 2495.5039318207096;
        bool r1946418 = r1946416 <= r1946417;
        double r1946419 = c;
        double r1946420 = a;
        double r1946421 = r1946419 * r1946420;
        double r1946422 = -3.0;
        double r1946423 = r1946421 * r1946422;
        double r1946424 = fma(r1946416, r1946416, r1946423);
        double r1946425 = sqrt(r1946424);
        double r1946426 = r1946425 * r1946424;
        double r1946427 = r1946416 * r1946416;
        double r1946428 = r1946427 * r1946416;
        double r1946429 = r1946426 - r1946428;
        double r1946430 = r1946416 + r1946425;
        double r1946431 = fma(r1946425, r1946430, r1946427);
        double r1946432 = r1946429 / r1946431;
        double r1946433 = 3.0;
        double r1946434 = r1946420 * r1946433;
        double r1946435 = r1946432 / r1946434;
        double r1946436 = -0.5;
        double r1946437 = r1946419 / r1946416;
        double r1946438 = r1946436 * r1946437;
        double r1946439 = r1946418 ? r1946435 : r1946438;
        return r1946439;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.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-+18.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. Simplified17.4

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

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

    if 2495.5039318207096 < b

    1. Initial program 37.5

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

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt15.5

      \[\leadsto \frac{\frac{-3}{2} \cdot \frac{a \cdot c}{\color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{3 \cdot a}\]
    5. Applied times-frac15.5

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

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

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

Reproduce

herbie shell --seed 2019153 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))