Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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}]? – sebhofer Aug 12 '14 at 10:25
@sebhofer,Actually Series[p[x+e,y-e,t],{e,0,1},{e,0,1}] is what I wanted. – wdg Aug 12 '14 at 10:46
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}] – sebhofer Aug 12 '14 at 10:48
@sebhofer Don't forget to post this as an answer. – C. E. Aug 12 '14 at 14:03
@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 – sebhofer Aug 12 '14 at 15:45
up vote 3 down vote accepted

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]]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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