Average Error: 43.7 → 11.3
Time: 5.7s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\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 4.2169126153830769 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5}{3} \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 4.2169126153830769 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r95208 = b;
        double r95209 = -r95208;
        double r95210 = r95208 * r95208;
        double r95211 = 3.0;
        double r95212 = a;
        double r95213 = r95211 * r95212;
        double r95214 = c;
        double r95215 = r95213 * r95214;
        double r95216 = r95210 - r95215;
        double r95217 = sqrt(r95216);
        double r95218 = r95209 + r95217;
        double r95219 = r95218 / r95213;
        return r95219;
}

double f(double a, double b, double c) {
        double r95220 = b;
        double r95221 = 0.0004216912615383077;
        bool r95222 = r95220 <= r95221;
        double r95223 = r95220 * r95220;
        double r95224 = 3.0;
        double r95225 = a;
        double r95226 = r95224 * r95225;
        double r95227 = c;
        double r95228 = r95226 * r95227;
        double r95229 = r95223 - r95228;
        double r95230 = -r95229;
        double r95231 = fma(r95220, r95220, r95230);
        double r95232 = -r95220;
        double r95233 = sqrt(r95229);
        double r95234 = r95232 - r95233;
        double r95235 = r95231 / r95234;
        double r95236 = r95235 / r95226;
        double r95237 = -1.5;
        double r95238 = r95237 / r95224;
        double r95239 = r95227 / r95220;
        double r95240 = r95238 * r95239;
        double r95241 = r95222 ? r95236 : r95240;
        return r95241;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 20.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 flip-+20.1

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

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

    if 0.0004216912615383077 < b

    1. Initial program 45.7

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied times-frac10.8

      \[\leadsto \color{blue}{\frac{-1.5}{3} \cdot \frac{\frac{a \cdot c}{b}}{a}}\]
    5. Taylor expanded around 0 10.6

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

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

Reproduce

herbie shell --seed 2020036 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))