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(x1,…,xn) and a parameter $\eps > 0$, the algorithm approximates Prx∼{−1,1}n[p(x)≥0] to within an additive $\pm \eps$ in time $\poly(n,2^{\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(n,1/\eps)$ time. The algorithm also runs in $\poly(n,1/\eps)$ time to approximate Prx∼N(0,1)n[p(x)≥0] to within an additive $\pm \eps$, for any degree-2 polynomial p. As an application of our counting result, we give a deterministic FPT multiplicative $(1 \pm \eps)$-approximation algorithm to approximate the k-th absolute moment $\E_{x \sim \{-1,1\}^n}[|p(x)^k|]$ of a degree-2 polynomial. The algorithm's running time is of the form $\poly(n) \cdot f(k,1/\eps)$.
Many quantum algorithms for ground-state preparation and energy estimation require the implementation of high-degree polynomials of a Hamiltonian to achieve better convergence rates. Their circuit implementation typically relies on quantum signal processing (QSP), whose circuit depth is proportional to the degree of the polynomial. Previous studies exploit the Chebyshev polynomial approximation, which requires a Chebyshev series of degree O(nln(1/δ)) for an n-degree polynomial, where δ is the approximation error. However, the approximation is limited to only a few functions, including monomials, truncated exponential, Gaussian, and error functions. In this work, we present the most generalized function approximation methods for δ-approximating linear combinations or products of polynomial-approximable functions with quadratically reduced-degree polynomials. We extend the list of polynomial-approximable functions by showing that the functions of cosine and sine can also be δ-approximated by quadratically reduced-degree Laurent polynomials. We demonstrate that various Hamiltonian functions for quantum ground-state preparation and energy estimation can be implemented with quadratically shallow circuits.