- #1

- 173

- 0

[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?