Average Error: 44.2 → 0.4
Time: 19.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{\frac{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\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{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}\right)}}{2 \cdot a}
double f(double a, double b, double c) {
        double r47790 = b;
        double r47791 = -r47790;
        double r47792 = r47790 * r47790;
        double r47793 = 4.0;
        double r47794 = a;
        double r47795 = r47793 * r47794;
        double r47796 = c;
        double r47797 = r47795 * r47796;
        double r47798 = r47792 - r47797;
        double r47799 = sqrt(r47798);
        double r47800 = r47791 + r47799;
        double r47801 = 2.0;
        double r47802 = r47801 * r47794;
        double r47803 = r47800 / r47802;
        return r47803;
}

double f(double a, double b, double c) {
        double r47804 = 4.0;
        double r47805 = a;
        double r47806 = r47804 * r47805;
        double r47807 = c;
        double r47808 = r47806 * r47807;
        double r47809 = b;
        double r47810 = sqrt(r47809);
        double r47811 = -r47810;
        double r47812 = -r47808;
        double r47813 = fma(r47809, r47809, r47812);
        double r47814 = sqrt(r47813);
        double r47815 = -r47814;
        double r47816 = fma(r47810, r47811, r47815);
        double r47817 = r47808 / r47816;
        double r47818 = 2.0;
        double r47819 = r47818 * r47805;
        double r47820 = r47817 / r47819;
        return r47820;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 44.2

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

    \[\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 + 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. Using strategy rm
  6. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\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{0 + c \cdot \left(4 \cdot a\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.4

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\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.4

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

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

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))