Average Error: 44.0 → 11.4
Time: 7.0s
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 0.114113106997123639:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(3 \cdot a\right)\right)}}{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 0.114113106997123639:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r78152 = b;
        double r78153 = -r78152;
        double r78154 = r78152 * r78152;
        double r78155 = 3.0;
        double r78156 = a;
        double r78157 = r78155 * r78156;
        double r78158 = c;
        double r78159 = r78157 * r78158;
        double r78160 = r78154 - r78159;
        double r78161 = sqrt(r78160);
        double r78162 = r78153 + r78161;
        double r78163 = r78162 / r78157;
        return r78163;
}

double f(double a, double b, double c) {
        double r78164 = b;
        double r78165 = 0.11411310699712364;
        bool r78166 = r78164 <= r78165;
        double r78167 = -r78164;
        double r78168 = c;
        double r78169 = 3.0;
        double r78170 = a;
        double r78171 = r78169 * r78170;
        double r78172 = r78168 * r78171;
        double r78173 = -r78172;
        double r78174 = fma(r78164, r78164, r78173);
        double r78175 = sqrt(r78174);
        double r78176 = r78167 + r78175;
        double r78177 = r78176 / r78171;
        double r78178 = -0.5;
        double r78179 = r78168 / r78164;
        double r78180 = r78178 * r78179;
        double r78181 = r78166 ? r78177 : r78180;
        return r78181;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 23.5

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    3. Simplified23.4

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

    if 0.11411310699712364 < b

    1. Initial program 46.9

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

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

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

Reproduce

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