1 | initial version |

I don't know of anything *built in* to do this, but here's one possible method. I think it requires slightly different definitions of `R1`

and `R2`

, but maybe you can work something out if you need to keep your definitions:

```
sage: S1 = ZZ['x,y']
sage: S2 = ZZ['y,x']
sage: a = S1.gen(0) * (S1.gen(1) + 1)
sage: a
x*y + x
sage: a.dict()
{(1, 0): 1, (1, 1): 1}
sage: S2(a.dict())
y*x + y
```

So I guess with your original `R1`

and `R2`

:

```
sage: R1 = ZZ['y']['x']
sage: R2 = ZZ['x']['y']
sage: a = R1.base_ring().gen(0) * (R1.gen(0) + 1)
sage: a
y*x + y
sage: a.dict()
{0: y, 1: y}
sage: R2({p: a.dict()[p].subs(R2.base_ring().gen(0)) for p in a.dict()})
x*y + x
```

2 | No.2 Revision |

I don't know of anything *built in* to do this, but here's one possible method. I think it requires slightly different definitions of `R1`

and `R2`

, but maybe you can work something out if you need to keep your definitions:

```
sage: S1 = ZZ['x,y']
sage: S2 = ZZ['y,x']
sage: a = S1.gen(0) * (S1.gen(1) + 1)
sage: a
x*y + x
sage: a.dict()
{(1, 0): 1, (1, 1): 1}
sage: S2(a.dict())
y*x + y
```

Edit: sorry, this doesn't do what you want. You should modify the dictionary appropriately:

```
sage: d = {(p[1], p[0]):a.dict()[p] for p in a.dict()}
sage: S2(d)
y*x + x
```

So I guess with your original `R1`

and `R2`

:

```
sage: R1 = ZZ['y']['x']
sage: R2 = ZZ['x']['y']
sage: a = R1.base_ring().gen(0) * (R1.gen(0) + 1)
sage: a
y*x + y
sage: a.dict()
{0: y, 1: y}
sage: R2({p: a.dict()[p].subs(R2.base_ring().gen(0)) for p in a.dict()})
x*y + x
```

Edit: There should be a similar way to modify the dictionary here, too...

3 | No.3 Revision |

I don't know of anything *built in* to do this, but here's one possible method. I think it requires slightly different definitions of `R1`

and `R2`

, but maybe you can work something out if you need to keep your definitions:

```
sage: S1 = ZZ['x,y']
sage: S2 = ZZ['y,x']
sage: a = S1.gen(0) * (S1.gen(1) + 1)
sage: a
x*y + x
sage: a.dict()
{(1, 0): 1, (1, 1): 1}
sage: S2(a.dict())
y*x + y
```

Edit: sorry, this doesn't do what you want. You should modify the dictionary appropriately:

```
sage: d = {(p[1], p[0]):a.dict()[p] for p in a.dict()}
sage: S2(d)
y*x + x
```

So I guess with your original `R1`

and `R2`

:

```
sage: R1 = ZZ['y']['x']
sage: R2 = ZZ['x']['y']
sage: a = R1.base_ring().gen(0) * (R1.gen(0) + 1)
sage: a
y*x + y
sage: a.dict()
{0: y, 1: y}
sage: R2({p: a.dict()[p].subs(R2.base_ring().gen(0)) for p in a.dict()})
x*y + x
```

Edit: There should be a similar way to modify the dictionary here, ~~too...~~

`a.map_coefficients(...)`

.
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.