Average Error: 28.7 → 0.3
Time: 21.4s
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{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, -a \cdot 4, b \cdot b\right)}} \cdot \frac{a \cdot 4}{2}}{a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, -a \cdot 4, b \cdot b\right)}} \cdot \frac{a \cdot 4}{2}}{a}
double f(double a, double b, double c) {
        double r47229 = b;
        double r47230 = -r47229;
        double r47231 = r47229 * r47229;
        double r47232 = 4.0;
        double r47233 = a;
        double r47234 = r47232 * r47233;
        double r47235 = c;
        double r47236 = r47234 * r47235;
        double r47237 = r47231 - r47236;
        double r47238 = sqrt(r47237);
        double r47239 = r47230 + r47238;
        double r47240 = 2.0;
        double r47241 = r47240 * r47233;
        double r47242 = r47239 / r47241;
        return r47242;
}

double f(double a, double b, double c) {
        double r47243 = c;
        double r47244 = b;
        double r47245 = -r47244;
        double r47246 = a;
        double r47247 = 4.0;
        double r47248 = r47246 * r47247;
        double r47249 = -r47248;
        double r47250 = r47244 * r47244;
        double r47251 = fma(r47243, r47249, r47250);
        double r47252 = sqrt(r47251);
        double r47253 = r47245 - r47252;
        double r47254 = r47243 / r47253;
        double r47255 = 2.0;
        double r47256 = r47248 / r47255;
        double r47257 = r47254 * r47256;
        double r47258 = r47257 / r47246;
        return r47258;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.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-+28.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.5

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

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

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

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

    \[\leadsto \frac{\frac{0 + a \cdot \left(4 \cdot c\right)}{\left(-\color{blue}{\sqrt{b} \cdot \sqrt{b}}\right) - \left|\sqrt{\mathsf{fma}\left(b, b, -a \cdot \left(4 \cdot c\right)\right)}\right|}}{2 \cdot a}\]
  11. Applied distribute-lft-neg-in0.5

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

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

    \[\leadsto \frac{\frac{0 + a \cdot \left(4 \cdot c\right)}{\mathsf{fma}\left(-\sqrt{b}, \sqrt{b}, \color{blue}{-\sqrt{\mathsf{fma}\left(c \cdot \left(-4\right), a, b \cdot b\right)}}\right)}}{2 \cdot a}\]
  14. Using strategy rm
  15. Applied associate-/r*0.5

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

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

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

Reproduce

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