This notebook contains additional material to the Mathematica GuideBooks  (Springer-Verlag, New York, 2004) http://www.MathematicaGuideBooks.org . It uses the stylesheet of the Mathematica GuideBooks, which is embedded.

Symbolics Volume, Chapter 1

The MacMahon master theorem states that, for an arbitrary matrix (Subscript[((Subscript[a, ij])), 1≤i,j≤d]) and indeterminates (Subscript[x, k]), the coefficients of the following expressions are identical [✶]:

[(Subscript[x, 1]^(Subscript[k, 1]))(Subscript[x, 2]^(Subscript[k, 2]))… (Subscript[x, d]^(Subscript[k, d]))]((1/(Subscript[det((Subscript[δ, ij])-(Subscript[a, ij])(Subscript[x, j])), 1≤i,j≤d])))=[(Subscript[x, 1]^(Subscript[k, 1]))(Subscript[x, 2]^(Subscript[k, 2]))… (Subscript[x, d]^(Subscript[k, d]))]((∏_(j=1)^d)((((∑_(m=1)^d)(Subscript[a, jm])(Subscript[x, m])))^(Subscript[k, j])))

Write a function that, for an explicitly given d, verifies the MacMahon master theorem for all monomials (Subscript[x, 1]^(Subscript[k, 1]))(Subscript[x, 2]^(Subscript[k, 2]))… (Subscript[x, d]^(Subscript[k, d])) with (∑_(j=1)^d)(Subscript[k, j])≤o by explicit calculation of the coefficients. Check the theorem for all 1≤d,o≤5.

checkMacMahonMasterTheorem[d_Integer?Positive, o_Integer?Positive] := 
Module[{a, x, τ, det, invDetSeries, xMonomials},
       (* list of the indeterminates *)
       xMonomials = Table[x[j], {j, d}];
       (* the determinant, make homogeneous with τ *)
       det = Det[IdentityMatrix[d] - Table[a[i, j] x[j], {i, d}, {j, d}]] /. 
                 x[j_] :> τ x[j];
       (* series of the inverse determinant in τ *)
       invDetSeries = (Series[1/det, {τ, 0, o}] // Normal // Expand) /. τ -> 1;
       (* extract coefficients of monomials in the series terms *)
       terms = Internal`DistributedTermsList[invDetSeries, xMonomials][[1]];
       (* form right-hand-side for a given exponent vector, 
          extract coefficient and subtract *)
       ((If[Union[#1] === {0}, 1, Plus @@ Cases[
           Expand[Times @@ (Table[Sum[a[i, j] x[j], {j, d}], {i, d}]^#)], 
                 _ (Times @@ (xMonomials^#1)), {If[d === 1, 0, 1]}] /. 
                      _x -> 1] - #2)& @@@ terms) // (Union[#] === {0})&]

Of course, the MacMahon master theorem holds for all 1≤d,o≤5.

Table[checkMacMahonMasterTheorem[i, j], {i, 5}, {j, 5}] // Flatten // Union