Average Error: 28.3 → 0.5
Time: 10.4s
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{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(4 \cdot a\right)\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{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(4 \cdot a\right)\right)}\right)}}{2 \cdot a}
double f(double a, double b, double c) {
        double r43568 = b;
        double r43569 = -r43568;
        double r43570 = r43568 * r43568;
        double r43571 = 4.0;
        double r43572 = a;
        double r43573 = r43571 * r43572;
        double r43574 = c;
        double r43575 = r43573 * r43574;
        double r43576 = r43570 - r43575;
        double r43577 = sqrt(r43576);
        double r43578 = r43569 + r43577;
        double r43579 = 2.0;
        double r43580 = r43579 * r43572;
        double r43581 = r43578 / r43580;
        return r43581;
}

double f(double a, double b, double c) {
        double r43582 = b;
        double r43583 = r43582 - r43582;
        double r43584 = r43582 * r43583;
        double r43585 = 4.0;
        double r43586 = a;
        double r43587 = c;
        double r43588 = r43586 * r43587;
        double r43589 = r43585 * r43588;
        double r43590 = r43584 + r43589;
        double r43591 = sqrt(r43582);
        double r43592 = -r43591;
        double r43593 = r43585 * r43586;
        double r43594 = r43587 * r43593;
        double r43595 = -r43594;
        double r43596 = fma(r43582, r43582, r43595);
        double r43597 = sqrt(r43596);
        double r43598 = -r43597;
        double r43599 = fma(r43591, r43592, r43598);
        double r43600 = r43590 / r43599;
        double r43601 = 2.0;
        double r43602 = r43601 * r43586;
        double r43603 = r43600 / r43602;
        return r43603;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.3

    \[\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}{b \cdot \left(b - b\right) + 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 add-sqr-sqrt0.5

    \[\leadsto \frac{\frac{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\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-rgt-neg-in0.5

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

    \[\leadsto \frac{\frac{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\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{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, \color{blue}{-\sqrt{\mathsf{fma}\left(b, b, -c \cdot \left(4 \cdot a\right)\right)}}\right)}}{2 \cdot a}\]
  10. Final simplification0.5

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

Reproduce

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