Average Error: 28.7 → 16.3
Time: 18.4s
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 r1649007 = b;
        double r1649008 = -r1649007;
        double r1649009 = r1649007 * r1649007;
        double r1649010 = 3.0;
        double r1649011 = a;
        double r1649012 = r1649010 * r1649011;
        double r1649013 = c;
        double r1649014 = r1649012 * r1649013;
        double r1649015 = r1649009 - r1649014;
        double r1649016 = sqrt(r1649015);
        double r1649017 = r1649008 + r1649016;
        double r1649018 = r1649017 / r1649012;
        return r1649018;
}

double f(double a, double b, double c) {
        double r1649019 = b;
        double r1649020 = 2495.5039318207096;
        bool r1649021 = r1649019 <= r1649020;
        double r1649022 = c;
        double r1649023 = a;
        double r1649024 = r1649022 * r1649023;
        double r1649025 = -3.0;
        double r1649026 = r1649024 * r1649025;
        double r1649027 = fma(r1649019, r1649019, r1649026);
        double r1649028 = sqrt(r1649027);
        double r1649029 = r1649028 * r1649027;
        double r1649030 = r1649019 * r1649019;
        double r1649031 = r1649030 * r1649019;
        double r1649032 = r1649029 - r1649031;
        double r1649033 = r1649019 + r1649028;
        double r1649034 = fma(r1649028, r1649033, r1649030);
        double r1649035 = r1649032 / r1649034;
        double r1649036 = 3.0;
        double r1649037 = r1649023 * r1649036;
        double r1649038 = r1649035 / r1649037;
        double r1649039 = -0.5;
        double r1649040 = r1649022 / r1649019;
        double r1649041 = r1649039 * r1649040;
        double r1649042 = r1649021 ? r1649038 : r1649041;
        return r1649042;
}

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