Average Error: 28.8 → 14.7
Time: 20.6s
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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.840082917903566 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right)} \cdot \mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right)}\right), \left(\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right)} + b\right), \left(b \cdot b\right)\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.840082917903566 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right)} \cdot \mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right)}\right), \left(\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot \left(c \cdot a\right)\right)\right)} + b\right), \left(b \cdot b\right)\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2789153 = b;
        double r2789154 = -r2789153;
        double r2789155 = r2789153 * r2789153;
        double r2789156 = 3.0;
        double r2789157 = a;
        double r2789158 = r2789156 * r2789157;
        double r2789159 = c;
        double r2789160 = r2789158 * r2789159;
        double r2789161 = r2789155 - r2789160;
        double r2789162 = sqrt(r2789161);
        double r2789163 = r2789154 + r2789162;
        double r2789164 = r2789163 / r2789158;
        return r2789164;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2789165 = b;
        double r2789166 = r2789165 * r2789165;
        double r2789167 = 3.0;
        double r2789168 = a;
        double r2789169 = r2789167 * r2789168;
        double r2789170 = c;
        double r2789171 = r2789169 * r2789170;
        double r2789172 = r2789166 - r2789171;
        double r2789173 = sqrt(r2789172);
        double r2789174 = -r2789165;
        double r2789175 = r2789173 + r2789174;
        double r2789176 = r2789175 / r2789169;
        double r2789177 = -1.840082917903566e-05;
        bool r2789178 = r2789176 <= r2789177;
        double r2789179 = -3.0;
        double r2789180 = r2789170 * r2789168;
        double r2789181 = r2789179 * r2789180;
        double r2789182 = fma(r2789165, r2789165, r2789181);
        double r2789183 = sqrt(r2789182);
        double r2789184 = r2789183 * r2789182;
        double r2789185 = r2789165 * r2789166;
        double r2789186 = r2789184 - r2789185;
        double r2789187 = r2789183 + r2789165;
        double r2789188 = fma(r2789183, r2789187, r2789166);
        double r2789189 = r2789186 / r2789188;
        double r2789190 = r2789189 / r2789169;
        double r2789191 = r2789170 / r2789165;
        double r2789192 = -0.5;
        double r2789193 = r2789191 * r2789192;
        double r2789194 = r2789178 ? r2789190 : r2789193;
        return r2789194;
}

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) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -1.840082917903566e-05

    1. Initial program 16.6

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

      \[\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. Simplified16.1

      \[\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. Simplified16.1

      \[\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 -1.840082917903566e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 39.8

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

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

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

      \[\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 13.4

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

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

Reproduce

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