       Re: error with Sum and Infinity

• To: mathgroup at smc.vnet.net
• Subject: [mg102271] Re: error with Sum and Infinity
• From: Albert Retey <awnl at gmx-topmail.de>
• Date: Mon, 3 Aug 2009 05:48:18 -0400 (EDT)
• References: <h53o1e\$1i8\$1@smc.vnet.net>

```Hi,
>
> 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 = 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:= Sum[ t[i], {i, 1, Infinity}]
> Out= 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}]

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

ClearAll[t]
t[i_?NumericQ]=0
t=1

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:

ClearAll[t]
t[i_]:=If[t==3,1,0]

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.

hth,

albert

```

• 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