Stupid question about multinomial theorem (and Matlab)

In summary, the conversation discusses a theorem for calculating coefficients in a multinomial expansion and the correctness of a specific implementation of the algorithm using MATLAB. The formula for the coefficients is also provided.
  • #1
AiRAVATA
173
0
I know that there is a theorem to calculate the coefficients for a multinomial expansion, but I'm having a hard time implementig the algorithm. What I need to know is if my procedure is correct:

[tex](A + B + C + D)^n = \sum_{i=0}^n \dbinom{n}{i} A^{n-i} (B + C + D)^i[/tex]

[tex]= \sum_{i=0}^n \dbinom{n}{i} A^{n-i} \sum_{j=0}^i \dbinom{i}{j} B^{i-j} (C + D)^j[/tex]

[tex]= \sum_{i=0}^n \dbinom{n}{i} A^{n-i} \sum_{j=0}^i \dbinom{i}{j} B^{i-j} \sum_{k=0}^j \dbinom{j}{k} C^{j-k} D^k,[/tex]

so

[tex](A + B + C + D)^n = \sum_{i=0}^n \sum_{j=0}^{i} \sum_{k=0}^{j}\dfrac{n!}{(n-i)!(i-j)!(j-k)!k!} A^{n-i} B^{i-j} C^{j-k} D^k [/tex]

Is that correct?

If so, I'm trying to compute the coefficients in Matlab in the following way

Code:
h = 1;
for i = 1:n
     for j = 1:i
          for k = 1:j
               coef(h,1) = factorial(n)/(factorial(n-i)*factorial(i-j)*factorial(j-k)*factorial(k))
               h = h+1;
          end
     end
end

so the vector coef contains the coefficients of the polynomial. What do you think? Is my approach correct or am I doing something wrong?
 
Physics news on Phys.org
  • #2
Hi AiRAVATA! :smile:
AiRAVATA said:
I know that there is a theorem to calculate the coefficients for a multinomial expansion, but I'm having a hard time implementig the algorithm. What I need to know is if my procedure is correct:

[tex](A + B + C + D)^n = \sum_{i=0}^n \sum_{j=0}^{i} \sum_{k=0}^{j}\dfrac{n!}{(n-i)!(i-j)!(j-k)!k!} A^{n-i} B^{i-j} C^{j-k} D^k [/tex]

Is that correct?

Yes, though it's normally written for an individual component:

coefficient of AaBbCcDd = n!/a!b!c!d! (with a + b + c + d = n) :wink:

(I don't know anything about porgramming though :redface:)
 
  • #3
not being smart but should it not be:

Code:
for i = [B]0[/B]:n
     for j = [B]0[/B]:i
          for k = [B]0[/B]:j
 
  • #4
True, in the real code they all start from zero. Thanks for noticing though!
 

1. What is the multinomial theorem?

The multinomial theorem is a mathematical theorem that provides a way to expand a power of a sum into a sum of multiple terms. It is a generalization of the binomial theorem, which expands a power of a binomial into a sum of two terms.

2. How is the multinomial theorem used in Matlab?

In Matlab, the multinomial theorem is used to calculate the coefficients of a polynomial expansion. This is done using the polyfit function, which takes in a set of data points and the desired degree of the polynomial, and returns the coefficients of the polynomial in descending order.

3. Can the multinomial theorem be used for non-integer powers?

Yes, the multinomial theorem can be used for non-integer powers as long as the coefficients can be represented as binomial coefficients. In Matlab, this can be achieved by using the gammaln function to calculate the logarithm of the factorial of the non-integer power.

4. Is the multinomial theorem limited to a certain number of terms?

No, the multinomial theorem can be used for any number of terms in the expansion. In Matlab, the polyfit function can handle up to 7 terms, but the polyfitn function can be used for any number of terms.

5. Are there any applications of the multinomial theorem other than polynomial expansions?

Yes, the multinomial theorem has applications in statistics, probability, and combinatorics. It is used to calculate the probabilities of events with multiple outcomes, and in combinatorics it is used to count the number of ways to arrange objects with repeated elements.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
924
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Advanced Physics Homework Help
Replies
0
Views
209
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
5
Views
361
  • Engineering and Comp Sci Homework Help
Replies
1
Views
927
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Back
Top