Re: Expansion Coefficients in Multivariate Series Expansions?
- To: mathgroup at smc.vnet.net
- Subject: [mg26610] Re: [mg26579] Expansion Coefficients in Multivariate Series Expansions?
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Thu, 11 Jan 2001 10:39:18 -0500 (EST)
- References: <200101090651.BAA00200@smc.vnet.net> <3A5B4FC1.23338960@wolfram.com>
- Sender: owner-wri-mathgroup at wolfram.com
Daniel Lichtblau wrote:
>
> "A. E. Siegman" wrote:
> >
> > Given an expression that is the sum of products of integer powers of
> > three variables (say x,y,z) multiplied by numerical coefficients:
> >
> > f = c000 + c100 x + c010 y + c001 z + c110 x y + c211 x^2 y z + . . .
> >
> > where the cijk's are all real numbers, and f may or may not be in
> > Normal (or other) form, how do I find the coefficient of a particular
> > term, e.g. c100 for the x term (*not* c1000 + c110 y), or ckmn for the
> > x^k y^m z^n term?
> > [...]
>
> Or you could write your own code. Below is a simple procedural way,
> taking derivatives and setting variables to zero.
>
> In[64]:= myCoefficient[ee_, vars__] := Module[
> {len, vlist={vars}, res=ee},
> Do[
> res = D[res, vlist[[j]]] /. vlist[[j,1]]->0,
> {j,Length[vlist]}];
> res
> ]
>
> In[66]:= myCoefficient[f, {x,0}, {y,0}, {z,0}]
> Out[66]= c000
>
> A functional programming approach might use Fold.
>
> In[72]:= myCoefficient2[ee_, vars__] := Fold[(D[#1,#2] /. #2[[1]]->0)&,
> f, {vars}]
>
> In[73]:= myCoefficient2[f, {x,0}, {y,0}, {z,0}]
> Out[73]= c000
> [...]
Oops, forgot to divide by factorials in those last ones. Those should
be:
myCoefficient[ee_, vars__] := Module[
{len, vlist={vars}, res=ee},
Do[
res = D[res, vlist[[j]]] / vlist[[j,2]]! /. vlist[[j,1]]->0,
{j,Length[vlist]}
];
res
]
myCoefficient2[ee_, vars__] :=
Fold[(D[#1,#2]/#2[[2]]! /. #2[[1]]->0)&, f, {vars}]
Daniel Lichtblau
Wolfram Research
- References:
- Expansion Coefficients in Multivariate Series Expansions?
- From: "A. E. Siegman" <siegman@stanford.edu>
- Expansion Coefficients in Multivariate Series Expansions?