# Sum with IntegerQ does not converge

Why does Mathematica return:

Sum::div: Sum does not converge. >>


when I input:

Sum[Boole[!IntegerQ[x]], {x, 1, Infinity}]


The sum is obviously $0$.

• What seems to happen is that !IntegerQ[x] gets evaluated right away to True, this is before the sum takes hold. Hence the result becomes Boole[True] which is 1 and the whole sum becomes just Sum[1, {x, 1, Infinity}] which diverges. You can see this more clearly like this: !Mathematica graphics need to find a way to tell M to delay this evaluation. – Nasser Apr 13 '14 at 14:07
• what do you get for a finite sum? – george2079 Apr 13 '14 at 14:11
• The sum is 0 for any arbitrarily large finite value, but the infinite sum doesn't converge. I'm not sure why it evaluates it to true if I'm summing over natural numbers. – user85798 Apr 13 '14 at 14:12
• You can also see this more clearly like this Sum[Boole[Not[IntegerQ[x]]], {x, 1, k}] which gives k. So let k to any value, say Infinity, and you see the problem. It is all due to evaluation of !IntegerQ[x] before the sum even starts. Since you are summing to Infinity, I am not sure how else M will handle this, as the function needs to be analytical for M to figure the sum. – Nasser Apr 13 '14 at 14:24
• So how do I make Mathematica evaluate the sum correctly? – user85798 Apr 13 '14 at 14:31

found something that works:

 Sum[Boole[! (IntegerPart[x] == x)], {x, 1, Infinity}]


0

This other thing I suggested does not work:

 intq[x_?NumericQ] := IntegerQ[x];
Sum[Boole[! intq[x]], {x, 1, Infinity}]


(* remains unevaluated *)

It could be Sum is smart enough to first simplify assuming integers:

 Simplify[ Boole[(! IntegerPart[x] == x)] , Element[x, Integers]]
Simplify[ Boole[! intq[x]] , Element[x, Integers]]


0

Boole[! intq[x]]

Before x is a assigned a value its Head is Symbol. Thus IntegerQ[x] yields False.

That means Boole[!IntegerQ[x]] will be simplified to 1 and the sum will not converge. This can be seen with Trace.

Any integer value as upper bound of the sum will however yield 0 as expected.

Sum[Boole[! IntegerQ[x]], {x, 1, 100}]


Out:

0


As far as I understand the behaviour of Sum in thise case it will evalute the exrpession symbolicaly in case of an infinite sum and numericaly in case of a finite sum.

edit: sorry didn't notice the comments