Average Error: 29.1 → 0.4
Time: 2.9m
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\frac{\frac{c \cdot a}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}}}{a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{\frac{c \cdot a}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}}}{a}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r23746140 = b;
        double r23746141 = -r23746140;
        double r23746142 = r23746140 * r23746140;
        double r23746143 = 3.0;
        double r23746144 = a;
        double r23746145 = r23746143 * r23746144;
        double r23746146 = c;
        double r23746147 = r23746145 * r23746146;
        double r23746148 = r23746142 - r23746147;
        double r23746149 = sqrt(r23746148);
        double r23746150 = r23746141 + r23746149;
        double r23746151 = r23746150 / r23746145;
        return r23746151;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r23746152 = c;
        double r23746153 = a;
        double r23746154 = r23746152 * r23746153;
        double r23746155 = b;
        double r23746156 = -r23746155;
        double r23746157 = -3.0;
        double r23746158 = r23746157 * r23746153;
        double r23746159 = r23746155 * r23746155;
        double r23746160 = fma(r23746152, r23746158, r23746159);
        double r23746161 = sqrt(r23746160);
        double r23746162 = r23746156 - r23746161;
        double r23746163 = r23746154 / r23746162;
        double r23746164 = r23746163 / r23746153;
        return r23746164;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Initial program 29.1

    \[\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-+29.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. Simplified0.4

    \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(3 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
  5. Using strategy rm
  6. Applied associate-/r*0.6

    \[\leadsto \color{blue}{\frac{\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}{a}}\]
  7. Simplified0.4

    \[\leadsto \frac{\color{blue}{\frac{c \cdot a}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}}}}{a}\]
  8. Final simplification0.4

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

Reproduce

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