This self answer consists of three parts. In the first past we provide closed expression for the sum for all vaues of the parameter $x \gt 0$, the second part shows a close relation between the correct result and the wrong one returned by Mathematica, finally, I briefly discuss a well appreciated but wrong answer.
EDIT 19.05.20: official rejection of bug statement from Wolfram added.
Closed expressions for the sum
To begin with, let me write down these closed expressions for the sum
si[x_?# > 1 &, n_] = (
PolyGamma[1, n/(x - 1)] - PolyGamma[1, (n x)/(x - 1)])/(-1 + x)^2; (1)
si[x_?# < 1 &, n_] = (-PolyGamma[1, 1 + n/(1 - x)] +
PolyGamma[1, 1 + (n x)/(1 - x)])/(-1 + x)^2; (2)
and, of course,
si[1, n_] = 1/n^2; (3)
Checking numerically,
Table[{s[1/2, n], si[1/2, n]}, {n, 1, 5}]
(* Out[223]= {{1, 1}, {25/36, 25/36}, {469/900, 469/900}, {73249/176400,
73249/176400}, {547129/1587600, 547129/1587600}} *)
Table[{s[2, n], si[2, n]}, {n, 1, 5}]
(* Out[224]= {{1, 1}, {13/36, 13/36}, {769/3600, 769/3600}, {26581/
176400, 26581/176400}, {737641/6350400, 737641/6350400}} *)
Now for x=2 we get
si[2,n] = PolyGamma[1, n] - PolyGamma[1, 2 n]
This is completely well defined and gives correct numerical results for n>0
, in sharp contrast to the wrong generic result of Mathematica provided in the OP
sg[2,n] = PolyGamma[1, 1 - 2 n] - PolyGamma[1, 1 - n]
Derivation
We start with deriving an integral representation of the sum.
Using the formula
Integrate[Log[1/z] z^(q - 1), {z, 0, 1}, Assumptions -> q > 0]
(* Out[77]= 1/q^2 *)
to replace the denominator, and doing the sum under the integral leads to
si0[x_, n_] := Integrate[Log[1/z] (z^n - z^(n x))/(z - z^x), {z, 0, 1}]
Now adding the assumption x>0 to the integral gives
Integrate[Log[1/z] (z^n - z^(n x))/(z - z^x), {z, 0, 1},
Assumptions -> x > 0]
(* Out[146]= ConditionalExpression[(
PolyGamma[1, n/(-1 + x)] - PolyGamma[1, (n x)/(-1 + x)])/(-1 + x)^2,
x > 1] *)
which returns the condition x>1 and the (correct) expression si[x>1,n]
above.
But what happens in the remaining region of $x$?
Integrate[Log[1/z] (z^n - z^(n x))/(z - z^x), {z, 0, 1},
Assumptions -> 0 < x < 1]
(* Out (-PolyGamma[1, n/(-1 + x)] + PolyGamma[1, (n x)/(-1 + x)])/(-1 + x)^2 *)
At $x=1/2$ this gives
4 (-PolyGamma[1, -2 n] + PolyGamma[1, -n])
which is just as wrong as the generic result sg[x,n]
.
Hence also Integrate[]
has a similar bug as Sum[]
.
What's the remedy? Well, one idea is to just set x->1/2
before doing the integral:
Integrate[
Log[1/z] (z^n - z^(n x))/(z - z^x) /. x -> 1/2, {z, 0, 1},
Assumptions -> x > 0]
(* Out[219]= ConditionalExpression[
4 (PolyGamma[1, 1 + n] - PolyGamma[1, 1 + 2 n]), Re[n] >= -(1/2)] *)
Now the result corresponds to the general correct formula si[x,n].
In order to find a general expression for the region 0<x<1
we could try several values of x
and then guess the result. But here's a simpler way: let x->pi /4
, and after evaluation replace back pi -> 4 x
.
This heuristic trick gives si[x,n]
valid for 0<x<1
.
In summary: there is a bug (at least in my version 10.1.0) which causes wrong results the generic Sum[]
as well as in the generic Integrate[]
.
But nevertheless we were able to find exact results using Mathematica, giving it a nudge.
Relation between correct and wrong expression
Let us compare these two expressions for $x = 2$
s0 = PolyGamma[1, 1 - 2 n] - PolyGamma[1, 1 - n] (* wrong *);
s1 = PolyGamma[1, n] - PolyGamma[1, 2 n] (* correct *);
s0
is returned by Mathematica, and it is wrong, as it leads to infinite values for positive integer n
, s1
was derived by analytic continuation, and it is true as it gives the correct values for positive integers n
.
For brevity we shall say s0
is wrong if it does not conincide with s1
.
It is easy to show that s0 is wrong not only for positive integers n but also for real values, say n=1/5.
{s0, s1} /. n -> 1/5
% // N
(* Out[350]= {PolyGamma[1, 3/5] - PolyGamma[1, 4/5], PolyGamma[1, 1/5] - PolyGamma[1, 2/5]}
Out[351]= {1.33674, 18.992}
*)
So the problem can be decoupled from the divergence.
But we can derive the difference quite generally using the reflection formula of the polygamma function (https://de.wikipedia.org/wiki/Polygammafunktion)
$$(-1)^m \Psi_m(1-z) = \Psi_m(z) -\pi \frac{d^m}{dz^m}{\cot(\pi z)$$
which gives
s1 - s0 = \[Pi]^2/Sin[n \[Pi]]^2 - \[Pi]^2/Sin[2 n \[Pi]]^2
This quantity vanishes only for n=k[PlusMinus]1/3, k[Element]Integers.
Hence s0
is incorrect for all real n
except countably many values. This is sometimes stated as "almost always inccorect".
Comment on the strange answer of Soner
I make this comment because this answer was pretty much appreciated by the community.
In spite of this support this answer is planily wrong, and this goes for the result as well as for the method.
The answer starts with the bold face line "it is not a bug", and then states: "Unless you explicitly state otherwise, Sum evaluates generically, ignoring specific conditions. In your case, the result for generic n is correct" and he quotes s0
.
In fact the expression s0 is wrong for any positive integer n. Simply because it is divergent. And we have furthermore shown that s0 is wrong almost everywhere.
But let's nevertheless turn to the "reasoning" of Soner:
I'm not a newbee but I must admit that I haven't seen yet a magic procedure like this in oder to calculate the value of a function.
The first step is clear: an expansion in n
about the value n=10
in question. To first order this yields
Normal[
Series[PolyGamma[1, 1 - 2 n] - PolyGamma[1, 1 - n], {n, 10, 0}]]
(* Out[251]= 2920725891004177/54192375991353600 - 3/(4 (-10 + n)^2) *)
This shows clearly that the function has a double pole at n=10 and hence is divergent in this point.
Now the magic (or was it perhaps meant as a test of the audience?): the author just throws away the divergent part (by suddenly applying an additional limit n->inf, remember that we were at n=10) and declare the rest as the value of the function.
Simply stated: this is not mathematics. With the same "method" he could as well "prove" that Zeta[1] = 0.
And, of course, this answer cannot serve to reject the bug statment.
Official statement of Wolfram
Here is the official answer to my bug report
Betreff: Re: [CASE:4544347] Bug report Sum[], Integrate[]
Datum: Mon, 18 May 2020 12:09:25 -0500
Von: Wolfram Technical Support
"Hello Wolfgang,
This behavior is not a bug. As is documented in several places in the documentation
https://support.wolfram.com/39071?src=mathematica
https://reference.wolfram.com/language/ref/FullSimplify.html#482986235
and
https://reference.wolfram.com/language/ref/Sum.html#87823560
Mathematica assumes that unspecified symbolic variables are in general complex. Your symbolic expression fails at integers, but this is a measure-zero set of the complex plane, so the 'generic' validity of the Sum is upheld.
Further information on how to use GenerateConditions and Assumptions to avoid these issues is also available in the documentation at the included links."
My comment: To me this answer is remarkable but neither satisfactory nor useful for practical purposes. Considering that I have provided a Mathematica expression which yields the correct values also at integers the simple question is: why doesn't Mathematica return this expression? (Also, the Integrate question was not answered.)
Bottom line: I have received two different strange answers to my observation.