Re: Series and passing a function a changing number of

*To*: mathgroup at smc.vnet.net*Subject*: [mg106822] Re: [mg106758] Series and passing a function a changing number of*From*: Leonid Shifrin <lshifr at gmail.com>*Date*: Sun, 24 Jan 2010 05:41:48 -0500 (EST)*References*: <201001231229.HAA15987@smc.vnet.net>

Ignacio, In short, what you were missing seems to be Apply[Sequence,...] construct. The signature of a function you declare suggests that the starting point will have all components equal, and you want your function to be expanded to the same order in each dimension (otherwise you'd need lists for those parameters and that would not be any different than a built-in Series). Then, the following seems to do what you asked for: In[1]:= Clear[myTaylorExpander]; myTaylorExpander[function_, varList : {__Symbol}, startPoint_, ord_] := Series[function @@ varList, Sequence @@ PadRight[List /@ varList, {Length[varList], 3}, {ord, startPoint}]] In[3]:= myTaylorExpander[Sin, {x}, 0, 4] Out[3]= SeriesData[x, 0, {1, 0, Rational[-1, 6]}, 1, 5, 1] In[4]:= Clear[fn]; fn[x_, y_] := Exp[x + 2 y^x]; myTaylorExpander[fn, {p, q}, 0, 2] Out[6]= SeriesData[p, 0, {E^2, SeriesData[q, 0, {E^2 + 2 E^2 Log[q]}, 0, 3, 1], SeriesData[ q, 0, {Rational[1, 2] E^2 + 2 E^2 Log[q] + 3 E^2 Log[q]^2}, 0, 3, 1]}, 0, 3, 1] Regards, Leonid On Sat, Jan 23, 2010 at 4:29 AM, Ignacio Plazeta < Ignacio.Plazeta at speednet.es> wrote: > Dear Friends > > -- 1 ----------------------------------------------- > > This command works fine: > > Series[ Exp[ x + 2 y^x ] , {x, 0, 2} , {y, 0, 2} ] > > this one doesn't: > > Series[ Exp[ x + 2 y^x ] , {{x, 0, 2}, {y, 0, 2}} ] > > It returns: > > "Series specification is not a list with three elements ..." > > -- 2 ----------------------------------------------- > > I'm trying to set up this kind of function: > > myTaylorExpander[ function_ , varList , startPoint_ , ord_ ] > > where varList length is changing; because of the above mentioned > behavior of Series function I can't simply try something like: > > numVar = Length[ varList ]; > > args = Table[ > > { varList[[k]] , startPoint , ord} > > , { k, 1 , numVar } > > ] > > Series[ f , args ] // Normal > > -- 3 ----------------------------------------------- > > Is there a way to get out of this by a trick to pass a functions > a changing number of variable ? Anything else fitting is welcomed too. > > Warmest Regards. > > Ignacio Plazeta > ( Spain ) > > >

**References**:**Series and passing a function a changing number of variables***From:*Ignacio Plazeta <Ignacio.Plazeta@speednet.es>