# Mathematica giving wrong answer for limit of LerchPhi[]

Mathematica is often frustrating to use, due to how it apparently get things wrong at times. It's giving me a totally wrong answer for this below limit (it gets it right though, if I pick a positive integer value for k).

Maybe I need to specify a positive integer value for k, how do I do that? Maybe I am entering the assumptions incorrectly, but what makes me lose my patience is that trying many other different ways doesn't do it, it just ignores all attempts at trying to feed it more information.

Clear[k, n]; Limit[LerchPhi[E^(2*I*Pi*x), -2*k + 1, n + 1] + ((Pi*I*x)/k)*LerchPhi[E^(2*I*Pi*x), -2*k, n + 1], x -> 0, Assumptions -> k > 0 && k*In*Reals]


It gives me LerchPhi[1, 1 - 2 k, 1 + n] as the answer, which is infinity if k is a positive integer, which doesn't make sense since the limit is finite, and LerchPhi[1, 1 - 2 k, 1 + n] is infinity.

Here a practical example plus code:

k = 3; Clear[x]; n = 2; x1 = Limit[LerchPhi[E^(2*I*Pi*x), -2*k + 1, n + 1] + ((Pi*I*x)/k)*LerchPhi[E^(2*I*Pi*x), -2*k, n + 1], x -> 0]


• I'm really sure your use of In is incorrect. You can look up In in the help system and see how it is used. Element[k,Reals] would be better. But simpler, k>0 means k must also be Real because > is meaningless for complex values. Just a fumbling guess, do you perhaps need to tell it anything about the domain of n? Don't know.
– Bill
Jun 22 at 4:02
• @Bill Thx. I don't think that would work because I already used Element and it gave me the same answer. Jun 22 at 4:12
• @MichaelE2 Yes, and that's wrong. I know in theory what it should be, but I can't work it out easily and Mathematica only gets it right for a given integer k. It's wrong as for positive integer k PolyLog[1 - 2 k, 1] is a singularity. But the result should be a finite rational number. Jun 22 at 4:51
• Can you talk a little about where the expression whose limit you're taking came from? Jun 22 at 15:54
• I was able to solve analytically the problem that Mathematica couldn't. It's not trivial, so it's no wonder Mathematica choked. This piece will be featured in my new paper, which i hope to write soon. Jun 22 at 17:08

Specifying that k is a positive integer can be done with Assumptions->And[Element[k,Integers],k>0] but that alone does not seem to do it here.

I just did a bit of detective work to see where the problem could potentially come from, but do not expect a solution. So using

Series[LerchPhi[z,-1,b],{z,1,0}]
Series[LerchPhi[z,-2,b],{z,1,0}]


one sees that there is a 2nd order pole at $$z=1$$ in the first case, a 3rd order pole at $$z=1$$ in the second case, and this continues predictably. In fact LerchPhi[z,-1,b] is rational in $$z$$, actually a polynomial in $$1/(z-1)$$, and evaluates to a rational expression even before Series does its work. Same for LerchPhi[z,-2,b] and so on.

However

Series[LerchPhi[z,-a,b],{z,1,0}]


evaluates to

LerchPhi[1+O[z-1]^1,-a,b]


and that is also the case when adding Assumptions->And[Element[a,Integers],a>0] and one can start to guess where the trouble comes from. For comparison,

Series[unknownsymbol[z,-a,b],{z,1,0}]


evaluates to

unknownsymbol[1,-a,b]+O[z-1]^1


Interestingly

Limit[(z-1)*LerchPhi[z,-a,b],z->1]


is left unevaluated, which is not wrong, but

With[{z=Exp[x]},
Limit[(z-1)*LerchPhi[z,-a,b],x->0]]


evaluates to 0, even if we add Assumptions->..., which is not right.

As someone who has never myself thought much about the algorithmic side of such symbolic computations, which is clearly a very difficult problem in general, and as someone who is regularly impressed by what Mathematica can do, I guess here one could have hoped, from a naive user perspective, that Mathematica would recognize that it does not know the answer, and that it would leave things unevaluated. On the other hand, explicitly evaluating the limit in your post requires cancellations among various terms of the Laurent series at $$z=1$$, where the order of the poles depends on k. For symbolic k, that seems somewhat subtle for an algorithm to figure out. I usually expect that I need to do work myself, often interactive work with the computer, if there is something slightly subtle going on. Now in this particular case one can figure out, thanks to Mathematica and OEIS and some guesstrapolation, that the limit is -1/(2*k)*BernoulliB[2*k,-n].

• Upvoted for "guesstrapolation". I also do this sometimes. Jun 22 at 19:37
• Where this problem appears. See page 5 of researchgate.net/publication/… Jun 27 at 5:56