# Does an integral converge/diverge if its sum converges/diverges

I'm sure this has been asked many times before, sorry if it's a duplicate, but when googling this I mostly found instructions on how to do the integral test.

So I was given an integral $$\int_{1}^{\infty} f(x) dx$$ and asked to find whether it converges/diverges. I figured out that it diverges, and the next task was to find the sum $$\sum_{n=1}^{\infty} f(n)$$ where $f(x)$ was the same expression in both tasks. So I concluded that since the integral diverges, the sum also diverges by the integral test. But assume I was given the sum of the series first, and let's say I were to use a limit-comparison test to figure out that the series diverges. If the next task was to calculate the integral, would it still hold to conclude that since the sum of the series $a_n$ diverges, then so does the integral, or does the implication not go both ways? I hope my question was clear, thanks in advance.

edit: Original $f(x)$ was $arctan(\frac{1}{x})$ and $f(n) = arctan(\frac{1}{n})$

• What do you mean by $\int_1^{\infty}a_n dx$? How does $a_n$ vary with $x$? – Bungo Nov 22 '17 at 13:33
• Usually an integral is connected to a sum via Riemann sums, and to do the comparison you need to know that the integrand is decreasing, or something along those lines. Is that the situation you have? – lulu Nov 22 '17 at 13:36
• I'm sorry I should have written $f(x)$ instead, my mistake. It's the same function, that's the point. – novo Nov 22 '17 at 13:36
• If we take $a_n = \sin(\pi n)$, then $\sum a_n$ converges (all the terms are zero), but $\int a_x dx$ diverges. – Bungo Nov 22 '17 at 13:38
• Do you mean $\sum_{n=1}^\infty f(n)$? – ajotatxe Nov 22 '17 at 13:40

If you let $f(x) = \sin(\pi x)$ you have a divergent integral but a convergent sum.

If you don't have information about the values of $f$ between integer points, you can't establish any relationship between the sum and the integral.

@Bungo and @Goddard have given an example of convergent sum and divergent integral.

Example of divergent sum and convergent integral:

Define $f$ as follows:

• $f(n)=\frac1n$ for $n\in\Bbb N$
• $f(x)=0$ if $[x]+\frac1{[x]}\le x \le[x]+1-\frac1{[x]+1}$
• Define $f$ in the intervals $[n-\frac1n,n+\frac1n]$ to be piecewise linear and continuous.

Informally, this is a function which is $0$ except around of integer points, where the graph renders "peaks" of height and base $1/n$.

Then $\sum_{n=1}^\infty f(n)=\sum_{n=1}^\infty\frac1n$, but $\int_1^\infty f(x)dx<\sum_{n=1}^\infty\frac1{n^2}$

Notation: Here, $[x]$ denotes the floor (integer part) of $x$.