How can I force Mathematica to completely evaluate a subexpression before using a replacement rule?
For example, consider the following definition (for the series of n correction factors in Stirling's formula):
stirlingSeries[n_] :=
Series[Exp[
Total[Table[(-1)^(k - 1)/k t^k h^(k/2 - 1), {k, 3,
2 n + 2}]]], {h, 0, n}] /.
t^m_ -> If[Mod[m, 2] == 0, (m - 1)!!, 0]
What I want to tell Mathematica to do is replace powers of t at the end, as the very last step in calculating stirlingSeries[n]. Instead, it replaces them first. This changes the result of the calculation.
