I know this is not great, as far as a question, but I came across this function,
NExpand[expr_,vars_,NN_Integer/;NN>0]:=
Expand[
Normal[
Series[
expr/.((#->lambda #)&/@vars)
,{lambda,a0,NN}]
]/.lambda->1
]
involving some work with power series and I'm not really sure I understand it.
I checked it by the following:
expr = x^2*y + y
vars = {x,y}
expr/.((#->lambda #)&/@vars)
yielding;
x^2*y*lambda^3 + y*lambda
I know a little about a slot and about a pure function, so the # and the & don't really bother me too much. Going on...
Normal[Series[%, {lambda, a0, 3}]]
resulted in;
(a0 y + a0^3 x^2 y) +
(y + 3 a0^2 x^2 y) (lambda - a0) +
3 a0 x^2 y (lambda - a0)^2 +
x^2 y (lambda - a0)^3
which then has lambda set to 1 and expanded. This resulting in the original expression (for this case at least).
x^2*y+y
Clearly this is not a Series[] alone, but is this some method in mathematics or mathematical algorithms that is used to generically expand expressions into sums of monomials? Or....? I realize this is a difficult question but still appreciate any insight.
See the linked question
Cancel[]instead on that bivariate rational function? Also, now that you mention it, you could have chosen a rational function as a more illustrative example than a polynomial. – J. M.'s missing motivation Jul 11 '16 at 22:32Cancel[]will supposedly yield a polynomial if the numerator and denominator have common factors. In this case, your mystery function was intended to give a multivariate polynomial that very nearly approximates your original rational function. – J. M.'s missing motivation Jul 11 '16 at 22:42NN(whereasSeriesalone keeps higher order terms when given several variables). That's what the trick withlambdadoes (it's whattdoes in my answer). – Jens Jul 11 '16 at 23:01