counting function of system of equations and Circle method I came up with the follwing question while looking on Davenport's book: Analytical Methods for Diophantine equations and Inequalities. 
When introducing the Circle method gives an example on how to apply this in the case of Waring's problem. More precisely, starting with the sum of exponentials $$ T(\alpha) = \sum_{x=1}^P e(\alpha x^k)$$ where $e( \cdot)= e^{2 \pi i (\cdot) }$
he says's that using orthogonal relation of the exponentials we can represent the number of solution's of Waring's problem, i.e. $$ r(N)= \{ 1 \leq x_i \leq P, \hspace{0.1in} i=1,2,\cdots, s \hspace{0.1in}| x_1^k +x_2^k + \cdots + x_s^k = N \} $$ as an integral, namely we get $$ r(N) = \int_0^1 T(\alpha)^s e(-\alpha N) d \alpha $$.
I proved the above formula, and my question is how one can generalize this "method" in order to prove the similar problem :

Let $f_1, \cdots, f_r \in \mathbb Z [x_1,\cdots,x_s]$, be homogeneous
  polynomials of degree $d$, and consider the counting function $$
 r(n,P) = \# \{ |x_i| \leq P \hspace{0.1in} | f_i (x_1, \cdots,x_s)=
 n_i , \hspace{0.1in} i=1,\cdots,r \}$$ where $n=(n_1,\cdots, n_r) \in
 \mathbb N_{\geq 0}^r$
How can we write the counting function $ r(n,P)$ as an integral ?

Thank you in advance.
P.S. If the title is not the best one, please feel free to change it, so it will became more clear my question.
 A: Let $\vec{x}=(x_{1},\dots,x_{s})$. For Waring's problem we may set $g(\vec{x})=x_{1}^{k}+\cdots+x_{s}^{k}$ and write $$T(\alpha)^{s}=T_{g}(\alpha)=\sum_{\vec{x}\in[0,P]^{s}}e\left(\alpha g(\vec{x})\right).$$
The integral $\int_{0}^{1}T(\alpha)^{s}e(-\alpha N)d\alpha$ then counts the number of representations of $N$ as a sum of $k^{th}$ powers, since the only terms in the sum which are non-zero correspond to $g(\vec{x})=N.$ For $f_{1},\dots,f_{r}\in\mathbb{Z}[x_{1},\dots,x_{s}]$ let $$T_{f_{1},\dots,f_{r}}(\alpha_{1},\dots,\alpha_{r})=\sum_{\vec{x}\in[0,P]^{s}}e\left(\alpha_{1}f_{1}(\vec{x})+\cdots+\alpha_{r}f_{r}(\vec{x})\right).$$ Then the quantity $r(n,P)$
  is equal to an integral over the $r$-dimensional torus $$\int_{\mathbb{T}^{r}}T_{f_{1},\dots,f_{r}}(\alpha_{1},\dots,\alpha_{r})e(-(n_{1}\alpha_{1}+\cdots+n_{r}\alpha_{r}))d\alpha_{1}\cdots d\alpha_{r}.$$ To prove this, expand the definition of $T_{f_{1},\dots,f_{r}}(\alpha_{1},\dots,\alpha_{r})$ and switch the order of integration and summation to obtain $$\sum_{\vec{x}\in[0,P]^{s}}\int_{\mathbb{T}^{r}}\prod_{i=1}^r e\left(\alpha_{i}f_{i}(\vec{x})-n_i\right)d\alpha_1\cdots d\alpha_r,$$ and this equals $$\sum_{\vec{x}\in[0,P]^{s}}\prod_{i=1}^r \int_0^1 e\left(\alpha f_{i}(\vec{x})-n_i\right)d\alpha.$$ Now, it follows that this quantity equals $r_{f_1,\dots ,f_r}(n,P)$ since $$\prod_{i=1}^r\int_0^1 e\left(\alpha f_{i}(\vec{x})-n_i\right)d\alpha=\begin{cases}
0 & \text{if}\ f_{i}(\vec{x})\neq n_{i}\ \text{for some }i\\
1 & \text{if}\ f_{i}(\vec{x})=n_{i}\ \text{for all }i
\end{cases}.$$
