Suppose I have a function $p(x+\epsilon,y-\epsilon,t)$, and I want to expand it around $(x,y)$ like $$ p(x+\epsilon,y-\epsilon,t)=p(x,y,t)+\dfrac{\partial p}{\partial x}\epsilon+\dfrac{\partial p}{\partial y}(-\epsilon)+\cdots $$

A naive way to do it is


which will result in the following error message:

General::ivar: "e+x is not a valid variable."

Right now I do the expansion in the following clumsy way:

Normal@Series[p[x, y, t], {x, a, 1}, {y, b, 1}], 
{x - a -> \[Epsilon], y - b -> -\[Epsilon]}, 
/. {a -> x, b -> y}

Question: Is there an elegant way to do it? In the end, I want to expand $p(x,y,t)$ in $$ -(x+z)p(x,y,t)+(x+\epsilon)p(x+\epsilon,y-\epsilon,t)+(1-x-y+\epsilon)p(x,y-\epsilon,t) $$ and keep only the $\epsilon$ terms.

  • $\begingroup$ What's wrong with Series[p[x+e,y-e,t],{e,0,1},{e,0,1}] or Series[p[xx,yy,t],{xx,x,1},{yy,y,1}]? $\endgroup$
    – sebhofer
    Commented Aug 12, 2014 at 10:25
  • $\begingroup$ @sebhofer,Actually Series[p[x+e,y-e,t],{e,0,1},{e,0,1}] is what I wanted. $\endgroup$
    – wdg
    Commented Aug 12, 2014 at 10:46
  • $\begingroup$ Ups, I just realized this should have been Series[p[x+ex,y-ey,t],{ex,0,1},{ey,0,1}] or just Series[p[x+e,y-e,t],{e,0,1}] $\endgroup$
    – sebhofer
    Commented Aug 12, 2014 at 10:48
  • $\begingroup$ @sebhofer Don't forget to post this as an answer. $\endgroup$
    – C. E.
    Commented Aug 12, 2014 at 14:03
  • $\begingroup$ @Pickett If I'm honest, I wasn't (and still not am) really sure if this question would survive, as this is a pretty trivial use of Series $\endgroup$
    – sebhofer
    Commented Aug 12, 2014 at 15:45

1 Answer 1


Depending on your specific needs the straightforward way to do this is




If you want to extract the terms proportional to $\epsilon$ you can get the correct coefficients with

SeriesCoefficient[p[x + e, y - e, t], {e, 0, 1}]

or if that suits you better with

CoefficientList[Series[p[x + e, y - e, t], {e, 0, 1}], e][[2]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.