0

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

nate
  • 445
  • 2
  • 7
  • 1
    "I came across this function…" - you might want to link to where you saw it. – J. M.'s missing motivation Jul 11 '16 at 22:14
  • Aahhhh... well I can't - it came via a friend of a colleague, via email. I was hoping its meaning might jump out at someone. ;) It is only invoked at the end by entering in as "expr" a very long ratio of two bivariate polynomials. Then vars={x,y}, etc. – nate Jul 11 '16 at 22:21
  • Did you try using 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:32
  • I didn't try Cancel[], but I just did and it returned the expression. I also agree - I should have tried something like this expr = (xy^3 + xy + x^2y^2) / (x^3 + xy + y + x^2*y^2) which is what I used with Cancel[]. I also note that this function NExpand[] gives an expanded result with each term having the same denominator, though not the original denominator, raised to an integer power... – nate Jul 11 '16 at 22:37
  • I see. Cancel[] 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:42
  • I see.... Short of a Taylor series, how does it do that? I'm not following. How did you see that? Also, I thought it for a specific case, but now from what you say I wonder if the fact that a0=0 was set and meant to be done any time it is used... – nate Jul 11 '16 at 22:45
  • 1
  • Thank you! The accepted answer and yours looks like something I'll look at closely. I don't see the 'Module' business but maybe you corrected that already? I'll add a link to this question so it will point to the one you provided. Or should I just erase my question? – nate Jul 11 '16 at 22:58
  • 1
    Looks to me like the mystery function does exactly what I say in my answer to the question linked by @J.M. - the point is that it's supposed to work for multiple variables and keep only terms up to a fixed cumulative order NN (whereas Series alone keeps higher order terms when given several variables). That's what the trick with lambda does (it's what t does in my answer). – Jens Jul 11 '16 at 23:01
  • I guess I'll have to play around with it a little more, but for the sake of Mathematica use, how would I incorporate the expansion point (x0,y0) different from (0,0)? Would I have to replace x and y by (x-x0) and (y-y0)? – nate Jul 11 '16 at 23:19

0 Answers0