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

  • 1
    I don’t see any code or even a question. – JimB Nov 9 at 4:27
  • 2
    @MichaelE2 - doesn't work with v11.3 on my Mac – Bob Hanlon Nov 9 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. – bill s Nov 9 at 19:14
  • "This summation can be evaluated by hand" then what is the solution for this sum ,because I'm curious ? – Mariusz Iwaniuk Nov 9 at 20:30
  • 2
    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 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@Sum`SumParserDump`sumParserEvaluate = 
   DownValues[Sum`SumParserDump`sumParserEvaluate][[-2 ;;]];

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

mySum`sumFiniteTelescopingMaxGap = 3;
Internal`InheritedBlock[{Sum`FiniteSumDump`sumFiniteTelescoping},
 Sum`FiniteSumDump`sumFiniteTelescoping[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[[1]] /. {k -> k+tgap}) + expr[[2]]]] || 
      PossibleZeroQ[idx = 2; Together[(expr[[2]] /. {k -> k+tgap}) + expr[[1]]]];
    ];
   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[[1]], expr[[2]], k, min, max, tgap];
If[res === $Failed,
     res = getFiniteTelescopingSum[expr[[2]], expr[[1]], 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 – zeros Nov 10 at 15:37
  • @zeros You're welcome. :) – Michael E2 Nov 12 at 4:48
(sum1 = Sum[2^(k + 1)^3 - 2^(k - 1)^3, {k, 0, n}]) // TraditionalForm

enter image description here

Separate into two sums

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

enter image description here

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

enter image description here

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

enter image description here

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 – zeros Nov 10 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[0] + 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

General formula

Adding additional parenthesis eliminates problems and becomes easy to evaluate.

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

works as expected. Evaluating the terms of the series and its proposed solution by use of

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

produces a string of zeros.

  • Your Table command works without the additional parentheses, too! – Michael E2 Nov 12 at 4:31

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.