Mathematica code for multinomial expansion

Click For Summary

Discussion Overview

The discussion revolves around the development of Mathematica code for the multinomial expansion, specifically seeking a general formula for expanding expressions of the form (sum of m terms) raised to the power of n. Participants are exploring how to derive the complete expanded formula rather than just the multinomial coefficients.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant requests Mathematica code for the multinomial expansion of a general case involving m terms raised to the power of n.
  • Another participant seeks clarification on whether the request is for code that returns the expanded product or just the multinomial coefficients.
  • A participant expresses interest in deriving the entire expanded formula and notes that the multinomial coefficients can be obtained using the built-in "multinomial" command.
  • One participant provides a potential code snippet for expanding the sum of m terms raised to n, but questions whether it meets the original request.
  • A later post discusses the need to elaborate on the product terms powered by the multinomial coefficients and presents a specific code example for a limited case, asking how to generalize it.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the specific requirements for the Mathematica code, and multiple interpretations of the original request remain. The discussion includes various approaches and clarifications without a definitive solution being established.

Contextual Notes

There are limitations in the clarity of the original request, particularly regarding the expected input and output of the desired function. The discussion also reflects uncertainty about how to generalize the provided code for broader cases.

nikozm
Messages
51
Reaction score
0
Hello,

I m looking for a mathematica code for the multinomial expansion of the general case of (let's say m sum terms given in a power of n), e.g., the code for the 1st equation in http://en.wikipedia.org/wiki/Multinomial_theorem

Any help would be useful.

Thanks
 
Physics news on Phys.org
I'm not sure I understand what you want. Do you mean you want code that, given ##m## and ##n##, returns the expanded product? Or you want the multinomial coefficients?
 
Hello,

First, thank you for replying. I m interested to deriving the whole expanded formula not just the multinomial coefficient, since the latter can be straightforwardly returned via the corresponding mathematica command "multinomial"

Is there a way to build an efficient code for multinomial expansion for the general case ?
 
I'm still not sure what you want. When you have such a question, it is good to explain clearly what the input to the function is, and what you want to get out.

Is this what you are looking for?
Code:
multi[m_, n_] := Expand[Sum[Subscript[x, i], {i, 1, m}]^n]
 
The expand command does the job, but i want to further elaborate on the product terms (powered to the corresponding multinomial coefficients).

In particular, i want to express the following general form: ∑^{L}_{p1,p2,...,pn=0 && p1+p2+...+pn=L} f(x)^{p1+p2+...+pn}. There is a code for a certain case (see bellow) but how can i generalize it ?

x = 0; For[k1 = 0, k1 <= 2, k1++,
For[k2 = 0, k2 <= 2, k2++,
For[k3 = 0, k3 <= 2, k3++,
If[k1 + k2 + k3 == 2,
x = x + Multinomial[k1, k2, k3]*
x1^k1*x2^k2*x3^k3];
If[k1 == 2 && k2 == 2 && k3 == 2, Print[x]]]]]
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 16 ·
Replies
16
Views
12K