1
$\begingroup$

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.

$\endgroup$
  • 4
    $\begingroup$ 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). $\endgroup$ – march Sep 20 '17 at 22:00
  • $\begingroup$ That's a notation with which I am unfamiliar. But thank you. $\endgroup$ – saintsfan342000 Sep 20 '17 at 22:05
3
$\begingroup$

(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
$\endgroup$
  • $\begingroup$ Unbelievable. So that I fully understand and never repeat this mistake: Without the parenthesis, Mathematica is trying to do the replacement within Normal itself? $\endgroup$ – saintsfan342000 Sep 20 '17 at 22:09
  • 1
    $\begingroup$ @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. $\endgroup$ – Mr.Wizard Sep 20 '17 at 22:37
  • $\begingroup$ @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? $\endgroup$ – QuantumDot Sep 21 '17 at 0:19
  • $\begingroup$ @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) $\endgroup$ – Mr.Wizard Sep 21 '17 at 6:39
  • 2
    $\begingroup$ 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. $\endgroup$ – Mr.Wizard Sep 21 '17 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.