Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

A Combinatorics Problem - Product Rule Indices

asked 14 years ago

I have a particular combinatorics problem where I would like to generate lists that look like this:

  • (n=1): [[1],[]], [[],[1]]
  • (n=2): [[1,2],[]], [[1],[2]], [[2],[1]], [[],[1,2]]
  • (n=3): [[1,2,3],[]], [[1,2],[3]], [[1,3],[2]], [[2,3],[1]], [[1],[2,3]], [[2],[1,3]], [[3],[1,2]], [[],[1,2,3]]

These sorts of combinations come from taking derivatives with respect to different variables of a product of two functions. Using subscripts 1,2,3 to denote differentiation with respect to the variables z1,z2,z3, respectively, I'm looking at computations of the form:

  • z1(fg)=f1g+fg1
  • z1z2(fg)=f12g+f1g2+f2g1+fg12
  • z1z2z3(fg)=f123g+f12g3+f13g2+f23g1+f1g23+f2g13+f3g12+fg123

Is there a quick way to generate such a list in Sage? I'm not actually looking to perform these symbolic derivatives. I just used the differentiation to demonstrate where these combinations come from. (And check with you whether or not I'm computing them correctly.)

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 14 years ago

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.

Preview: (hide)
link

Comments

what if we make questions appear anonymous?

Evgeny gravatar imageEvgeny ( 14 years ago )

I'm not sure if that's necessary. I just didn't want to appear that I was spamming ask.sage or trying to increase my karma. I was also, in part, trying to make a joke but I'm terrible at those. :)

cswiercz gravatar imagecswiercz ( 14 years ago )

that's the thing I'm not sure why people should worry about these issues, it's kind of silly IMO.

Evgeny gravatar imageEvgeny ( 14 years ago )

In that case I'm done worrying about it.

cswiercz gravatar imagecswiercz ( 14 years ago )

See also OrderedSetPartitions, which may be helpful.

Jason Bandlow gravatar imageJason Bandlow ( 14 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 14 years ago

Seen: 700 times

Last updated: Dec 07 '10