Finite sum not evaluating

Mathematica refuses to evaluate this summation.

Sum[2^(k + 1)^3 - 2^(k - 1)^3, {k, 0, n}]

It just returns the form unevaluated.

$$\sum _{k=0}^n \left(2^{(k+1)^3}-\ 2^{(k-1)^3}\right)$$

Is there some special command for this case? I think it should evaluate because it is telescopic.

EDIT :Hi, This summation can be evaluated by hand, but Mathematica refuses to evaluate it, how should I write the command so that it gives me a result? my mathemativa is version 10.410

• I don’t see any code or even a question.
– JimB
Nov 9 '18 at 4:27
• @MichaelE2 - doesn't work with v11.3 on my Mac Nov 9 '18 at 4:51
• It is interesting that Sum[2^(k + 1) - 2^(k - 1), {k, 0, n}] simplifies nicely but Sum[2^(k + 1)^2 - 2^(k - 1)^2, {k, 0, n}] does not. Nov 9 '18 at 19:14
• "This summation can be evaluated by hand" then what is the solution for this sum ,because I'm curious ? Nov 9 '18 at 20:30
• I believe the solution is $2^{n^3}+2^{(n+1)^3}-\frac{3}{2}$. A lot of identical terms subtract out. Alternatively the sum can be viewed as $\sum _{k=n}^{n+1} 2^{k^3}-\sum _{k=-1}^0 2^{k^3}$.
– JimB
Nov 9 '18 at 20:40

The problem with telescoping sums is recognizing how many terms are needed before the cancellation is going to start happening. The built-in method only tries to see if cancellation occurs in adjacent terms. If the gap before cancellation is two terms or greater, then the built-in method fails and the sum is not evaluated. It's easy enough to extend the method, but apparently the user has to do this for themselves.

Here's a way to extend the built-in method to longer gaps (based on the code for sumFiniteTelescoping):

clearSumCache[] := DownValues@SumSumParserDumpsumParserEvaluate =
DownValues[SumSumParserDumpsumParserEvaluate][[-2 ;;]];

clearSumCache[];  (* sum results are cached, so either Quit[] or clear the cache *)

mySumsumFiniteTelescopingMaxGap = 3;
InternalInheritedBlock[{SumFiniteSumDumpsumFiniteTelescoping},
SumFiniteSumDumpsumFiniteTelescoping[expr_, {k_, min_ : 1, max_}] /;
Head[expr] == Plus && Length[expr] == 2 :=
Module[{test, lim1, lim2, tgap, idx},
test = False; tgap = 0;
While[! test && tgap < mySum`sumFiniteTelescopingMaxGap,
tgap++;
test =
PossibleZeroQ[idx = 1; Together[(expr[] /. {k -> k+tgap}) + expr[]]] ||
PossibleZeroQ[idx = 2; Together[(expr[] /. {k -> k+tgap}) + expr[]]];
];
dbPrint[tgap];
(lim1 = Quiet[expr[[idx]] /. Table[{k -> k0}, {k0, min, min+tgap-1}] // Total];
(lim2 =
Quiet[expr[[3-idx]] /. Table[{k -> k0}, {k0, max-tgap+1, max}] // Total];
lim1 + lim2 /;
FreeQ[lim2, Indeterminate | DirectedInfinity]) /;
FreeQ[lim1, Indeterminate | DirectedInfinity]) /;
test === True];

Sum[2^(k + 1)^3 - 2^(k - 1)^3, {k, 0, n}]
]
(*  -(3/2) + 2^n^3 + 2^(1 + n)^3  *)

[Edit: Refactored the following.] Another approach is to use the above algorithm with plug-in Method option:

ClearAll[myFiniteTelescoping, getFiniteTelescopingSum];
$myFiniteTelescopingMaxGap = 3; getFiniteTelescopingSum[e1_, e2_, k_, min_, max_, offset_] /; PossibleZeroQ[Together[(e1 /. {k -> k + offset}) + e2]] := Module[{lim1, lim2}, (lim1 = Quiet[e1 /. Table[{k -> k0}, {k0, min, min + offset - 1}] // Total]; (lim2 = Quiet[e2 /. Table[{k -> k0}, {k0, max - offset + 1, max}] // Total]; lim1 + lim2 /; FreeQ[lim2, Indeterminate | DirectedInfinity]) /; FreeQ[lim1, Indeterminate | DirectedInfinity]) ]; getFiniteTelescopingSum[___] :=$Failed;

myFiniteTelescoping[expr_, {k_, min_: 1, max_}] /;
Head[expr] == Plus && Length[expr] == 2 :=
Module[{tgap, res},
tgap = 1; res = $$Failed; While[res ===$$Failed && tgap <= $$myFiniteTelescopingMaxGap, res = getFiniteTelescopingSum[expr[], expr[], k, min, max, tgap]; If[res ===$$Failed,
res = getFiniteTelescopingSum[expr[], expr[], k, min, max, tgap]];
tgap++
];
res /; FreeQ[res, $$Failed]]; myFiniteTelescoping[___] :=$$Failed;

Examples:

Sum[2^(k + 1)^3 - 2^(k - 1)^3, {k, 0, n}, Method -> myFiniteTelescoping]
(*  -(3/2) + 2^n^3 + 2^(1 + n)^3  *)

(* Fails because gap is too great *)
Sum[2^(k + 3)^3 - 2^(k - 1)^3, {k, 0, n}, Method -> myFiniteTelescoping]
(*  Sum[-2^(-1 + k)^3 + 2^(3 + k)^3, {k, 0, n}, Method -> myFiniteTelescoping]  *)

(* Succeeds if we raise the max gap checked *)
Block[{myFiniteTelescopingMaxGap = 5},
Sum[2^(k + 3)^3 - 2^(k - 1)^3, {k, 0, n}, Method -> myFiniteTelescoping]]
(*  -(519/2) + 2^n^3 + 2^(1 + n)^3 + 2^(2 + n)^3 + 2^(3 + n)^3  *)
• excellent explanation, thanks Nov 10 '18 at 15:37
• @zeros You're welcome. :) Nov 12 '18 at 4:48
(sum1 = Sum[2^(k + 1)^3 - 2^(k - 1)^3, {k, 0, n}]) // TraditionalForm Separate into two sums

(sum2 = sum1 /. Sum[f_, iter_] :> (Sum[#, iter] & /@ f)) // TraditionalForm Translate indices

(sum3 = Sum[-2^(k - 1)^3 /. k -> k + 1, {k, -1, n - 1}] +
Sum[2^(k + 1)^3 /. k -> k - 1, {k, 1, n + 1}]) // TraditionalForm Combine sums and cancel like terms with different signs

(sum = Sum[-2^(k^3), {k, -1, 0}] +
Sum[2^(k^3), {k, n, n + 1}]) // TraditionalForm Numerically verifying,

And @@ Table[sum == sum1, {n, 0, 100}]

(* True *)
• Thank you very much, although I still have the doubt because Mathematica can not solve the sum directly Nov 10 '18 at 1:48

Getting the indices right and simplified depends on what values are known. If you are interested in sums of the form

$$\sum _{k=0}^n (f (k+\delta_1)-f (k+\delta_2))$$

where $$\delta_1$$ and $$\delta_2$$ are arbitrary integers and $$n \geq 0$$, then the following function will produce a (usually) simplified formula:

sum[δ1_, δ2_, n_] := Module[{δmin, δmax},
{δmin, δmax} = MinMax[{δ1, δ2}];
Sign[δ1 - δ2] (Sum[f[k], {k, n + δmin + 1, n + δmax}] - Sum[f[k], {k, δmin, δmax - 1}])]

For example, consider

sum[1, -1, n]
(* -f[-1] - f + f[n] + f[1 + n] *)

If we define $$f$$ as in the question:

f[k_] := 2^k^3
sum[1, -1, n]

$$2^{n^3}+2^{(n+1)^3}-\frac{3}{2}$$

In general using

sum[δ1, δ2, n]

gets you 