Continuous function $f$ on $\mathbb R$ such that $f \notin L^1 (\mathbb R)$ but $f \in L^1([a,b]), a< b$

Give an example of a continuous function $f$ on $\mathbb R$ such that $f \notin L^1 (\mathbb R)$ but $f \in L^1([a,b]), a< b$

If $f \in L^1([a,b]), a< b$ that would mean that $$\int_{a}^{b}|f(x)|dx < \infty \text{ but f \notin L^1 (\mathbb R) means} \int_{\mathbb R}|f(x)|dx\to \infty \text { or undefined.}$$

I feel like there are many examples for this, like $f(x)=x$, but this was given on a exam, so I think I am not understanding this correctly, what are your guys' thoughts on this?

Also the second part of the question was to give an example of a continuous function $f$ on $\mathbb R$ such that $f$ is Reiman integrable on $\mathbb R$ but $f \notin L^1 (\mathbb R)$ . Now this seems like it is impossible to me. We have done the other way around in class, but this I just don't know at all how I would go about, maybe constructing a set that satisfies this. Help is needed, very thankful for insight.

How about $f(x)\equiv1$ for the first one, since then $\int_a^bf(x)dx=b-a<\infty$, but clearly $f\not\in L^1(\Bbb R)$. For the second, pick a function that oscillates enough that cancellation allows integrability but not absolute integrability. The answer below has a nice example.

EDIT: If one of $a$ or $b$ is infinite (at the appropriate end of the real line), then pick $f(x)=e^{\alpha x}$ and choose $\alpha$ so that $f\in L^1(a,b)$ but not $L^1(\Bbb R)$.

• Could you give detail into this, and why $f(x)=x$ won't work? The first one seems trivial to me, but I think that is because I am not understanding something here. Jan 24, 2016 at 23:36
• @JerryWest $f(x)=x$ works, $f(x)=1$ makes the calculation slightly easier.
– Ian
Jan 24, 2016 at 23:36
• Im interested in this calculation that is spoken about. Can someone go into that a little? Jan 24, 2016 at 23:38
• Can you show that why the limit for $f^\pm$ exist? It's not true even for series.
– user99914
Jan 24, 2016 at 23:55
• @JohnMa nope. Will edit. Jan 24, 2016 at 23:56

By definition, a function is Lebesgue integrable on $\mathbb R$(i.e. $\in L^1(\mathbb R)$ if its modulus is Lebesgue integrable. (Improper) Riemann integrability on $\mathbb R$, on the other hand is defined as existence of the limit

$$\lim_{a\rightarrow -\infty}\lim_{b\rightarrow \infty} \int _a^b f(x)dx,$$

where the integral $\int _a^b f(x)dx$ is a proper Riemann integral.

So we're looking for a function where $|f|$ makes some problems when integrating, but $f$ does not.

The alternating harmonic series $\sum_{n=1}^\infty (-1)^n \frac{1}{n}$ is a convergent series, but the harmonic series $\sum_{n=1}^\infty \frac{1}{n}$ does not converge to a finite value.

Thus $$f(x)= \begin{cases}(-1)^n \frac{1}{n}, \mbox {if }n\leq x < n +1\\ 0, \mbox{otherwise} \end{cases},$$

is a function which is Riemann integrable, but its modulus $|f(x)|= \begin{cases} \frac{1}{n}, \mbox {if }n\leq x < n +1\\ 0, \mbox{otherwise} \end{cases},$ is neither Riemann nor Lebesgue integrable. Thus, $f \notin L^1(\mathbb R)$.

Basically both example are correct, and you can think at any continuous function having a non zero limit at infinity... For the second statement, Riemann integrable implies Lebesgue integrable, I think maybe, you forgot the term improperly front of Riemann integrable.