Average Error: 28.6 → 16.5
Time: 16.7s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 183.1843483503574816495529375970363616943:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(3 \cdot a, c, b \cdot b\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 183.1843483503574816495529375970363616943:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(3 \cdot a, c, b \cdot b\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 r67133 = b;
        double r67134 = -r67133;
        double r67135 = r67133 * r67133;
        double r67136 = 3.0;
        double r67137 = a;
        double r67138 = r67136 * r67137;
        double r67139 = c;
        double r67140 = r67138 * r67139;
        double r67141 = r67135 - r67140;
        double r67142 = sqrt(r67141);
        double r67143 = r67134 + r67142;
        double r67144 = r67143 / r67138;
        return r67144;
}

double f(double a, double b, double c) {
        double r67145 = b;
        double r67146 = 183.18434835035748;
        bool r67147 = r67145 <= r67146;
        double r67148 = r67145 * r67145;
        double r67149 = 3.0;
        double r67150 = a;
        double r67151 = r67149 * r67150;
        double r67152 = c;
        double r67153 = fma(r67151, r67152, r67148);
        double r67154 = r67148 - r67153;
        double r67155 = r67151 * r67152;
        double r67156 = r67148 - r67155;
        double r67157 = sqrt(r67156);
        double r67158 = r67157 + r67145;
        double r67159 = r67154 / r67158;
        double r67160 = r67159 / r67151;
        double r67161 = -0.5;
        double r67162 = r67152 / r67145;
        double r67163 = r67161 * r67162;
        double r67164 = r67147 ? r67160 : r67163;
        return r67164;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 15.9

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

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

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

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

    if 183.18434835035748 < b

    1. Initial program 35.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified35.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 17.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 183.1843483503574816495529375970363616943:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(3 \cdot a, c, b \cdot b\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 2019305 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.05367121277235087e-8 a 94906265.6242515594) (< 1.05367121277235087e-8 b 94906265.6242515594) (< 1.05367121277235087e-8 c 94906265.6242515594))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))