MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: error with Sum and Infinity

> i'm very new to Mathematica and this is my first problem. I define a
> function that is 0 everywhere:
> t[i_] := 0
> expect for point i =3 that is:
>  t[3] = 1
> If now i evaluate the finite sum i obtain 1 as expected
> Sum[ t[i], {i, 1, 10}]
> Out = 1
> but if i try do the same with infinity i obtain
> In[808]:= Sum[ t[i], {i, 1, Infinity}]
> Out[808]= 0
> instead of 1 expected. 

Could you really expect that? If you look at the documentation of Sum
you will find that there is possibliy happening a lot more behind the
scenes than summing up terms. For an infinte sum it is quite clear that
Mathematica _must_ do something different from creating infinitly many
terms and add them. What it does is to evaluate the Sumand symbolically
and tries to do some things symbolically with it, and because for
arbitrary symbolic argument t returns zero Mathematica will return zero
as the result for the sum. Actually for performace reasons it will do so
for finite large values too, as you can see from:

Sum[t[i], {i, 1, 1000000}]

Sum[t[i], {i, 1, 1000001}]

> Any advice?

You can make Mathematica behave more consistant if you'd restrict the
evaluation to numeric arguments:


then it will just return the infinit sum unevaluated, basically telling
you that it can't do the sum without further hints. A probably even
better approach is to use a completley different way to define t:


then you will always get the correct result (and in many cases much
faster!). This is because now mathematica gets the chance to analyse the
symbolic If-expression. The same works for some other constructs like
Which, too.



  • Prev by Date: Re: A Sum-like notation for iteration
  • Next by Date: Re: error with Sum and Infinity
  • Previous by thread: Re: error with Sum and Infinity
  • Next by thread: Re: error with Sum and Infinity