5
$\begingroup$

The Series expansion for Sin[Pi * x] is

Series[Sin[Pi * x], {x, 0, 10}]

Pi * x - (Pi^3 * x^3) /6 + (Pi^5 * x^5) /120 - (Pi^7 * x^7) /5040 + (Pi^9 * x^9) /362880 + O[x]^11

How can I make Mathematica display this using factorial notation? I'd prefer this to read

Pi * xn - (Pi^3 * x^3) /3! + (Pi^5 * x^5) /5! - (Pi^7 * x^7) /7! + (Pi^9 * x^9) /9! + O[x]^11

I appreciate that the result in InputForm is

InputForm[Series[Sin[Pi * x], {x, 0, 10}]]

SeriesData[x, 0, { Pi, 0, Rational[-1, 6] Pi^3, 0, Rational[1, 120] Pi^5, 0, Rational[-1, 5040] Pi^7, 0, Rational[1, 362880] Pi^9}, 1, 11, 1]

So, equivalently, I'm after the output

SeriesData[x, 0, { Pi, 0, Rational[-1, Factorial[3]] Pi^3, 0, Rational[1, Factorial[5]] Pi^5, 0, Rational[-1, Factorial[7]] Pi^7, 0, Rational[1, Factorial[9]] Pi^9}, 1, 11, 1]

$\endgroup$
6
$\begingroup$

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}]]

enter image description here

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.

| improve this answer | |
$\endgroup$
6
$\begingroup$

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.

| improve this answer | |
$\endgroup$
  • 3
    $\begingroup$ Reduce`FactorialInverse is a bit more direct. +1 $\endgroup$ – ciao Sep 24 at 16:35
  • $\begingroup$ @ciao Thank's! I was looking for this function but was not aware where to find it. $\endgroup$ – Rolf Mertig Sep 25 at 7:48
3
$\begingroup$

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}]

output 1

A more complicated example:

inactiveSeries[Hypergeometric1F1Regularized[-1/3, 1/5, x], {x, 0, 3}]

output 2

| improve this answer | |
$\endgroup$

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.