# Replace variable in Series expression

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.

• 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

(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

• 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 6:39