7
$\begingroup$
Limit[Sum[k/(n^2 - k + 1), {k, 1, n}], n -> Infinity]

This should converge to 1/2, but Mathematica simply returns Indeterminate without calculating (or so it would appear). Any specific reason why it can't handle this? Did I make a mistake somewhere?

$\endgroup$
2
  • $\begingroup$ That's because Sum[k/(n^2 - k + 1), {k, 1, n}] // FullSimplify is itself problematic. $\endgroup$ Commented Jul 15, 2016 at 15:28
  • $\begingroup$ I see. Would there be a better way to evaluate such an infinite sum in Mathematica? $\endgroup$
    – Jorice
    Commented Jul 15, 2016 at 15:49

4 Answers 4

10
$\begingroup$

You can use the Euler-Maclaurin formula to get the limit (the sum can be approximated by an integral, which becomes exact in the infinite limit):

f[i_] = i/(n^2 - i + 1);
Integrate[f[k], {k, 0, n}, Assumptions -> n > 0]
Limit[%, n -> Infinity]

1/2

$\endgroup$
9
$\begingroup$

Reverse the order of the summation. i.e., k -> (n - k + 1)

s = Sum[(n - k + 1)/(n^2 - (n - k + 1) + 1), {k, 1, n}] // Simplify

(*  -n + (1 + n^2) PolyGamma[0, 1 + n^2] - (1 + n^2) PolyGamma[0, 1 - n + n^2]  *)

Limit[s, n -> Infinity]

(*  1/2  *)

For an alternative representation

s2 = FullSimplify[s]

(*  -n - (1 + n^2) HarmonicNumber[(-1 + n) n] + (1 + n^2) HarmonicNumber[n^2]  *)

Limit[s2, n -> Infinity]

(*  1/2  *)
$\endgroup$
1
  • $\begingroup$ So without reversing the order you get internally garbage which as NLimit warns has 1/0^1 which leads to Indeterminate: NLimit[(1 + n) HurwitzLerchPhi[1, 1, n - n^2] + Hypergeometric2F1[2, -n^2, 1 - n^2, 1]/n^2 + Hypergeometric2F1[2, 1 + n - n^2, 2 + n - n^2, 1]/(1 + n - n^2), n -> Infinity] $\endgroup$ Commented Jul 4, 2022 at 18:52
5
$\begingroup$

In cases where you can't get a symbolic result, it's also possible to use a completely numerical approach:

Needs["NumericalCalculus`"]

sum[n_?NumberQ] := NSum[k/(n^2 - k + 1), {k, 1, n}]
NLimit[sum[n], n -> Infinity]

(* ==> 0.499999 *)
$\endgroup$
2
$\begingroup$

The problem is that without the limit, the sum doesn't converge, and without the sum the limit is 0. Mathematica can only do one at a time.

At a finite value n, the sum gives a sequence with a $\frac{1}{0}$ or other complexinfinity expression for all values of n, which is a by product of the sum not converging.

You can approximate the limit:

i=4;
Sum[k/(n^2 - k + 1), {k, 1, 10*^i}] /. n -> 10*^i // N

which will give i significant numbers.

$\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.