Average Error: 28.5 → 0.5
Time: 16.9s
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(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\frac{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}
double f(double a, double b, double c) {
        double r44944 = b;
        double r44945 = -r44944;
        double r44946 = r44944 * r44944;
        double r44947 = 4.0;
        double r44948 = a;
        double r44949 = r44947 * r44948;
        double r44950 = c;
        double r44951 = r44949 * r44950;
        double r44952 = r44946 - r44951;
        double r44953 = sqrt(r44952);
        double r44954 = r44945 + r44953;
        double r44955 = 2.0;
        double r44956 = r44955 * r44948;
        double r44957 = r44954 / r44956;
        return r44957;
}

double f(double a, double b, double c) {
        double r44958 = 4.0;
        double r44959 = a;
        double r44960 = r44958 * r44959;
        double r44961 = c;
        double r44962 = r44960 * r44961;
        double r44963 = b;
        double r44964 = sqrt(r44963);
        double r44965 = -r44964;
        double r44966 = r44963 * r44963;
        double r44967 = r44966 - r44962;
        double r44968 = sqrt(r44967);
        double r44969 = -r44968;
        double r44970 = fma(r44964, r44965, r44969);
        double r44971 = r44962 / r44970;
        double r44972 = 2.0;
        double r44973 = r44972 * r44959;
        double r44974 = r44971 / r44973;
        return r44974;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.5

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

    \[\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.5

    \[\leadsto \frac{\frac{\color{blue}{0 + c \cdot \left(4 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\right)}{\left(-\color{blue}{\sqrt{b} \cdot \sqrt{b}}\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  7. Applied distribute-rgt-neg-in0.5

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

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

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

Reproduce

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