A power series expansion of a multivariate function can be performed with the Series command, which performs each expansion consecutively. The results can be a bit clunky, however.

Often "mixed" terms will show up. For instance, a function f(x,y) expanded to the first order about zero in x then y will often have terms a*x*y with a some constant. Since we've aske for a first-order expansion, terms like a*x*y are undesirable. It is easy-enough to fix this in the two-variable case with something like this.

ReplaceAll[#,{x*y :> 0}]&

But in n variables, an explosion in the number of possible combinations becomes prohibitive to use this "by-hand" type of fix. Is there an elegant solution to this? I could write a routine to generate all combinations and corresponding list of replacement rules, but this seems... excessive.

Is there a better way to perform the expansion that avoids this? Or is there an elegant simplification method?

  • $\begingroup$ The usual way to do this is to replace vars by t*vars, e.g. Thread[{x,y,z}->t*{x,y,z}], then expand in t, then maybe use Normal[expansion] /. t->1. Modify as needed if not expanding at the origin (either translate or, if at infinity, use reciprocals-- whatever it takes so that you can expand at t=0). $\endgroup$ Aug 20, 2013 at 21:00
  • $\begingroup$ Daniel, thank you for the helpful comment. I've seen this solution before, but had forgotten it. It works well, but when replacing variables in a differential equation (I'm using this to simplify coupled nonlinear partial differential equations), care must be taken to replacement only non-derivative terms, otherwise the expansion occurs in the derivative terms as well (which is not desirable). I may end up using this solution, however, because it's probably the easiest. $\endgroup$ Aug 20, 2013 at 21:49
  • $\begingroup$ @RicoPicone If you could include an example in which Daniel Lichtblau's method does not work, this would seem less a duplicate of the question Jens linked. $\endgroup$
    – Michael E2
    Aug 21, 2013 at 11:07
  • $\begingroup$ @MichaelE2, my application where this issue arises is pretty esoteric, so I doubt it would be of general interest. Because I'm often changing variables of a differential equation, I have substitution routines that substitutes functions for functions, which account for the changes in variable of derivatives with ease. If I use these routines to substitute {x,y,z} for t*{x,y,z}, even terms that are derivatives of {x,y,z} will be replaced and these t coefficients will be expanded over---which is undesirable. However, I realize that most people will simply use ReplaceAll. Which works. $\endgroup$ Aug 26, 2013 at 18:35


Browse other questions tagged or ask your own question.