Average Error: 43.9 → 11.1
Time: 6.9s
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 2.56800976414688911 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{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 2.56800976414688911 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r115307 = b;
        double r115308 = -r115307;
        double r115309 = r115307 * r115307;
        double r115310 = 3.0;
        double r115311 = a;
        double r115312 = r115310 * r115311;
        double r115313 = c;
        double r115314 = r115312 * r115313;
        double r115315 = r115309 - r115314;
        double r115316 = sqrt(r115315);
        double r115317 = r115308 + r115316;
        double r115318 = r115317 / r115312;
        return r115318;
}

double f(double a, double b, double c) {
        double r115319 = b;
        double r115320 = 0.0002568009764146889;
        bool r115321 = r115319 <= r115320;
        double r115322 = r115319 * r115319;
        double r115323 = c;
        double r115324 = 3.0;
        double r115325 = a;
        double r115326 = r115324 * r115325;
        double r115327 = r115323 * r115326;
        double r115328 = fma(r115319, r115319, r115327);
        double r115329 = r115322 - r115328;
        double r115330 = r115326 * r115323;
        double r115331 = r115322 - r115330;
        double r115332 = sqrt(r115331);
        double r115333 = r115332 + r115319;
        double r115334 = r115329 / r115333;
        double r115335 = r115334 / r115326;
        double r115336 = -0.5;
        double r115337 = r115323 / r115319;
        double r115338 = r115336 * r115337;
        double r115339 = r115321 ? r115335 : r115338;
        return r115339;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 19.6

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

      \[\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 flip--19.5

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}}{3 \cdot a}\]
    5. Simplified18.8

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

    if 0.0002568009764146889 < b

    1. Initial program 46.0

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

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

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

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

Reproduce

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