We give a {\em deterministic} algorithm for approximately computing the fraction of Boolean assignments that satisfy a degree-2 polynomial threshold function. Given a degree-2 input polynomial p(x1xn) and a parameter 0">\eps0, the algorithm approximatesPrx−11n[p(x)0]to within an additive \eps in time \poly(n2\poly(1\eps)) . Note that it is NP-hard to determine whether the above probability is nonzero, so any sort of multiplicative approximation is almost certainly impossible even for efficient randomized algorithms. This is the first deterministic algorithm for this counting problem in which the running time is polynomial in n for \eps=o(1). For ``regular'' polynomials p (those in which no individual variable's influence is large compared to the sum of all n variable influences) our algorithm runs in \poly(n1\eps) time. The algorithm also runs in \poly(n1\eps) time to approximate PrxN(01)n[p(x)0] to within an additive \eps, for any degree-2 polynomial p.
As an application of our counting result, we give a deterministic FPT multiplicative (1\eps)-approximation algorithm to approximate the k-th absolute moment \Ex−11n[p(x)k] of a degree-2 polynomial. The algorithm's running time is of the form \poly(n)f(k1\eps) .