Under what conditions do we have $\int_{0}^{\infty} |f(x)|^2 dx \leq C \int_{0}^{\infty} x^2 |f^{\prime}(x)|^2 dx$?

Constant is $\boldsymbol{\le4}$

Whatever conditions are needed to justify the following steps: $$ \begin{align} \int_0^\infty|f(x)|^2\,\mathrm{d}x &=\int_0^\infty\left|\int_x^\infty f'(t)\,\mathrm{d}t\right|^2\,\mathrm{d}x\tag1\\ &\le\int_0^\infty\int_x^\infty t^{-3/2}\,\mathrm{d}t\int_x^\infty t^{3/2}|f'(t)|^2\,\mathrm{d}t\,\mathrm{d}x\tag2\\ &=\int_0^\infty2x^{-1/2}\int_x^\infty t^{3/2}|f'(t)|^2\,\mathrm{d}t\,\mathrm{d}x\tag3\\ &=\int_0^\infty t^{3/2}|f'(t)|^2\int_0^t2x^{-1/2}\,\mathrm{d}x\,\mathrm{d}t\tag4\\ &=\int_0^\infty t^{3/2}|f'(t)|^24t^{1/2}\,\mathrm{d}t\tag5\\ &=4\int_0^\infty t^2|f'(t)|^2\,\mathrm{d}t\tag6 \end{align} $$ Explanation:
$(1)$: Funamental Theorem of Calculus (assuming $f$ vanishes at $\infty$)
$(2)$: Cauchy Schwarz
$(3)$: integrate
$(4)$: change order of integration
$(5)$: integrate
$(6)$: simplify

It seems that if $(6)$ exists and $f$ vanishes at $\infty$, the inequality holds.


$\boldsymbol{4}$ is Sharp

Define $$ f_a(t)=\frac{t^{-1/2}}{t^{-a}+t^a}\tag7 $$ then $$ \begin{align} \int_0^\infty f_a(t)^2\,\mathrm{d}t &=\int_0^\infty\frac{t^{-1}}{\left(t^{-a}+t^a\right)^2}\mathrm{d}t\tag8\\ &=\int_0^\infty\frac{t^{2a-1}}{\left(1+t^{2a}\right)^2}\mathrm{d}t\tag9\\ &=\frac1{2a}\int_0^\infty\frac1{(1+t)^2}\mathrm{d}t\tag{10}\\[6pt] &=\frac1{2a}\tag{11} \end{align} $$ Explanation:
$\phantom{1}(8)$: apply $(7)$
$\phantom{1}(9)$: multiply numerator and denominator by $t^{2a}$
$(10)$: substitute $t^{2a}\mapsto t$
$(11)$: evaluate

Taking the derivative of $(7)$ $$ f_a'(t)=\frac{t^{-\frac32+a}\left(4a+(1-2a)\left(1+t^{2a}\right)\right)}{2\left(1+t^{2a}\right)^2}\tag{12} $$ Thus, $$ \begin{align} \int_0^\infty t^2f_a'(t)^2\,\mathrm{d}t &=\int_0^\infty t^2\,\left(\frac{t^{-\frac32+a}\left(4a+(1-2a)\left(1+t^{2a}\right)\right)}{2\left(1+t^{2a}\right)^2}\right)^2\mathrm{d}t\tag{13}\\ &=\int_0^\infty\frac{t^{-1+2a}\left(4a+(1-2a)\left(1+t^{2a}\right)\right)^2}{4\left(1+t^{2a}\right)^4}\,\mathrm{d}t\tag{14}\\ &=\int_0^\infty\frac{16a^2+8a(1-2a)(1+t)+(1-2a)^2(1+t)^2}{8a(1+t)^4}\,\mathrm{d}t\tag{15}\\[3pt] &=\frac23a+\frac12(1-2a)+\frac1{8a}(1-2a)^2\tag{16}\\[6pt] &=\frac16a+\frac1{8a}\tag{17} \end{align} $$ Explanation:
$(13)$: apply $(12)$
$(14)$: simplify
$(15)$: substitute $t^{2a}\mapsto t$
$(16)$: integrate
$(17)$: simplify

The ratio of $(11)$ over $(17)$ is $\frac4{1+\frac43a^2}$. As $a\to0$, this gets arbitrarily close to $4$.


Here are some thoughts about this question. My guess is that $C=4$ is the optimal value. The computations below are not totally rigorous and some arguments are missing. This can only give some directions for the question.

Consider the function $f$ defined on $[0, +\infty)$ as follows, with $a>1/2$ and $\varepsilon \in [0,1/10]$: $$ f(x)=x^a\quad \mbox{ if } x\leq 1-\varepsilon \quad \mbox{and}\quad f(x)=x^{-a}\quad\mbox{ if } x\geq 1+\varepsilon. $$ On $[1-\varepsilon, 1+\varepsilon]$ construct $f$ such as it is globally of class $\mathcal{C}^1$.

$f$ verifies the conditions and we have $$ f'(x)=ax^{a-1}\quad \mbox{ if } x\leq 1-\varepsilon \quad \mbox{and}\quad f(x)=-ax^{-a-1}\quad\mbox{ if } x\geq 1+\varepsilon. $$ Assuming $f'$ is bounded on $[1-\varepsilon, 1+\varepsilon]$ we can compute both integrals and we get, taking $\varepsilon \to 0$: $$J\doteq \int_0^{\infty} f(x)^2\mbox{d}x\approx\int_0^1x^{2a}\mathrm{d}x+\int_1^{\infty}x^{-2a}\mathrm{d}x=\dfrac{4a}{4a^2-1}.$$ And similarly $$K\doteq \int_0^{\infty} x^2f'(x)^2\mbox{d}x\approx\int_0^1 a^2 x^{2a}\mathrm{d}x+\int_1^{\infty} a^2 x^{-2a}\mathrm{d}x=a^2\dfrac{4a}{4a^2-1}=a^2 J.$$ Finally $$J\approx K/a^2.$$ Taking $a$ close from $1/2$ we obtain $J \approx 4 K$, indicating that $4$ should be the optimal constant.

Note nevertheless that when $a \to 1/2$, we have $J \sim \dfrac{1}{2a-1}$ which diverges.


You say you can prove it if $x|f(x)|^2\to0$. It seems very likely that your proof can be modified to work without that extra assumption.

Because there must exist $x_n\to\infty$ such that $x_n|f(x_n)|^2\to0$; if not then $|f(x)|^2\ge c/x$ for all $x\ge A$, which implies that $\int|f(x)|^2=\infty$.

I haven't seen your proof, but "surely" it works just using integration by parts on the interval $(0,x_n)$ instead of an arbitrary interval.