Average Error: 52.6 → 0.1
Time: 2.7m
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{2 \cdot c}{\left(-b\right) - \sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}\]
double f(double a, double b, double c) {
        double r9752386 = b;
        double r9752387 = -r9752386;
        double r9752388 = r9752386 * r9752386;
        double r9752389 = 4.0;
        double r9752390 = a;
        double r9752391 = r9752389 * r9752390;
        double r9752392 = c;
        double r9752393 = r9752391 * r9752392;
        double r9752394 = r9752388 - r9752393;
        double r9752395 = sqrt(r9752394);
        double r9752396 = r9752387 + r9752395;
        double r9752397 = 2.0;
        double r9752398 = r9752397 * r9752390;
        double r9752399 = r9752396 / r9752398;
        return r9752399;
}

double f(double a, double b, double c) {
        double r9752400 = 2.0;
        double r9752401 = c;
        double r9752402 = r9752400 * r9752401;
        double r9752403 = b;
        double r9752404 = -r9752403;
        double r9752405 = -4.0;
        double r9752406 = a;
        double r9752407 = r9752405 * r9752406;
        double r9752408 = r9752403 * r9752403;
        double r9752409 = fma(r9752401, r9752407, r9752408);
        double r9752410 = sqrt(r9752409);
        double r9752411 = r9752404 - r9752410;
        double r9752412 = r9752402 / r9752411;
        return r9752412;
}

\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{2 \cdot c}{\left(-b\right) - \sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 52.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-+52.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. Applied associate-/l/52.6

    \[\leadsto \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(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
  5. Simplified0.4

    \[\leadsto \frac{\color{blue}{4 \cdot \left(c \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\]
  6. Using strategy rm
  7. Applied associate-/r*0.2

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

    \[\leadsto \frac{\frac{4 \cdot \left(c \cdot a\right)}{2 \cdot a}}{\color{blue}{\left(-b\right) - \sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}}\]
  9. Taylor expanded around -inf 0.1

    \[\leadsto \frac{\color{blue}{2 \cdot c}}{\left(-b\right) - \sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}\]
  10. Final simplification0.1

    \[\leadsto \frac{2 \cdot c}{\left(-b\right) - \sqrt{(c \cdot \left(-4 \cdot a\right) + \left(b \cdot b\right))_*}}\]

Reproduce

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