How to find a function in $ L_{2}(0,\infty)$ but not $L_{q}(0,\infty)$, $q\neq 2 $ How to find $x\in L_{2}(0,\infty)$ \ $L_{q}(0,\infty)$  ,  $q\neq 2 $
i tried $\frac{1}{t.lnt}$ with various degrees on $t$ and $ln(t)$
Could you please help me with this question  
 A: Case I. $p>2$. Then let
$$
f(x)=\left\{\begin{array}{lll}x^{-a}&\text{if}& x\in(0,1), \\ 0 & \text{otherwise}\end{array}\right.
$$ 
where 
$$
\frac{1}{p}<a<\frac{1}{2}.
$$
We have
$$
\int_0^\infty |f(x)|^2\,dx=\int_0^1 x^{-2a}\,dx=\frac{x^{1-2a}}{1-2a}\big|_0^1=\frac{1}{1-2a}<\infty,
$$
while
$$
\int_0^\infty |f(x)|^p\,dx=\int_0^1 x^{-pa}\,dx\ge \int_0^1 \frac{dx}{x}=\infty.
$$
Case II. $p<2$. Then let
$$
f(x)=(1+x)^{-a},
$$
where
$$
\frac{1}{p}>a>\frac{1}{2}.
$$
Then
$$
\int_0^\infty |f(x)|^2dx=\int_0^\infty(1+x)^{-2a}dx=\frac{(1+x)^{1-2a}}{1-2a}\big|_0^\infty=\frac{1}{2a-1}<\infty,
$$
while
$$
\int_0^\infty |f(x)|^pdx=\int_0^\infty(1+x)^{-pa}dx\ge\int_0^\infty(1+x)^{-1}dx=\infty.
$$
A: For $x\in (0,\infty),x\ne 1,$ define $f(x) = \frac{1}{\sqrt x \ln x}\frac{x-1}{x+1}.$
A: I don't know if this is what you were looking for, but it is possible to create a function which is in $L^2$ but not in $L^p$ for any $p\ne2$.
Note that
$$
f_n(x)=\left(x^{\frac{n-1}{n}}+x^{\frac{n+1}{n}}\right)^{-1/2}
$$
is in $L^p$ only for $\frac{2n}{n+1}\lt p\lt\frac{2n}{n-1}$. For $p$ outside that range, $f_n(x)\not\in L^p$. Any $p\ne2$ is outside that range for large enough $n$.
Substituting $x=u^n$, we get
$$
\begin{align}
\int_0^\infty f_n(x)^2\,\mathrm{d}x
&=\int_0^\infty\left(x^{\frac{n-1}{n}}+x^{\frac{n+1}{n}}\right)^{-1}\,\mathrm{d}x\\
&=\int_0^\infty\frac{x^{-\frac{n-1}{n}}}{1+x^{2/n}}\,\mathrm{d}x\\
&=n\int_0^\infty\frac1{1+u^2}\,\mathrm{d}u\\[3pt]
&=\frac{n\pi}2
\end{align}
$$
Thus,
$$
\|f_n\|_{L^2(0,\infty)}=\sqrt{\frac{n\pi}2}
$$
If we define
$$
f(x)=\sum_{n=1}^\infty f_n(x)\,n^{-5/2}
$$
then $f\not\in L^p$ for any $p\ne2$ since $f$ is the sum of positive functions, only finitely many of which are in $L^p$. However, Minkowski's Inequality says
$$
\|f\|_{L^2(0,\infty)}\le\sqrt{\frac{\pi^5}{72}}
$$
