Average Error: 43.7 → 0.5
Time: 11.1s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\mathsf{fma}\left(a \cdot c, 4, 0\right)}{2} \cdot \frac{\frac{1}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}}}{a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\mathsf{fma}\left(a \cdot c, 4, 0\right)}{2} \cdot \frac{\frac{1}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}}}{a}
double f(double a, double b, double c) {
        double r56760 = b;
        double r56761 = -r56760;
        double r56762 = r56760 * r56760;
        double r56763 = 4.0;
        double r56764 = a;
        double r56765 = r56763 * r56764;
        double r56766 = c;
        double r56767 = r56765 * r56766;
        double r56768 = r56762 - r56767;
        double r56769 = sqrt(r56768);
        double r56770 = r56761 + r56769;
        double r56771 = 2.0;
        double r56772 = r56771 * r56764;
        double r56773 = r56770 / r56772;
        return r56773;
}

double f(double a, double b, double c) {
        double r56774 = a;
        double r56775 = c;
        double r56776 = r56774 * r56775;
        double r56777 = 4.0;
        double r56778 = 0.0;
        double r56779 = fma(r56776, r56777, r56778);
        double r56780 = 2.0;
        double r56781 = r56779 / r56780;
        double r56782 = 1.0;
        double r56783 = b;
        double r56784 = -r56783;
        double r56785 = r56777 * r56774;
        double r56786 = r56785 * r56775;
        double r56787 = -r56786;
        double r56788 = fma(r56783, r56783, r56787);
        double r56789 = sqrt(r56788);
        double r56790 = r56784 - r56789;
        double r56791 = r56782 / r56790;
        double r56792 = r56791 / r56774;
        double r56793 = r56781 * r56792;
        return r56793;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 43.7

    \[\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-+43.7

    \[\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}{4 \cdot \left(a \cdot c\right) + b \cdot \left(b - b\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  5. Using strategy rm
  6. Applied fma-neg0.4

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

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

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

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

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))