Is there a real valued positive function such that it and its square integrate to $1$ Does there exist a function $f : \mathbb{R} \rightarrow \mathbb{R}$ such that $f > 0$ and
$$
\int_{-\infty}^\infty f(x) dx = \int_{-\infty}^\infty f(x)^2 dx = 1.
$$
I suspect the answer is yes. I have looked at taking $f$ to be the PDF of a normal distibution $\mathcal N(0, \sigma)$ to guarantee that $f > 0$ and integrates to give $1$. I'm thinking about using IVT to find a value of $\sigma$ that works. However, in order to do this, I'm not entirely sure how to integrate $e^{x^4}$.
 A: It is possible. Take
$$f(x) = 2 e^{-4|x|}$$
$\int_{\Bbb{R}} f \:dx = \int_{\Bbb{R}} f^2 \:dx = 1$ as desired.
A: For $a>0$, $p>1$, we have
$$
\int _0^{\infty} \frac{1}{(a+x)^p}\,dx=\frac{a^{1-p}}{p-1}
$$Similarly, for $b>0$, we have
$$
\int _{-\infty}^0 e^{bx}\,dx = \frac{1}{b}
$$So if we let $f(x):\mathbb{R}\to\mathbb{R}$,
$$
f(x) = \begin{cases}
e^{bx}, & x <0\\
\frac{1}{(a+x)^p},& x\geq 0
\end{cases}
$$the question amounts to finding $(a,b,p)$ such that:
$$
\begin{cases}
\frac{1}{b} + \frac{a^{1-p}}{p-1} & = 1\\
\frac{1}{2b} + \frac{a^{1-2p}}{2p-1} & = 1\\
\end{cases}
$$Mathematica gives one solution as (approximately) $( 0.80297, 2.50859,5)$. You could probably modify this example to be continuous or even differentiable.
If you don't require $f(x)>0$, a well-known example is $\sin(x)/x$, where both it and its square integrate to $\pi$.
A: The solutions are actually very general. If $p$ is any PDF bounded above, $M:=\int_{\Bbb R}p^2dx\le\max p$. You can therefore take $f(x):=p(x/M)/M$.
A: Take any function $g$ such that the integrals below are finite:
$$I_1:=\int_{-\infty}^\infty |t|g(t)\,dt,
\\I_2:=\int_{-\infty}^\infty t^2g^2(t)\,dt.$$
Now by the change of variable $t=ax$,
$$I_1:=a^2\int_{-\infty}^\infty |x|g(ax)\,dx,
\\I_2:=a^3\int_{-\infty}^\infty x^2g(ax)^2\,dx$$ and take the value of $a$ that ensures $I_1=I_2$. Finally,
$$f(x)=\frac{|x|g(ax)}{a^2}$$ has the requested property.
This will work among others with $g(t):=e^{-|t|}$ or $g(t):=e^{-t^2}$.
A: We can find a normal distribution with this property, say the one with mean zero and variance $\sigma^2$: $$f(x)=\frac1{\sqrt{2\pi}\,\sigma}\,\exp\frac{-x^2}{2\sigma^2}\quad(x\in\Bbb R).$$Then $f(x)^2=\dfrac1{{2\pi}\sigma^2}\,\exp\dfrac{-x^2}{\sigma^2}$, which may be written $$f(x)^2=\left(\frac1{2\sqrt\pi\,\sigma}\right)\cdot\frac1{\sqrt{2\pi}\,(\sigma/\sqrt2)}\,\exp\frac{-x^2}{2(\sigma/\sqrt2)^2}.$$For this to be a PDF (with variance $\sigma^2/2)$ too, the initial factor must be $1$: namely $\sigma=1/2\sqrt\pi$. Thus$$f(x)=\sqrt2\exp(-2\pi x^2)\quad\text{and}\quad f(x)^2=2\exp(-4\pi x^2)$$are both PDFs (with total integral $1$).
A: Note that $(e^{x^2})^2=e^{2x^2}$, so there is no need to worry about $e^{x^4}$. But even without that, we can use your approach without actually integrating $f(x)^2$.
If $\sigma$ is large enough, all of $f$ is below $1$, so $f(x)^2<f(x)$, and we get $\int f(x)^2dx<1$.
Now for the other side, consider $\int_{-\sigma}^\sigma f(x)dx$. It is known to be about $0.68$. If $\sigma$ is small enough, we get $f(x)>2$ on $x\in[-\sigma,\sigma]$, which gives
$$
\int_{-\infty}^\infty f(x)^2>\int_{-\sigma}^\sigma f(x)^2>\int_{-\sigma}^\sigma 2f(x)>1
$$
