Average Error: 28.7 → 16.9
Time: 17.5s
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 53.72772989939689125549193704500794410706:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}, b \cdot b - \left(3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\ \mathbf{elif}\;b \le 250.8081548127311179996468126773834228516:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 2125.07914601017046152264811098575592041:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}, b \cdot b - \left(3 \cdot a\right) \cdot c\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 53.72772989939689125549193704500794410706:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}, b \cdot b - \left(3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\

\mathbf{elif}\;b \le 250.8081548127311179996468126773834228516:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\mathbf{elif}\;b \le 2125.07914601017046152264811098575592041:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}, b \cdot b - \left(3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4728098 = b;
        double r4728099 = -r4728098;
        double r4728100 = r4728098 * r4728098;
        double r4728101 = 3.0;
        double r4728102 = a;
        double r4728103 = r4728101 * r4728102;
        double r4728104 = c;
        double r4728105 = r4728103 * r4728104;
        double r4728106 = r4728100 - r4728105;
        double r4728107 = sqrt(r4728106);
        double r4728108 = r4728099 + r4728107;
        double r4728109 = r4728108 / r4728103;
        return r4728109;
}

double f(double a, double b, double c) {
        double r4728110 = b;
        double r4728111 = 53.72772989939689;
        bool r4728112 = r4728110 <= r4728111;
        double r4728113 = r4728110 * r4728110;
        double r4728114 = 3.0;
        double r4728115 = a;
        double r4728116 = r4728114 * r4728115;
        double r4728117 = c;
        double r4728118 = r4728116 * r4728117;
        double r4728119 = r4728113 - r4728118;
        double r4728120 = sqrt(r4728119);
        double r4728121 = r4728119 * r4728120;
        double r4728122 = r4728113 * r4728110;
        double r4728123 = r4728121 - r4728122;
        double r4728124 = r4728110 + r4728120;
        double r4728125 = fma(r4728110, r4728124, r4728119);
        double r4728126 = r4728123 / r4728125;
        double r4728127 = r4728126 / r4728116;
        double r4728128 = 250.80815481273112;
        bool r4728129 = r4728110 <= r4728128;
        double r4728130 = -0.5;
        double r4728131 = r4728117 / r4728110;
        double r4728132 = r4728130 * r4728131;
        double r4728133 = 2125.0791460101705;
        bool r4728134 = r4728110 <= r4728133;
        double r4728135 = r4728134 ? r4728127 : r4728132;
        double r4728136 = r4728129 ? r4728132 : r4728135;
        double r4728137 = r4728112 ? r4728127 : r4728136;
        return r4728137;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 53.72772989939689 or 250.80815481273112 < b < 2125.0791460101705

    1. Initial program 17.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified17.4

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip3--17.5

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}^{3} - {b}^{3}}{\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 \cdot b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot b\right)}}}{3 \cdot a}\]
    5. Simplified16.7

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

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

    if 53.72772989939689 < b < 250.80815481273112 or 2125.0791460101705 < b

    1. Initial program 35.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified35.4

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

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

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

Reproduce

herbie shell --seed 2019174 +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)))