This question already has an answer here:

I have a rather complicated function that I need to expand it in series, which is quite straightforward but takes a long time. I was wondering if there is a way to speed up such a calculation:

Series[1/(1 + x)^2 y z/.{x->x1+x2+x3+x4,y->y1+y2+y3+y4,z->z1+z2+z3+z4},{x1,0,2},{x2,0,2},{x3,0,2},{x4,0,2},{y1,0,2},{y2,0,2},{y3,0,2},{y4,0,2},{z1,0,2},{z2,0,2},{z3,0,2},{z4,0,2}]

Now the one,sth seconds the above needs to be computed on my laptop is not dramatic but the function I consider is way more complicated and runtime is in the order of hours...Thanks for any advice!


marked as duplicate by Öskå, Jens, bobthechemist, ciao, m_goldberg Jun 30 '14 at 21:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ To get a consistent expansion, you probably want to do something like this instead of the approach in your question: Normal[Series[1/(1 + x)^2 y z /. {x -> ϵ (x1 + x2 + x3 + x4), y -> ϵ (y1 + y2 + y3 + y4), z -> ϵ (z1 + z2 + z3 + z4)}, {ϵ, 0, 2}]] /. ϵ -> 1. In that case, this is probably a duplicate of Multivariable Taylor expansion does not work as expected $\endgroup$ – Jens Jun 30 '14 at 17:33
  • $\begingroup$ Thanks, this is helpful indeed! $\endgroup$ – tks Jul 1 '14 at 11:02