Ask Your Question

Revision history [back]

I solved my own problem. The solution uses the function partitions_set. However, it only generates half of the derivatives I want. The other half is obtained by transposing / reversing the outputs:

sage: derivs = [1,2]
sage: for s in partitions_set(derivs,2):
          print s
          s.reverse()
          print s
[[1], [2]]
[[2], [1]]
sage: s = [derivs, []]; print s
[[1, 2], []]
sage: s.reverse(); print s
[[], [1, 2]]

For the case when $n=3$ I get what I want as well:

sage: derivs = [1,2,3]
sage: for s in partitions_set(derivs,2):
          print s
          s.reverse()
          print s
[[1], [2, 3]]
[[2, 3], [1]]
[[1, 2], [3]]
[[3], [1, 2]]
[[1, 3], [2]]
[[2], [1, 3]]
sage: s = [derivs, []]; print s
[[1, 2, 3], []]
sage: s.reverse(); print s
[[], [1, 2, 3]]

At the risk of sounding full of myself I'm going to answer my own question. Thanks to everyone who thought about it, though.