Average Error: 28.6 → 0.3
Time: 23.8s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\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}{2 \cdot a}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(4 \cdot a\right)\right)}}\]
\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}{2 \cdot a}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(4 \cdot a\right)\right)}}
double f(double a, double b, double c) {
        double r48272 = b;
        double r48273 = -r48272;
        double r48274 = r48272 * r48272;
        double r48275 = 4.0;
        double r48276 = a;
        double r48277 = r48275 * r48276;
        double r48278 = c;
        double r48279 = r48277 * r48278;
        double r48280 = r48274 - r48279;
        double r48281 = sqrt(r48280);
        double r48282 = r48273 + r48281;
        double r48283 = 2.0;
        double r48284 = r48283 * r48276;
        double r48285 = r48282 / r48284;
        return r48285;
}

double f(double a, double b, double c) {
        double r48286 = 4.0;
        double r48287 = a;
        double r48288 = r48286 * r48287;
        double r48289 = c;
        double r48290 = r48288 * r48289;
        double r48291 = 2.0;
        double r48292 = r48291 * r48287;
        double r48293 = r48290 / r48292;
        double r48294 = b;
        double r48295 = -r48294;
        double r48296 = r48289 * r48288;
        double r48297 = -r48296;
        double r48298 = fma(r48294, r48294, r48297);
        double r48299 = sqrt(r48298);
        double r48300 = r48295 - r48299;
        double r48301 = r48293 / r48300;
        return r48301;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.6

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

    \[\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. Taylor expanded around 0 0.5

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

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

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

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

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

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

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

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

Reproduce

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