Average Error: 43.7 → 11.3
Time: 4.2s
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 r106208 = b;
        double r106209 = -r106208;
        double r106210 = r106208 * r106208;
        double r106211 = 3.0;
        double r106212 = a;
        double r106213 = r106211 * r106212;
        double r106214 = c;
        double r106215 = r106213 * r106214;
        double r106216 = r106210 - r106215;
        double r106217 = sqrt(r106216);
        double r106218 = r106209 + r106217;
        double r106219 = r106218 / r106213;
        return r106219;
}

double f(double a, double b, double c) {
        double r106220 = b;
        double r106221 = 0.0004216912615383077;
        bool r106222 = r106220 <= r106221;
        double r106223 = r106220 * r106220;
        double r106224 = 3.0;
        double r106225 = a;
        double r106226 = r106224 * r106225;
        double r106227 = c;
        double r106228 = r106226 * r106227;
        double r106229 = r106223 - r106228;
        double r106230 = -r106229;
        double r106231 = fma(r106220, r106220, r106230);
        double r106232 = -r106220;
        double r106233 = sqrt(r106229);
        double r106234 = r106232 - r106233;
        double r106235 = r106231 / r106234;
        double r106236 = r106235 / r106226;
        double r106237 = -1.5;
        double r106238 = r106237 / r106224;
        double r106239 = r106227 / r106220;
        double r106240 = r106238 * r106239;
        double r106241 = r106222 ? r106236 : r106240;
        return r106241;
}

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)))