1

I am trying to generate a series expansion in terms of the variable t then substitute a value in for it. However it seems that something about the SeriesData object returned by Series doesn't permit a standard slashdot replacement.

Series[(a^4 - (a - t)^4), {t, 0, 4}] // Normal /. t -> a/20

returns

4 a^3 t - 6 a^2 t^2 + 4 a t^3 - t^4

which is the same result as though the slashdot isn't even there.

On the other hand, replacing prior to Normal results in an undesirable output.

Series[a^4 - (a - t)^4 , {t, 0, i}] /. t -> a/20 // Normal

returns

(4 a^3 a)/20 - 6 a^2 (a/20)^2 + 4 a (a/20)^3 - (a/20)^4 + O[a/20]^6

This is on the right track, but I am left with the BigO and no amount of Simplify or its related functions can get the expression to condense to C*a^4.

To further complicate things, I am trying to run this within a For loop where I increment the number of kept terms.

For[i = 1, i <= 4, i++, 
 Print[Series[a^4 - (a - t)^4), {t, 0, i}] // Normal /. t -> a/20]]

So, how can I do the Series expansion, substitute a/20 in for t, and get a nice output that is, ideally, some constant times a^4. Much thanks.

  • 4
    Normal@Series[(a^4 - (a - t)^4), {t, 0, 4}] /. t -> a/20. Operator precedence. in other words, implicitly, your original expression is interpreted like this: Series[(a^4 - (a - t)^4), {t, 0, 4}] // (Normal /. t -> a/20). – march Sep 20 '17 at 22:00
  • That's a notation with which I am unfamiliar. But thank you. – saintsfan342000 Sep 20 '17 at 22:05

1 Answers1

3

(As march beat me to comment) I think you have a precedence problem with the postfix application //. Try this:

(Series[(a^4 - (a - t)^4), {t, 0, 4}] // Normal) /. t -> a/20
(29679 a^4)/160000
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • Unbelievable. So that I fully understand and never repeat this mistake: Without the parenthesis, Mathematica is trying to do the replacement within Normal itself? – saintsfan342000 Sep 20 '17 at 22:09
  • 1
    @saintsfan342000 Yes! I realize this is probably annoying but it follows from standard precedence rules. This is actually useful in other cases, once you know to expect it. – Mr.Wizard Sep 20 '17 at 22:37
  • @Mr.Wizard From a software design standpoint I find this precedence choice to be a flaw. On no occasion have I ever wanted to do a replacement only on the suffixed function; I always want to replace on the entire thing to the left. Do you know why it is designed this way? – QuantumDot Sep 21 '17 at 00:19
  • @QuantumDot I am very tired from exercise and probably not thinking at my best. However if I am not mistaken the explanation is easy: each operator only has one binding power, i.e. the left and right sides are treated similarly. (continued) – Mr.Wizard Sep 21 '17 at 06:39
  • 2
    If /. had a lower binding power then things like {1, 2, 3} /. {2 -> 7} // Print would group like {1, 2, 3} /. ({2 -> 7} // Print) which is totally undesirable in most cases in my experience. // is specifically useful because of its low binding power allowing most things on the left-hand-side to "stay together." That the right hand side, e.g. // Normal /. t -> a/20 is also grouped together is merely an unfortunate consequence, though this too can at least occasionally be exploited usefully. – Mr.Wizard Sep 21 '17 at 06:39