6

Compare the following. (The option specified is the default value; just to be explicit.)

Sum[b^n, {n, 0, ∞}, VerifyConvergence -> True]  (* 1/(1-b) *)
Sum[2^n, {n, 0, ∞}, VerifyConvergence -> True]  (* failure to converge *)

Is this difference behavior deducible from the documentation? Should the first result be considered a bug, or just a feature that counts on user discretion?

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
Alan
  • 13,686
  • 19
  • 38

2 Answers2

9

One option Sum provides is GenerateConditions

Sum[b^n, {n, 0, ∞}, GenerateConditions -> True]
Sum[2^n, {n, 0, ∞}, GenerateConditions -> True]

The first replies:

ConditionalExpression[1/(1 - b), Abs[b] < 1]

while the second gives the Sum does not converge warning.

Feyre
  • 8,597
  • 2
  • 27
  • 46
bill s
  • 68,936
  • 4
  • 101
  • 191
  • Plus, the documentaiton has remarks such as "Use GenerateConditions to get the conditions under which the answer is true:", "Get the conditions for summability:", "Get the conditions for convergence:", etc. – Szabolcs Sep 05 '16 at 13:08
  • @Szabolcs That's a bit useful, but what documentation are you looking at. I'm looking here https://reference.wolfram.com/language/ref/Sum.html and here https://reference.wolfram.com/language/ref/GenerateConditions.html Also, please see my subsequent comment. – Alan Sep 06 '16 at 03:26
  • Bill, I might be missing your point or misunderstanding GenerateConditions ... I expected the result you report, but my question is about the result when GenerateConditions has the default value of False. The value returned is valid only for a very restricted range of b. Why is that the correct thing for Mma to return in this case? What is the principle at work? – Alan Sep 06 '16 at 03:32
  • 1
    @Alan It's the Sum page you linked to. I agree it's not easy to find. It's among the examples. – Szabolcs Sep 06 '16 at 06:50
  • @Alan -- I certainly can't speak for the developers intent in choosing the default options. It does go to underscore that you can't blindly trust computer algebra systems. Maybe a good motto would be "trust but verify". – bill s Sep 06 '16 at 13:37
3

Some divergent sums can be evaluated using Regularization. In this specific case, Regularization->"Borel" gives the result that you expected from your first Sum

Sum[2^n, {n, 0, ∞}, Regularization -> "Borel"]

(*  -1  *)

Your first Sum is

f1[b_] = Sum[b^n, {n, 0, ∞}]

(*  1/(1 - b)  *)

While the Sum converges only for Abs[b] < 1, the closed form is defined for b != 1

FunctionDomain[f1[b], b]

(*  b < 1 || b > 1  *)

The regularized Sum is

f2[b_] := Sum[b^n, {n, 0, ∞}, Regularization -> "Borel"]

As with f1, f2[1] is undefined

f2[1]

(*  Sum[1, {n, 0, ∞}, Regularization -> "Borel"]  *)

However, f2[0] is also undefined since 0^0 (the first term) is undefined

f2[0]

(*  Sum[0^n, {n, 0, ∞}, Regularization -> "Borel"]  *)

Demonstrating that the functions are equivalent (except for b == 0)

Plot[{f1[b], f2[b]}, {b, -3, 3},
 Exclusions -> {b == 0, b == 1},
 PlotStyle -> (AbsoluteDashing[#] & /@
    {{5, 5}, {10, 10}}),
 PlotLegends -> {f1, f2}]

enter image description here

However, f2 is much slower

AbsoluteTiming[ans1 = f1 /@ Cases[Range[-3, 3, 1/20], _Rational];]

(*  {0.000225, Null}  *)

AbsoluteTiming[ans2 = f2 /@ Cases[Range[-3, 3, 1/20], _Rational];]

(*  {1.62083, Null}  *)

Verifying that results are identical

ans1 === ans2

(*  True  *)
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Thanks, but I am not asking about regularization. I am asking why the first case returns a result that is not generally true (and in fact is true for a narrow range of parameter values). Since the default Regularization is None, I don't think that the possibility of regularization justifies the return value in the first case. What is the principle at work. I realize Mma often returns expressions that are not true for all parameter values, but usually this is a matter of ignoring singularities in order to produce a generally useful result. This example does not fit that justification. – Alan Sep 06 '16 at 03:38