Average Error: 28.7 → 14.7
Time: 5.0s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -2.59935901923266655 \cdot 10^{-6}:\\ \;\;\;\;\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}:\\ \;\;\;\;-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}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -2.59935901923266655 \cdot 10^{-6}:\\
\;\;\;\;\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}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r93511 = b;
        double r93512 = -r93511;
        double r93513 = r93511 * r93511;
        double r93514 = 3.0;
        double r93515 = a;
        double r93516 = r93514 * r93515;
        double r93517 = c;
        double r93518 = r93516 * r93517;
        double r93519 = r93513 - r93518;
        double r93520 = sqrt(r93519);
        double r93521 = r93512 + r93520;
        double r93522 = r93521 / r93516;
        return r93522;
}

double f(double a, double b, double c) {
        double r93523 = b;
        double r93524 = -r93523;
        double r93525 = r93523 * r93523;
        double r93526 = 3.0;
        double r93527 = a;
        double r93528 = r93526 * r93527;
        double r93529 = c;
        double r93530 = r93528 * r93529;
        double r93531 = r93525 - r93530;
        double r93532 = sqrt(r93531);
        double r93533 = r93524 + r93532;
        double r93534 = r93533 / r93528;
        double r93535 = -2.5993590192326665e-06;
        bool r93536 = r93534 <= r93535;
        double r93537 = -r93531;
        double r93538 = fma(r93523, r93523, r93537);
        double r93539 = r93524 - r93532;
        double r93540 = r93538 / r93539;
        double r93541 = r93540 / r93528;
        double r93542 = -0.5;
        double r93543 = r93529 / r93523;
        double r93544 = r93542 * r93543;
        double r93545 = r93536 ? r93541 : r93544;
        return r93545;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) < -2.5993590192326665e-06

    1. Initial program 17.7

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

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

      \[\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 -2.5993590192326665e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 41.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -2.59935901923266655 \cdot 10^{-6}:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :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)))