2
$\begingroup$

Why MMA delivers this result and how to interpret or reformulate it?

enter image description here

Limit[k Sum[1/i, {i, 1, k - 1}], k -> 0]

I would expect 0 as it is an empty sum.

MMA 12.1


Edit:

Both expressions below deliver the same results for n>0. By which formula MMA calculates the value -1 for n=0? In case of analytic continuation there should be a formula that I couldn't find. What does this formula look like?

enter image description here

I have answered by own question, see below.

$\endgroup$
6
  • 4
    $\begingroup$ Analytic continuation of harmonic numbers. Your sum isn't actually empty, but goes from $1$ to $-1$ in the sense of analytic continuation. $\endgroup$
    – Roman
    Commented Jun 25, 2021 at 16:39
  • 1
    $\begingroup$ Indeed, k* Sum[1/i, {i, 1, k - 1}] performs $k H_{k-1}$. $\endgroup$
    – user64494
    Commented Jun 25, 2021 at 17:01
  • $\begingroup$ On other hand, Sum[1/i, {i, 1, -1}] equals 0 and HarmonicNumber[-1] is ComplexInfinity and 0*HarmonicNumber[-1] performs Indeterminate. $\endgroup$
    – user64494
    Commented Jun 25, 2021 at 17:11
  • $\begingroup$ @user64494 that's precisely why I mentioned analytic continuation. $\endgroup$
    – Roman
    Commented Jun 25, 2021 at 17:15
  • $\begingroup$ I don't find in the documentation to Sum something similar to Sum[...,{i,1,-1}]. $\endgroup$
    – user64494
    Commented Jun 25, 2021 at 18:31

3 Answers 3

3
$\begingroup$

Why MMA delivers this result?

To see more clearly what's happening, let's do one function per line.

Limit[k Sum[1/i,{i,1,k-1}],k->0] is the same as

f1=Sum[1/i,{i,1,k-1}] $=H_{k-1}$

f2=k f1 $=kH_{k-1}$

f3=Limit[f2,k->0] $=-1$

The basic issue is Mathematica evaluates the Sum first assuming it is not empty. This is indeed an issue you can encounter in Mathematica and can be a bit annoying. The basic issue is Sum will give a general form assuming some things about your variables. You can explicitly see these assumptions by using GenerateConditions. Consider the following:

Sum[1/i,{i,1,-1}] $=0$

Sum[1/i, {i, 1, k-1}] $=H_{k-1}$

Sum[1/i, {i, 1, k-1}]/. k->0 $=$ ComplexInfinity

Sum[1/i,{i,1,k-1},GenerateConditions->True] $=H_{k-1}\text{ if }k\in \mathbb{Z}\land k\geq 2$

Sum[1/i,{i,1,k-1},GenerateConditions->True]/. k->0 $=$ Undefined

and how to interpret or reformulate it?

I've encountered this a few times in the past and never found an elegant solution. What I ended up doing was just defining the special cases separately. For your case that's simple. Just plug in $k=0$ initially:

With[{k = 0}, k Sum[1/i, {i, 1, k - 1}]] gives 0.

In more complicated situations you can use Piecewise, If, or Condition to control the evaluation at a lower level.

$\endgroup$
11
  • 1
    $\begingroup$ I'm aware, it's the first example I gives under "Consider the following:". I was just showing the more general form - it's good to avoid hard-coding variables when possible. $\endgroup$
    – bRost03
    Commented Jun 25, 2021 at 18:16
  • 1
    $\begingroup$ I'm not sure what the relevance of that is? $\endgroup$
    – bRost03
    Commented Jun 25, 2021 at 18:30
  • 1
    $\begingroup$ I assume it's not in the documentation because it's fairly common knowledge that the empty sum is $0$ and follows from basic properties of sums. It's empty because $\sum_{i=a}^b$ means $i$ takes on values $a\leq i \leq b$ and there are no values of $i$ such that $1\leq i \leq -1$. $\endgroup$
    – bRost03
    Commented Jun 25, 2021 at 18:39
  • 1
    $\begingroup$ I'm not sure how my words were emotional, but I legitimately don't understand the source of your confusion. Please elaborate and I'll give you a detailed argument. Do you not buy that the empty sum should be 0? Or that it's common knowledge that the empty sum is $0$? Or that $\sum_{i=a}^b f(i) \ ; \ b<a$ is empty? Or that Sum[1/i,{i,1,-1}] is empty? Or what? $\endgroup$
    – bRost03
    Commented Jun 25, 2021 at 18:48
  • 1
    $\begingroup$ Sorry, your statement " it's fairly common knowledge that the empty sum is 0 and follows from basic properties of sums." is not grounded. I don't find it in the documentation. Can you give a reference? TIA. $\endgroup$
    – user64494
    Commented Jun 25, 2021 at 18:56
0
$\begingroup$

@Roman explains the contradiction by a generic result of Sum. There is a way to avoid any contradiction:

Sum[1/i, {i, 1, k - 1}, GenerateConditions -> True]

ConditionalExpression[HarmonicNumber[-1 + k], Element[k, Integers] && k >= 2]

$\endgroup$
1
  • $\begingroup$ I don't find in the documentation to Sum someting similar to Sum[...,{i,1,-1}]. $\endgroup$
    – user64494
    Commented Jun 25, 2021 at 18:25
0
$\begingroup$

The Harmonic number $H_{n-1}$ can be expressed by the Digamma function $\psi(n)$ together with the Euler-Mascheroni constant $\gamma\approx 0.5772$.

$\psi(n)=H_{n-1}-\gamma$

In MMA $\psi(n)$ and $\gamma$ are called by PolyGamma[n] and EulerGamma.

Table[Limit[(PolyGamma[k] + EulerGamma)*k, k -> n], {n, 0, 4}]
*( {-1, 0, 2, 9/2, 22/3} *)

The limes is only necessary for $n=0$, i.e.

Table[(PolyGamma[n] + EulerGamma)*n, {n, 0, 4}]
(* {Indeterminate, 0, 2, 9/2, 22/3} *)

An expression (inspired from here) that delivers values for all integers $n\ge 0$ without using Limit or control commands is

$H_{n-1}=(n-1) \left(1+n \sum _{i=2}^{\infty } \frac{1}{i (i+n-1)}\right)$

Table[(n-1)(1+n*Sum[1/(i(n-1+i)),{i,2,\[Infinity]}]),{n,0,4}]
*( {-1, 0, 2, 9/2, 22/3} *)
$\endgroup$

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.