# A polynomial with positive integer powers is being displayed as a transcedental function (LerchPhi)

I am defining a polynomial as follows:

g[x_, n_] := x^(n - 1) - \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$i = 1$$, $$n - 1$$]$$( \*FractionBox[\(2 i - 1$$, $$i + n - 1$$]
\*SuperscriptBox[$$x$$, $$i - 1$$])\)\)


When I evaluate it, I get an unnecessarily complicated answer because of n appearing in the denominator of the summation:

In[38]:= g[x, n]

Out[38]= x^(-1 +
n) + (1/((-1 + x) x))(2 x - 2 x^n + x LerchPhi[x, 1, n] -
2 n x LerchPhi[x, 1, n] - x^2 LerchPhi[x, 1, n] +
2 n x^2 LerchPhi[x, 1, n] - x^n LerchPhi[x, 1, -1 + 2 n] +
2 n x^n LerchPhi[x, 1, -1 + 2 n] +
x^(1 + n) LerchPhi[x, 1, -1 + 2 n] -
2 n x^(1 + n) LerchPhi[x, 1, -1 + 2 n])


I simply want my input to be shown with the summation expanded.

How should I define my function to prevent this? I want to perform symbolic computations on the polynomial later on, so I need n as a variable. I tried using Assuming, Simplify, and FullSimplify to no avail.

• Can you explain what you mean by "input to be shown with the summation expanded"? Can you add an example? Commented Feb 12 at 22:13
• Use e.g. Table[ g[x, n], {n, 20}] // Column otherwise there are no simpler expressions than g[x,n] assuming n is in a symbolic form. Commented Feb 12 at 22:46

g[x_, n_?IntegerQ] :=
x^(n - 1) - Sum[((2 i - 1)/(i + n - 1) x^(i - 1)), {i, 1, n - 1}]

g[x, 3]
g[x, n]
g[x, n] /. n -> 3


-(1/3) - (3 x)/4 + x^2

g[x, n]

-(1/3) - (3 x)/4 + x^2


Or use instead g[x_, n_ /; n ∈ PositiveIntegers] to limit to only positive integers.

What happens is that Mathematica is actually able to explicitly compute your series, which seems to contain two instances of LerchPhi (after you do FullSimplify).

Obviously, Mathematica cannot "expand" the series into separate terms for a symbolic $$n$$, but you can not let it calculate the series and preserving the Sum notation by using Inactivate (or Inactive):

Clear[g]
g[x_, n_] := x^(n - 1) - Inactivate[Sum[((2*i - 1)/(i + n - 1))*x^(i - 1), {i, 1, n - 1}], Sum]
(* or *)
g[x_, n_] := x^(n - 1) - Inactive[Sum][((2*i - 1)/(i + n - 1))*x^(i - 1), {i, 1, n - 1}]


Sum will now be preserved, and you can Activate it at need.

g[x, n]
(* x^(-1 + n) - Inactive[Sum][((-1 + 2 i) x^(-1 + i))/(-1 + i + n), {i, 1, -1 + n}] *)

g[x, 2]
(* x - Inactive[Sum][((-1 + 2 i) x^(-1 + i))/(1 + i), {i, 1, 1}] *)
% // Activate
(* -(1/2) + x *)

• This is almost perfect. I can even differentiate the g[x,n] which is great. But I cannot integrate it. Any suggestions to perform general operations on g[x,n]? Commented Feb 14 at 15:55
• Maybe there are some more general approaches. But for this particular case, you can manually distribute the integral and also change the order of summation/integration: Distribute[Integrate[g[x, n], x]] /. Integrate[Inactive[Sum][f_, i_], x_] :> Inactive[Sum][Integrate[f, x], i] Commented Feb 14 at 16:40