Average Error: 44.5 → 0.2
Time: 2.4m
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)}}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)}}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r20077073 = b;
        double r20077074 = -r20077073;
        double r20077075 = r20077073 * r20077073;
        double r20077076 = 3.0;
        double r20077077 = a;
        double r20077078 = r20077076 * r20077077;
        double r20077079 = c;
        double r20077080 = r20077078 * r20077079;
        double r20077081 = r20077075 - r20077080;
        double r20077082 = sqrt(r20077081);
        double r20077083 = r20077074 + r20077082;
        double r20077084 = r20077083 / r20077078;
        return r20077084;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r20077085 = c;
        double r20077086 = b;
        double r20077087 = -r20077086;
        double r20077088 = a;
        double r20077089 = -3.0;
        double r20077090 = r20077088 * r20077089;
        double r20077091 = r20077086 * r20077086;
        double r20077092 = fma(r20077085, r20077090, r20077091);
        double r20077093 = sqrt(r20077092);
        double r20077094 = r20077087 - r20077093;
        double r20077095 = r20077085 / r20077094;
        return r20077095;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Initial program 44.5

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

    \[\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 *-un-lft-identity0.4

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

    \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
  8. Applied associate-/l*0.2

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

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

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

Reproduce

herbie shell --seed 2019125 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))