Average Error: 28.4 → 0.5
Time: 19.1s
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{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 r47213 = b;
        double r47214 = -r47213;
        double r47215 = r47213 * r47213;
        double r47216 = 4.0;
        double r47217 = a;
        double r47218 = r47216 * r47217;
        double r47219 = c;
        double r47220 = r47218 * r47219;
        double r47221 = r47215 - r47220;
        double r47222 = sqrt(r47221);
        double r47223 = r47214 + r47222;
        double r47224 = 2.0;
        double r47225 = r47224 * r47217;
        double r47226 = r47223 / r47225;
        return r47226;
}

double f(double a, double b, double c) {
        double r47227 = 4.0;
        double r47228 = a;
        double r47229 = c;
        double r47230 = r47228 * r47229;
        double r47231 = r47227 * r47230;
        double r47232 = b;
        double r47233 = sqrt(r47232);
        double r47234 = -r47233;
        double r47235 = r47232 * r47232;
        double r47236 = r47235 - r47231;
        double r47237 = sqrt(r47236);
        double r47238 = -r47237;
        double r47239 = fma(r47234, r47233, r47238);
        double r47240 = r47231 / r47239;
        double r47241 = 2.0;
        double r47242 = r47241 * r47228;
        double r47243 = r47240 / r47242;
        return r47243;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.4

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

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

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

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

    \[\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 2019326 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :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 a) c)))) (* 2 a)))