Q) Give an example function $f$ s.t. $f\in L^2(\mathbb{R})$ but $f\notin L^p(\mathbb{R})$ for $p\neq 2, 0<p<\infty$.
I can give an example of $f = \frac{1}{\sqrt{x}}$ where the domain of $f$ is either $(0,1]$ or $[1,\infty)$ if the question were $f$ s.t. $f\in L^2, f\notin L^p$ for $p>2$ or $p<2$. But how can I solve this question? Thanks.
This example should work: $$ f(x) = \frac{1}{\sqrt{x} \ln x} \left( \chi_{(0; \frac{1}{2})}(x) + \chi_{(2; +\infty)}(x)\right). $$ It's not difficult to verify that $f \in L^2$ and at the same time $$ \frac{1}{\sqrt{x} \ln x} \chi_{(0; \frac{1}{2})}(x) \notin L^p, \; p>2 $$ and $$ \frac{1}{\sqrt{x} \ln x} \chi_{(2; +\infty)}(x) \notin L^p, \; p<2 $$