# Series doesn't seem to work on functions

When you try to use the Multivariable option of Series, it doesn't work as intended, since it keeps terms of higher order than intended.

Example: Expand a two-variable gaussian exponential to second order.

In[1]:= f[x_, y_] := Exp[-x^2 - y^2]
In[2]:= Normal[Series[f[x, y], {x, 0, 2}, {y, 0, 2}]]
Out[2]= 1 - y^2 + x^2 (-1 + y^2)


Here the last term is on fourth order. I found a solution to this here Multivariable Taylor expansion does not work as expected.

Applying this to my problem yields this,

In[3]:= Normal[Series[f[x t, y t], {t, 0, 2}]] /. t -> 1
Out[3]= 1 - x^2 - y^2


Which is the correct expansion to second order.

Now I intend to create a function to apply all the process in one step,

In[4]:=MultiSeries[exp_] := Module[{f},
f[x_, y_] := Evaluate[exp];
Normal[Series[f[x t, y t], {t, 0, 2}]] /. t -> 1
]


The problem is that by doing that, it yields this,

In[5]:= MultiSeries[Exp[-x^2 - y^2]]
Out[5]= E^(-x^2 - y^2)


The problem doesn't seem to be on the compound expression since,

In[6]:= Clear[f]; f[x_, y_] := Exp[-x^2 - y^2]; Normal[Series[f[x t, y t], {t, 0, 2}]] /. t -> 1


Yields,

Out[6]= 1 - x^2 - y^2


This leads me to believe that the problem is in the Module function. Is there any way to solve this?

• It's a scoping issue involving the dummy pattern variables not being recognized as the "same" as the ones used in the input. A way to avoid this is to make the variables explicit in the Module input. Could do multiSeries[exp_, vars_] := Module[{t}, Normal[Series[exp /. Thread[vars -> t*vars], {t, 0, 2}]] /. t -> 1] and try it on multiSeries[Exp[-x^2 - y^2], {x, y}]. – Daniel Lichtblau Nov 21 '18 at 15:34