[Date Index]
[Thread Index]
[Author Index]
Re: multinomials: a programming question
*To*: mathgroup at smc.vnet.net
*Subject*: [mg3965] Re: multinomials: a programming question
*From*: wagner at motel6.cs.colorado.edu (Dave Wagner)
*Date*: Mon, 13 May 1996 01:46:44 -0400
*Organization*: University of Colorado, Boulder
*Sender*: owner-wri-mathgroup at wolfram.com
In article <4menll$jva at dragonfly.wolfram.com>,
Jack Goldberg <jackgold at admin.lsa.umich.edu> wrote:
>Hello Mma users,
>
>... 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. (Multinomial is a built-in function.)
>
>The problem is with the iterator(s). The condition i+j+k = n
>is causing me great difficulty. What would be nice is a solution
>that works in the general multinomial case, but perhaps that is asking
>too much - I would be happy for the trinomial expansion.
>
>The more general issue here is this: Many sums in mathematics (most
>more important than the above trivial problem) are indexed over more
>complicated sets than allowed by the syntax of Sum. For example,
>open any book on number theory - I opened my copy of An Introduction
>To The Theory of Numbers, I. Niven et. al. - and found the Mobius
>inversion formula, pg 194, part
>of which reads (subject to the limitation of my keyboard)
>
>The sum over all divisors d of n of the product of
>mu(d)*F(n/d) ...
>
>Instead of having to recast this remarkable formula into terms
>understandable by Sum, wouldn't it be nice to have the set over
>which the sum is taken be given as the iterator. Then my trinomial
>problem would be solved like this:
>
>tri[a_,b_,c_,n_] := Sum["as above", {i+j+k=n}]
>
>Your thoughts are more than welcome!
The most general solution to the problem is to write a function that
generates a list of all of the indices, map the summand over the list
(the summand has to be converted to a pure function first), and
then apply Plus to the result. The generator function would be different
for every special sum, but the rest could be automated. For example,
you could make a new definition for Sum[summand_Function, generator_],
in which the first argument is the summand and the second argument
is the index-set generator function. The definition would be
*something* like this (untested!):
Sum[summand_Function, generator_] :=
Plus @@ summand /@ generator[]
For the multinomial problem, you might use:
Sum[ Times @@ {a,b,c}^# &, f]
where f is a suitable function from DiscreteMath`Combinatorics` that
generates a list of the indices. The result should be a list of
triples {i, j, k}.
I don't have time to work out the details, but you asked for my
thoughts, and those are them.
Dave Wagner
Principia Consulting
(303) 786-8371
dbwagner at princon.com
http://www.princon.com/princon
==== [MESSAGE SEPARATOR] ====
Prev by Date:
**Problem: Table[{v,Part[T[v],1]},{v,0.001,vcc,0.1}]**
Next by Date:
**Re: problem exporting numbers to text file**
Previous by thread:
**Re: multinomials: a programming question**
Next by thread:
**Re: multinomials: a programming question**
| |