Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

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

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:

Replace[
Normal@Series[p[x, y, t], {x, a, 1}, {y, b, 1}], 
{x - a -> \[Epsilon], y - b -> -\[Epsilon]}, 
Infinity] 
/. {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 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 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 at 10:48
    
@sebhofer Don't forget to post this as an answer. –  Pickett Aug 12 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 at 15:45

1 Answer 1

up vote 2 down vote accepted

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

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

or

Series[p[x+ex,y-ey,t],{ex,0,1},{ey,0,1}]

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

 
discard

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.