Consider the list

mylist = {b(a/bc t)^r, a/b(b t)^r, a (c/d t)^r, ...}

where a, b, c, t, etc., are real numbers between 0 and 1. I want to sum each term in the list over r from 1 to infinity. Since my list is very long, Mathematica takes a long time if I evaluate

Table[Sum[mylist[[k]], {r, 1, ∞}], {k, Length[mylist]}]

Instead, I would like to write a function which I can apply to the list such that for each element, x^r -> x/(1-x)? I think this would be a lot faster than Mathematica computing a geometric series for each element.


2 Answers 2


Is this what you are looking for?

data = {b (a/bc t)^r, a/b (b t)^r, a (c/d t)^r};
sums = data /. Power[x_, r] -> x/(1 - x)

$\left\{\frac{a b t}{\text{bc} \left(1-\frac{a t}{\text{bc}}\right)},\frac{a t}{1-b t},\frac{a c t}{d \left(1-\frac{c t}{d}\right)}\right\}$

  • $\begingroup$ That's exactly what I was looking for. Thanks! $\endgroup$
    – Tyrone
    Jul 6, 2013 at 0:55

Here is a fairly general solution for the infinite sum of a real geometric term in an arbitrary variable var from var = n0 to Infinity. There may be some expressions involving special functions that can be simplified to a geometric term that Simplify might miss, and the use of PowerExpand may be omitted if Complex bases are to be used. It was included here to handle Sqrt and other rational powers of expressions. Whether or not to expand over Plus is left to the reader; omit the second part of the definition of gsum if it seems undesirable.

SetAttributes[gsum, Listable];
Module[{r, n},
 gsum[term_, var_, n0_ : 0] /; FreeQ[r = Simplify[
                        PowerExpand[Divide @@ (term /. {{var -> n + 1}, {var -> n}})], 
                        n \[Element] Integers], n] :=
   With[{a = term /. var -> 0},  a/(1 - r)];
 gsum[t1_ + t2_, var_, , n0_ : 0] := gsum[t1, var, n0] + gsum[t2, var, n0];

The OP's examples:

terms = {b (a/bc t)^r, a/b (b t)^r, a (c/d t)^r};

gsum[terms, r, 1]

  (* {(a b t)/(bc (1 - (a t)/bc)), (a t)/(1 - b t), (a c t)/(d (1 - (c t)/d))} *)

Further examples. The last contains terms that do not form geometric sums. The expression gsum returns unevaluated (after threading over Plus).

gsum[{3^r (a + 2)^(2 r), a^(5 r + 3), a^r + b^r + c^r, Sqrt[a^r], r^2 + 2 b^r + c^r^2}, r]

  (* {1/(1 - 3 (2 + a)^2),   a^3/(1 - a^5),
      1/(1 - a) + 1/(1 - b) + 1/(1 - c), 
      1/(1 - Sqrt[a]),       2/(1 - b) + gsum[c^r^2, r] + gsum[r^2, r]} *)

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.