Average Error: 44.2 → 0.4
Time: 21.2s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\left(a \cdot c\right) \cdot 4}{\left(-2\right) \cdot \left(a \cdot \left(b + \sqrt{\mathsf{fma}\left(-c, 4 \cdot a, b \cdot b\right)}\right)\right)}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\left(a \cdot c\right) \cdot 4}{\left(-2\right) \cdot \left(a \cdot \left(b + \sqrt{\mathsf{fma}\left(-c, 4 \cdot a, b \cdot b\right)}\right)\right)}
double f(double a, double b, double c) {
        double r51936 = b;
        double r51937 = -r51936;
        double r51938 = r51936 * r51936;
        double r51939 = 4.0;
        double r51940 = a;
        double r51941 = r51939 * r51940;
        double r51942 = c;
        double r51943 = r51941 * r51942;
        double r51944 = r51938 - r51943;
        double r51945 = sqrt(r51944);
        double r51946 = r51937 + r51945;
        double r51947 = 2.0;
        double r51948 = r51947 * r51940;
        double r51949 = r51946 / r51948;
        return r51949;
}

double f(double a, double b, double c) {
        double r51950 = a;
        double r51951 = c;
        double r51952 = r51950 * r51951;
        double r51953 = 4.0;
        double r51954 = r51952 * r51953;
        double r51955 = 2.0;
        double r51956 = -r51955;
        double r51957 = b;
        double r51958 = -r51951;
        double r51959 = r51953 * r51950;
        double r51960 = r51957 * r51957;
        double r51961 = fma(r51958, r51959, r51960);
        double r51962 = sqrt(r51961);
        double r51963 = r51957 + r51962;
        double r51964 = r51950 * r51963;
        double r51965 = r51956 * r51964;
        double r51966 = r51954 / r51965;
        return r51966;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 44.2

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
  2. Using strategy rm
  3. Applied flip-+44.2

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

    \[\leadsto \frac{\frac{\color{blue}{0 + \left(c \cdot a\right) \cdot 4}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  5. Simplified0.4

    \[\leadsto \frac{\frac{0 + \left(c \cdot a\right) \cdot 4}{\color{blue}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, 4 \cdot \left(-a\right), {b}^{2}\right)}}}}{2 \cdot a}\]
  6. Using strategy rm
  7. Applied div-inv0.5

    \[\leadsto \frac{\color{blue}{\left(0 + \left(c \cdot a\right) \cdot 4\right) \cdot \frac{1}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, 4 \cdot \left(-a\right), {b}^{2}\right)}}}}{2 \cdot a}\]
  8. Applied associate-/l*0.5

    \[\leadsto \color{blue}{\frac{0 + \left(c \cdot a\right) \cdot 4}{\frac{2 \cdot a}{\frac{1}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, 4 \cdot \left(-a\right), {b}^{2}\right)}}}}}\]
  9. Simplified0.4

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

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

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))