# Implementing an integral test for series convergence

I have to do a project about series convergence. I have to write a package with some tests for convergence. I am having trouble implementing the integral test.

My code is:

IntegCon[f_, m_, n_] :=
Module[{l},
l = Integrate[f, {n, m, Infinity}];
If[l < Infinity, "True", "False"]]


When I try

IntegCon[1/n, 1, n]


I get the message

Integrate::idiv: Integral of 1/n does not converge on {1, ∞}.

Do you have any idea on how can I fix this?

• Check[l = Integrate[..]; "True", "False", Integrate::idiv]? – Michael E2 Jun 7 '17 at 22:44
• Do you need to check the other hypotheses of the integral test? – Michael E2 Jun 7 '17 at 23:00

Also has it's flaws, but could integrate to a symbolic upper bound and take a limit. No compelling need to give a lower bound, it can also be some unspecified symbolic constant so long as it is assumed to be fixed and smaller than the upper bound.

I should add that the comment by @MichaelE2 still holds. There are other hypotheses required and the code below makes no pretense of checking them.

IntegCon[f_, n_] := Module[{integral, lim},
integral =
Integrate[f, {n, m1, m2}, Assumptions -> 1000 < m1 < m2];
lim = Limit[integral, m2 -> Infinity];
FreeQ[lim, DirectedInfinity]]


Here are some examples.

IntegCon[1/n, n]

(* Out[142]= False *)

IntegCon[1/n^2, n]

(* Out[143]= True *)

IntegCon[1/(n*Log[n]), n] (* slow *)

(* Out[144]= False *)