Average Error: 52.7 → 0.4
Time: 19.9s
Precision: 64
\[4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt a \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt b \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt c \lt 20282409603651670423947251286016\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\frac{4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(-\sqrt{b}, \sqrt{b}, -\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}{2 \cdot a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(-\sqrt{b}, \sqrt{b}, -\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}{2 \cdot a}
double f(double a, double b, double c) {
        double r33233 = b;
        double r33234 = -r33233;
        double r33235 = r33233 * r33233;
        double r33236 = 4.0;
        double r33237 = a;
        double r33238 = r33236 * r33237;
        double r33239 = c;
        double r33240 = r33238 * r33239;
        double r33241 = r33235 - r33240;
        double r33242 = sqrt(r33241);
        double r33243 = r33234 + r33242;
        double r33244 = 2.0;
        double r33245 = r33244 * r33237;
        double r33246 = r33243 / r33245;
        return r33246;
}

double f(double a, double b, double c) {
        double r33247 = 4.0;
        double r33248 = a;
        double r33249 = c;
        double r33250 = r33248 * r33249;
        double r33251 = r33247 * r33250;
        double r33252 = b;
        double r33253 = sqrt(r33252);
        double r33254 = -r33253;
        double r33255 = r33252 * r33252;
        double r33256 = r33255 - r33251;
        double r33257 = sqrt(r33256);
        double r33258 = -r33257;
        double r33259 = fma(r33254, r33253, r33258);
        double r33260 = r33251 / r33259;
        double r33261 = 2.0;
        double r33262 = r33261 * r33248;
        double r33263 = r33260 / r33262;
        return r33263;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 52.7

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

    \[\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(a \cdot c\right) \cdot 4}}{\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 + \left(a \cdot c\right) \cdot 4}{\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-lft-neg-in0.5

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

    \[\leadsto \frac{\frac{0 + \left(a \cdot c\right) \cdot 4}{\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. Simplified0.4

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

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

Reproduce

herbie shell --seed 2019325 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :precision binary64
  :pre (and (< 4.93038e-32 a 2.02824e+31) (< 4.93038e-32 b 2.02824e+31) (< 4.93038e-32 c 2.02824e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))