Ask Your Question
2

the permutation of subscripts of a multivariate polynomial

asked 2014-07-12 16:32:22 +0100

ruidongshuai@gmail.com gravatar image

updated 2014-07-17 13:27:32 +0100

I want to define a function, the input are a permutation sigma belonging to Sn, and a multivariate polynomial f=f(x1,x2,...,xn) over Q, and the output is a multivariate polynomial f=f(x(sigma(1)),x(sigma(2)),...,x(sigma(n))), for example, if sigma=(3,1,2),f=x1+x2x3, then the output should be f=x3+x1x2. It is worth mentioning that this should work for any n not just when n=3. How should I do that?

edit retag flag offensive close merge delete

Comments

Please correct the typo in the title.

rws gravatar imagerws ( 2014-07-12 19:13:17 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-07-12 18:41:32 +0100

slelievre gravatar image

updated 2014-07-17 14:08:39 +0100

You can apply a permutation to a tuple, in particular to the tuple of generators of the polynomial ring. You can then apply the function to the permuted variables.

Here is an example, from which you could build a function permute_variables(sigma,f) (left as an exercise).

sage: version() # just for reference
'Sage Version 6.3.beta5, Release Date: 2014-07-01'
sage: R = PolynomialRing(ZZ,n,'x')
sage: R
Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over Integer Ring
sage: Sn = SymmetricGroup(range(n))
sage: f = R.random_element()
sage: f
x1*x2 - x3^2 + x2*x4 + 3*x1 - 1
sage: sigma = Sn.random_element()
sage: sigma
(0,2,4)
sage: R.gens()
(x0, x1, x2, x3, x4)
sage: sigma(R.gens())
(x2, x1, x4, x3, x0)
sage: f(*sigma(R.gens()))
-x3^2 + x0*x4 + x1*x4 + 3*x1 - 1

Rather than a random permutation, you probably prefer to input it yourself. For this, you need to define x0 etc. and make them point to the variables of polynomials in R. This is done with R.inject(variables). And to input permutations as products of cycles, use something like Sn('(0,1)(2,3)'). An example where you input the polynomial and the permutation yourself:

sage: n = 5
sage: R = PolynomialRing(ZZ,n,'x')
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4
sage: Sn = SymmetricGroup(range(n))
sage: f = x1 + x2
sage: sigma = Sn((1,2,3))
sage: sigma
(1,2,3)
sage: f(*sigma(R.gens()))
x2 + x3
sage: sigma = Sn('(0,1)(2,3)')
sage: f(*sigma(R.gens()))
x0 + x3

Be careful: If you define the permutation group as SymmetricGroup(5), they are indexed from 1 to n, so it's tricky to follow what goes on when you let them act on the generators of $R$, which are indexed from 0 to n-1 (you have to offset your indices by one, then apply the permutation, then undo the offset). In particular the permutation $(1,2,3)$ of $S_5$, would then act on $(x_0, x_1, x_2, x_3, x_4)$, acts as the cyclic permutation $(x_0, x_1, x_2)$.

edit flag offensive delete link more

Comments

Thanks for your answer very much! However, there is still a small problem, when I type in a polynomial f=x1+x2, and n=5, sigma=(1,2,3),it shows an error says that the number of arguments must be less than or equal to 2. How can I make the arguments of f be x1,x2,x3 instead of just x1 and x2?

ruidongshuai@gmail.com gravatar imageruidongshuai@gmail.com ( 2014-07-13 15:39:58 +0100 )edit

Don't forget the line `R.inject_variables()`. Or, if you prefer, define the x_i's by "x0, x1, x2, x3, x4 = R.gens()". *Do not* define x1, x2, x3 as symbolic variables (with `var('x1')` etc). Does it work now?

slelievre gravatar imageslelievre ( 2014-07-17 07:56:33 +0100 )edit

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: 2014-07-12 16:32:22 +0100

Seen: 1,231 times

Last updated: Jul 17 '14