2007/10/15, Steffen <[EMAIL PROTECTED]>: > > Hi, > > I need to create a random multivariate polynomial. I do it as follows: > > F = GF(10007)['x,y'].random_element(4,9)
Hi Stephen, This is not an "exact" function. The only guarantee we have is that we will get a polynomial with total degree of *at most* 4 and total number of terms is *at most* 9. You're right, in such a big field the coefficient is almost always nonzero. The problem is in the degrees: we don't check for repetitions when generating them (we don't care). As you know, we often view multivariate polynomials as dictionaries with the degrees as keys and the coefficients as values. The functions works simply (with parameters 4 and 9): 1) generate 9 random tuples of for the degrees. The only requirement we have is that the sum of the element in these tuples must not exceed 4. Repetitions are allowed. 2) Generate 9 coefficients. 3) Create a dictionary where the keys are the degree tuples and the values are the coefficients. Repetitions are discarded and that is how we end up with a polynomial with less than 9 terms. 4) Create a polynomial from this dictionary and return it. Hope that helps. didier > > Now, sage creates a polynomial in x and y of degree 2 in every > variable, since 4 = 2+2. Furthermore 9 restricts the polynomial to 9 > coefficients. I could not find any documentation for > "random_element(..,..)" but thats my guess after tinkering around with > the values. So far everything is perfect. > The problem is now, that most of the time the created polynomial has > only 6 or 7 coefficients. Since the probability to choose 0 in the > field GF(bigPrime) is quite low, I would expect the polynomial to have > 9 coefficients in most cases. If I increase this second parameter of > the random_element function, the average number of coefficients > increases up to the maximum possible number of coefficients, which is > 9. Unfortunately, the computation time for creating the polynomial > increases nearly linearly with the second parameter of the > "random_element" function. > So I am wondering if my understanding of the parameters of > "random_elment" is wrong or if this function really produces such > results, which I do not regard as random behaviour. > > Cheers, Steffen > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---