# Display a polynomial in exponential generating function form

Is there an easy way to have Mathematica display a polynomial in "exponential generating function" form? So, for example, rather than seeing $$1 + 2 x + 3 x^2 + 4 x^3$$ I would like to see $$1 + \frac{1}{1!} 2 x + \frac{1}{2!} 6 x^2 + \frac{1}{3!} 24 x^3$$ It would be especially nice if the output could also be captured in TeX format, as in TeXForm[].

You can easily do this by a simple replacement rule with the command Inactive:

(1 + 2 x + 3 x^2 + 4 x^3) /.  x_^n_ :> x^n Factorial[n]/Inactive[Factorial][n]


which yields the desired output

1+2 x+(6 x^2)/(2!)+(24 x^3)/(3!)

In addition, you can directly hit TeXForm without any problem and capture the desired form:

(1 + 2 x + 3 x^2 + 4 x^3) /. x_^n_ :> x^n Factorial[n]/Inactive[Factorial][n] // TeXForm


$\frac{24 x^3}{3!}+\frac{6 x^2}{2!}+2 x+1$

• I understood this as wanting the taylor series. For example, Series[Exp[x], {x, 0, 10}] for example, Sum[term[Exp[x],x,0,n],{n,0,10}] will give !Mathematica graphics but may be my understanding was wrong. – Nasser Apr 21 '18 at 4:11
• Hmm, I thought the question was about display. Well, s/he now has both answers :D – Soner Apr 21 '18 at 5:00
• By way of clarification, there are many sources of generating functions other than Series[], so I did not intend my question to be limited to the output of Series[]. However, Carl Wolf's example shows that an arbitrary polynomial can be an input to Series[], which then spits it out unaltered, so limiting the action to the output of Series[] is not an actual limitation. – awkward Apr 22 '18 at 12:51

Quick hack

<<MaTeX
term[f_,x_,x0_,n_]:=If[n==0,f/.x->x0,(D[f,{x,n}]/.x->x0) HoldForm[ 1/n!] (x-x0)^n]
myPoly = 1 + 2 x + 3 x^2 + 4 x^3 + 5 x^4;
Plus@@(Sum[term[#,x,0,n],{n,0,10}]&/@List@@myPoly)


MaTeX[%]


it is little tricky to keep terms in same order.

Here is a method that produces the appearance you requested. First, I define a wrapper that renders coefficients the way you want:

MakeBoxes[form[n_,r_], form_] ^:= TagBox[
RowBox[{MakeBoxes[1/n!], MakeBoxes[r,form]}],
#&,
SyntaxForm->Power
]
MakeBoxes[form[0,r_], form_] := MakeBoxes[r, form]


For example:

form[2,6] //TeXForm


$\frac{1}{2!}6$

Then, I define a function to transform a SeriesData object (produced by the Series function):

toEGF[HoldPattern@SeriesData[a_,b_,c_,d_,e_,f_]] := Module[
{orders, coeffs},

orders = Range[d,d+Length[c]-1];
coeffs = Replace[
Transpose[{orders, orders! c}],
{n_,r_}:>form[n,r]
{1}
];
SeriesData[a,b,foo,d,e,f]
]


ser = Series[1 + 2x + 3x^2 + 4x^3, {x, 0, 3}];
`
$$1+\frac{1}{1!}2 x+\frac{1}{2!}6 x^2+\frac{1}{3!}24 x^3+O\left(x^4\right)$$