Average Error: 28.6 → 16.5
Time: 15.8s
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 3260.8737586103744:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)} \cdot \mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)}\right), \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)}\right), \left(b \cdot b\right)\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 3260.8737586103744:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)} \cdot \mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)}\right), \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)}\right), \left(b \cdot b\right)\right)}}{a \cdot 3}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3006725 = b;
        double r3006726 = -r3006725;
        double r3006727 = r3006725 * r3006725;
        double r3006728 = 3.0;
        double r3006729 = a;
        double r3006730 = r3006728 * r3006729;
        double r3006731 = c;
        double r3006732 = r3006730 * r3006731;
        double r3006733 = r3006727 - r3006732;
        double r3006734 = sqrt(r3006733);
        double r3006735 = r3006726 + r3006734;
        double r3006736 = r3006735 / r3006730;
        return r3006736;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3006737 = b;
        double r3006738 = 3260.8737586103744;
        bool r3006739 = r3006737 <= r3006738;
        double r3006740 = c;
        double r3006741 = a;
        double r3006742 = r3006740 * r3006741;
        double r3006743 = -3.0;
        double r3006744 = r3006742 * r3006743;
        double r3006745 = fma(r3006737, r3006737, r3006744);
        double r3006746 = sqrt(r3006745);
        double r3006747 = r3006746 * r3006745;
        double r3006748 = r3006737 * r3006737;
        double r3006749 = r3006748 * r3006737;
        double r3006750 = r3006747 - r3006749;
        double r3006751 = r3006737 + r3006746;
        double r3006752 = fma(r3006746, r3006751, r3006748);
        double r3006753 = r3006750 / r3006752;
        double r3006754 = 3.0;
        double r3006755 = r3006741 * r3006754;
        double r3006756 = r3006753 / r3006755;
        double r3006757 = -0.5;
        double r3006758 = r3006740 / r3006737;
        double r3006759 = r3006757 * r3006758;
        double r3006760 = r3006739 ? r3006756 : r3006759;
        return r3006760;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

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

    1. Initial program 18.4

      \[\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.4

      \[\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.8

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

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

    if 3260.8737586103744 < b

    1. Initial program 37.3

      \[\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. Taylor expanded around inf 15.4

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

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

Reproduce

herbie shell --seed 2019130 +o rules:numerics
(FPCore (a b c d)
  :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)))