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)$.