1 | initial version |

It seems that there is no method readily available for what you want. Though, it is not too hard to write it. For instance, if you simply want the remainder in this long division, you can act as follows where you see that the order matters:

```
sage: R.<x,y> = PolynomialRing(QQ, order="lex")
sage: p = x*y^2+x*x*y+y**2
sage: q = x*y-1
sage: r = y^2-1
sage: p % q % r
x + y + 1
sage: p % r % q
2*x + 1
```

Now if you want a more general function, you can implement it as follows:

```
sage: def remainder(p, L):
....: r = p
....: for q in L:
....: r = r % q
....: return r
....:
sage: remainder(p, [q, r])
x + y + 1
sage: remainder(p, [r, q])
2*x + 1
```

You may also want to keep the quotients:

```
sage: def list_quo_rem(p, L):
....: r = p
....: quo = []
....: for q in L:
....: Q, R = r.quo_rem(q)
....: quo.append(Q)
....: r = R
....: return (quo, r)
....:
sage: list_quo_rem(p, [q, r])
([x + y, 1], x + y + 1)
sage: list_quo_rem(p, [r, q])
([x + 1, x], 2*x + 1)
```

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.