Processing math: 100%
Ask Your Question
1

Iterate over all homogeneous polynomials of a certain degree

asked 5 years ago

seagriffin gravatar image

I'd like to iterate over all cubic equations in four variables over a (small) finite field and count their rational points. What is the easiest way to iterate over all homogeneous polynomials of a certain degree?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

rburing gravatar image

Define a polynomial ring and the desired degree of your homogeneous polynomials:

R.<x,y,z,w> = PolynomialRing(GF(2))
degree = 3

A monomial should be a product of degree many variables (where some can coincide):

from itertools import combinations_with_replacement
monomials = [prod(c) for c in combinations_with_replacement(R.gens(), degree)]

Choose coefficients in all possible ways:

from itertools import product
polynomials = [sum(c*m for (c,m) in zip(coeffs, monomials)) for coeffs in product(R.base_ring(), repeat=len(monomials))]

Note not all of these give meaningfully different equations, e.g. F=0 is equivalent to cF=0 for c0, and many are related by coordinate changes.

You can define P3 as

P3 = ProjectiveSpace(3, R.base_ring(), names=R.gens())

so you can do e.g.

sage: P3.subscheme(polynomials[50]).point_set()
Set of rational points of Closed subscheme of Projective Space of dimension 3 over Finite Field of size 2 defined by:
  y^2 + y*z + z*w
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 413 times

Last updated: Dec 14 '19