Force Mathematica to display `Series` in factorial notation
You can do this with some tinkering with Inactive
, since that's one of the ways to prevent the factorial from evaluating:
factorialForm[s : HoldPattern @ SeriesData[x_, x0_, coeffList_List, n0_, n1_, 1]] :=
With[{powRange = Range[n0, n0 + Length[coeffList] - 1]},
SeriesData[x, x0,
Divide[
coeffList * Factorial[powRange],
Map[Inactive[Factorial], powRange]
],
n0, n1, 1
]
];
factorialForm[Series[Sin[x], {x, 0, 10}]]
Instead of Inactive[Factorial]
there are other holding constructs you can use, like Defer[Factorial[#]]&
or HoldForm[Factorial[#]] &
. The nice thing about Inactive
is that you can easily get rid of it again with Activate
.
I only implemented this for SeriesData[__, 1]
. You'd have to do a little thinking if you to make it work for other step sizes.
Also possible is:
$Post = #1 /. HoldPattern[SeriesData[Verbatim[z__]]] :> SeriesData[z] /.
Rational[a_, b_] :>
With[{invf = Reduce`FactorialInverse[b][[1]]},
a/HoldForm[invf!]] & ;
Then
Series[Sin[Pi*x],{x,0,10}]
displays as desired.
Here is a function you can use to replace Series[]
:
inactiveSeries[f_, {x_, x0_, n_}] := Module[{kk, tc},
tc[kk_] = Inactivate[Evaluate[SeriesCoefficient[f, {x, x0, kk}]],
Factorial | Gamma | Pochhammer];
Sum[tc[kk] (x - x0)^kk, {kk, 0, n}] + O[x, x0]^(n + 1)]
For example,
inactiveSeries[Sin[π x], {x, 0, 10}]
A more complicated example:
inactiveSeries[Hypergeometric1F1Regularized[-1/3, 1/5, x], {x, 0, 3}]