# Count the number of homogeneous polynomials

Is there a general way of counting the number of homogeneous polynomials of certain degree in a complex projective space or a weighted complex projective space, mod the ideal generated by some homogeneous polynomials with smaller degrees?

As an example, consider the degree 18 homogeneous polynomials in $W\mathbb{P}_{[2,2,2,4]}^3$, mod the ideal generated by two degree 8 homogeneous polynomials $P_1=x^4_1$ and $P_2=x_2^4$, where $x_1$ and $x_2$ are the first and second coordinates of $W\mathbb{P}_{[2,2,2,4]}^3$. I can count the number of equivalent classes by directly listing all of such homogeneous polynomials; I would like to know if there is a more general and efficient way of doing this.

Edit: to avoid possible confusion, I have replaced "polynomial" by "homogeneous polynomial".

I guess what you are after is the Hilbert function of ideal. More precisely, if you have a multigraded polynomial ring $k[x_1,\ldots,x_n]$ and the ideal is given by $I=(f_1,\ldots,f_r)$, the Hilbert function is simply the number $$h(\alpha)=\dim_k (k[x_1,\ldots,x_n]/I)_\alpha.$$Here $\alpha$ may take values in the multigrading. When $|\alpha|$ is large, the Hilbert-Serre theorem says that $h(\alpha)$ is actually a polynomial function in $\alpha$ and so the generating function is actually a rational function. There are many algorithms to compute the Hilbert function of such rings based on the theory of Gröbner basis and you could try them out in Macaulay2.
In certain special cases there are other alternatives though. As in your case, you can often turn this problem into a counting problem. Note that monomials of degree $n$ in $\mathbb{P}_{2,2,2,4}$ correspond bijectively to non-negative solutions of the equation $$2a+2b+2c+4d=n$$Let $s(n)$ denote this number. Then since the ideal $I=(P_1,P_2)$ is a complete intersection of two degree 8 polynomials, we get that the dimension of polynomials of degree $n$ modulo $I$ is exactly $$s(n)-2s(n-8)+s(n-16)$$If $n=18$, we get dimension $125-2\cdot 35+3=60$. In particular, if the ideal is c.i., this argument shows that it suffices to know the number of degree $k$ polynomials in the polynomial ring. In the general case however, you might not be so lucky that your ideal is a c.i. and then perhaps Hilbert-functions are better suited.