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]

enter image description here

  • 4
    $\begingroup$ 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. $\endgroup$
    – Bill
    Commented Jun 22, 2022 at 4:02
  • $\begingroup$ @Bill Thx. I don't think that would work because I already used Element and it gave me the same answer. $\endgroup$
    – ThomasJr
    Commented Jun 22, 2022 at 4:12
  • $\begingroup$ @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. $\endgroup$
    – ThomasJr
    Commented Jun 22, 2022 at 4:51
  • 2
    $\begingroup$ Can you talk a little about where the expression whose limit you're taking came from? $\endgroup$ Commented Jun 22, 2022 at 15:54
  • 1
    $\begingroup$ 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. $\endgroup$
    – ThomasJr
    Commented Jun 22, 2022 at 17:08

1 Answer 1


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


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.



evaluates to


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,


evaluates to




is left unevaluated, which is not wrong, but


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.