Average Error: 28.4 → 16.8
Time: 20.3s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 60.51244836482759836826517130248248577118:\\ \;\;\;\;\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} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b \cdot b\right)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 3}{\frac{a}{\frac{b}{c}} \cdot -1.5}}\\ \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 60.51244836482759836826517130248248577118:\\
\;\;\;\;\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} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b \cdot b\right)}}{a \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a \cdot 3}{\frac{a}{\frac{b}{c}} \cdot -1.5}}\\

\end{array}
double f(double a, double b, double c) {
        double r3375648 = b;
        double r3375649 = -r3375648;
        double r3375650 = r3375648 * r3375648;
        double r3375651 = 3.0;
        double r3375652 = a;
        double r3375653 = r3375651 * r3375652;
        double r3375654 = c;
        double r3375655 = r3375653 * r3375654;
        double r3375656 = r3375650 - r3375655;
        double r3375657 = sqrt(r3375656);
        double r3375658 = r3375649 + r3375657;
        double r3375659 = r3375658 / r3375653;
        return r3375659;
}

double f(double a, double b, double c) {
        double r3375660 = b;
        double r3375661 = 60.5124483648276;
        bool r3375662 = r3375660 <= r3375661;
        double r3375663 = r3375660 * r3375660;
        double r3375664 = c;
        double r3375665 = a;
        double r3375666 = r3375664 * r3375665;
        double r3375667 = 3.0;
        double r3375668 = r3375666 * r3375667;
        double r3375669 = r3375663 - r3375668;
        double r3375670 = sqrt(r3375669);
        double r3375671 = r3375669 * r3375670;
        double r3375672 = r3375663 * r3375660;
        double r3375673 = r3375671 - r3375672;
        double r3375674 = r3375660 + r3375670;
        double r3375675 = fma(r3375670, r3375674, r3375663);
        double r3375676 = r3375673 / r3375675;
        double r3375677 = r3375665 * r3375667;
        double r3375678 = r3375676 / r3375677;
        double r3375679 = 1.0;
        double r3375680 = r3375660 / r3375664;
        double r3375681 = r3375665 / r3375680;
        double r3375682 = -1.5;
        double r3375683 = r3375681 * r3375682;
        double r3375684 = r3375677 / r3375683;
        double r3375685 = r3375679 / r3375684;
        double r3375686 = r3375662 ? r3375678 : r3375685;
        return r3375686;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 14.5

      \[\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-+14.6

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

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

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

    if 60.5124483648276 < b

    1. Initial program 34.2

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied associate-/l*18.0

      \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num18.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 60.51244836482759836826517130248248577118:\\ \;\;\;\;\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} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, b \cdot b\right)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 3}{\frac{a}{\frac{b}{c}} \cdot -1.5}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 +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.0 a) c)))) (* 3.0 a)))