1 | initial version |

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: n = 5
sage: R = PolynomialRing(QQ,n,'x')
sage: R
Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over Rational Field
sage: Sn = SymmetricGroup(n)
sage: f = R.random_element()
sage: f
1/2*x2*x3 + x0 + x3
sage: sigma = Sn.random_element()
sage: sigma
(1,4,5)
sage: R.gens()
(x0, x1, x2, x3, x4)
sage: sigma(R.gens())
(x3, x1, x2, x4, x0)
sage: f(*sigma(R.gens()))
1/2*x2*x4 + x3 + x4
```

2 | No.2 Revision |

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: n = 5
sage: R = PolynomialRing(QQ,n,'x')
sage: R
Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over Rational Field
sage: Sn = SymmetricGroup(n)
sage: f = R.random_element()
sage: f
1/2*x2*x3 + x0 + x3
sage: sigma = Sn.random_element()
sage: sigma
(1,4,5)
sage: R.gens()
(x0, x1, x2, x3, x4)
sage: sigma(R.gens())
(x3, x1, x2, x4, x0)
sage: f(*sigma(R.gens()))
1/2*x2*x4 + x3 + x4
```

Another example where you input the polynomial and the permutation yourself:

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

Be careful: permutations are indexed from 1 to 5, but the generators of $R$ are indexed from 0 to 4. In particular the permutation $(1,2,3)$ of $S_5$, when acting on $(x_0, x_1, x_2, x_3, x_4)$, acts as the cyclic permutation $(x_0, x_1, x_2)$.

3 | No.3 Revision |

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:
```~~n = 5
sage: ~~R = ~~PolynomialRing(QQ,n,'x')
~~PolynomialRing(ZZ,n,'x')
sage: R
Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over ~~Rational Field
~~Integer Ring
sage: Sn = ~~SymmetricGroup(n)
~~SymmetricGroup(range(n))
sage: f = R.random_element()
sage: f
~~1/2*x2*x3 + x0 + x3
~~x1*x2 - x3^2 + x2*x4 + 3*x1 - 1
sage: sigma = Sn.random_element()
sage: sigma
~~(1,4,5)
~~(0,2,4)
sage: R.gens()
(x0, x1, x2, x3, x4)
sage: sigma(R.gens())
~~(x3, ~~(x2, x1, ~~x2, ~~x4, x3, x0)
sage: f(*sigma(R.gens()))
~~1/2*x2*x4 + x3 + x4
~~-x3^2 + x0*x4 + x1*x4 + 3*x1 - 1

~~Another ~~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(QQ,n,'x')
~~PolynomialRing(ZZ,n,'x')
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4
sage: Sn = ~~SymmetricGroup(n)
~~SymmetricGroup(range(n))
sage: f = x1 + x2
sage: sigma = Sn((1,2,3))
sage: sigma
(1,2,3)
sage: ~~sigma(2)
3
~~f(*sigma(R.gens()))
x2 + x3
sage: sigma = Sn('(0,1)(2,3)')
sage: f(*sigma(R.gens()))
x0 + ~~x2
~~x3

Be careful: ~~permutations ~~If you define the permutation group as SymmetricGroup(5), they are indexed from 1 to ~~5, but ~~n, so it's tricky to follow what goes on when you let them act on the generators of ~~$R$ ~~$R$, which are indexed from 0 to ~~4. ~~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$, ~~when acting ~~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)$.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.