Re: multinomials: a programming question
- To: mathgroup at smc.vnet.net
- Subject: [mg3948] Re: multinomials: a programming question
- From: Count Dracula <lk3a at kelvin.seas.virginia.edu>
- Date: Fri, 10 May 1996 03:32:54 -0400
- Organization: University of Virginia
- Sender: owner-wri-mathgroup at wolfram.com
In Message-ID: <4menll$jva at dragonfly.wolfram.com> Jack Goldberg
<jackgold at admin.lsa.umich.edu> writes:
> I need to write the trinomial expansion
> out in terms of Sum. Something like this:
> tri[a_,b_,c_,n_] := Sum[Multinomial[i,j,k]*a^i*b^j*c*k, ???]
> where i+j+k = n.
In[3]:= <<DiscreteMath`Combinatorica`
f[{a_, b_, c_}, {i_, j_, k_}] := Multinomial[i, j, k] a^i b^j c k
tri[x_List, n_Integer] := Apply[Plus, (f[x, #1] & ) /@ Compositions[n, 3]]
In[5]:= tri[{a, b, c}, 3]
2 2
Out[5]= 3 c + 6 a c + 3 a c + 6 b c + 6 a b c + 3 b c
In[6]:= tri[{1, 3, 5}, 4]
Out[6]= 2500
--
___________________________________________________________________________________
Levent Kitis lk3a at cars.mech.virginia.edu lk3a at kelvin.seas.virginia.edu
University of Virginia Department of Mechanical, Aerospace, and Nuclear Engineering
==== [MESSAGE SEPARATOR] ====