Example of a function which is not in $L^p$ for $p\neq 2, 0Q) 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.
 A: 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
$$
A: Let $A_{n}=[n,n+2^{-n})$ for $n\leq -2$ and $B_{n}=(n-1,n]$ for $n\geq 1$, then consider 
\begin{align*}
f=\sum_{n\geq 2}\dfrac{1}{n^{1/p}}\dfrac{1}{(\log n)^{2/p}}\chi_{B_{n}}+\sum_{n\leq-1}\dfrac{1}{|n|^{2/p}}\dfrac{1}{|A_{n}|^{1/p}}\chi_{A_{n}},
\end{align*}
then $f\in L^{p}$ but $f\notin L^{r}$ for any $r\ne p$.
Note that 
\begin{align*}
\sum_{n\leq-1}\dfrac{1}{|n|^{2/p}}\dfrac{1}{|A_{n}|^{1/p}}\chi_{A_{n}}\notin L^{r},~~~~r>p,
\end{align*}
and 
\begin{align*}
\sum_{n\geq 2}\dfrac{1}{n^{1/p}}\dfrac{1}{(\log n)^{2/p}}\chi_{B_{n}}\notin L^{r},~~~~1\leq r<p.
\end{align*}
A: Your example isn't quite right: $\dfrac 1{\sqrt x}$ isn't square integrable on either $(0,1]$ or on $[1,\infty)$.
There are a few ways to proceed. For $a > 0$ define $f_a(x) = \dfrac 1{x^a} \chi_{[1,\infty)}(x)$. It is well-known that $f_a$ is integrable on $\mathbb R$ if and only if $a > 1$ and consequently $f_a \in L^2(\mathbb R)$ if and only if $a > \frac 12$. Define
$$f = \sum_{n=1}^\infty \frac{1}{2^n} \frac{f_{\frac 12 + \frac 1n}}{\|f_{\frac 12 + \frac 1n}\|_{L^2}}$$
so that $f \in L^2(\mathbb R)$. If $0 < p < 2$ then for sufficiently large $n$ you have $p \left( \frac 12 + \frac 1n \right) < 1$ which means that $f_{\frac 12 + \frac 1n} \notin L^p(\mathbb R)$. Consequently (since every function in the sum is positive) you have $f \notin L^p(\mathbb R)$ for all $0 < p < 2$.
You can do a similar construction with functions of the form $g_a(x) = \dfrac 1{x^a} \chi_{(0,1)}(x)$ to construct a function $g \in L^2(\mathbb R)$ with the property that $g \notin L^p(\mathbb R)$ for all $p$ with $2 < p < \infty$.
The function $f+g$ gives you a function in $L^2(\mathbb R)$ that belongs to no other $L^p$ space.
