Ask Your Question

Revision history [back]

A Combinatorics Problem - Product Rule Indices

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 $z_1,z_2,z_3$, respectively, I'm looking at computations of the form:

  • $\partial_{z_1} (fg) = f_1g + f g_1$
  • $\partial_{z_1} \partial_{z_2} (fg) = f_{12}g + f_1 g_2 + f_2 g_1 + f g_{12}$
  • $\partial_{z_1} \partial_{z_2} \partial_{z_3} (fg) = f_{123}g + f_{12}g_3 + f_{13}g_2 + f_{23}g_1 + f_1g_{23} + f_2g_{13} + f_3g_{12} + f g_{123}$

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