Average Error: 28.4 → 0.4
Time: 6.5s
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{0 + 4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(-1, 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{0 + 4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(-1, 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 r38181 = b;
        double r38182 = -r38181;
        double r38183 = r38181 * r38181;
        double r38184 = 4.0;
        double r38185 = a;
        double r38186 = r38184 * r38185;
        double r38187 = c;
        double r38188 = r38186 * r38187;
        double r38189 = r38183 - r38188;
        double r38190 = sqrt(r38189);
        double r38191 = r38182 + r38190;
        double r38192 = 2.0;
        double r38193 = r38192 * r38185;
        double r38194 = r38191 / r38193;
        return r38194;
}

double f(double a, double b, double c) {
        double r38195 = 0.0;
        double r38196 = 4.0;
        double r38197 = a;
        double r38198 = c;
        double r38199 = r38197 * r38198;
        double r38200 = r38196 * r38199;
        double r38201 = r38195 + r38200;
        double r38202 = 1.0;
        double r38203 = -r38202;
        double r38204 = b;
        double r38205 = r38204 * r38204;
        double r38206 = r38196 * r38197;
        double r38207 = r38206 * r38198;
        double r38208 = r38205 - r38207;
        double r38209 = sqrt(r38208);
        double r38210 = -r38209;
        double r38211 = fma(r38203, r38204, r38210);
        double r38212 = r38201 / r38211;
        double r38213 = 2.0;
        double r38214 = r38213 * r38197;
        double r38215 = r38212 / r38214;
        return r38215;
}

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019356 +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)))