Let $X,Y$ be random variables and $(X,Y)$ is uniformly distributed over the unit disk. Find the density function $f_X$.
Well, it is given that $f(x,y) = \frac{1}{\pi}$ if $(x,y) \in S^1$ and $0$ elsewhere.
Hence, $$f_X(x) = \int_{-\infty}^{+\infty}f(x,y)dy = \int_{-1}^1 \pi^{-1}dy = 2 \pi^{-1}$$ for $x \in [-1,1]$ and $0$ elsewhere.
But, this seems wrong, as it isn't a density function. Where is my mistake?
You seems to have misused the $f$. For each $x\in\left[-1,1\right]$, $$ f(x,y)=\frac{1}{\pi}\cdot\mathbb{1}_{\left[-\sqrt{1-x^2},\sqrt{1-x^2}\right]}(y). $$ Therefore, $$ f_X(x)=\int_{\mathbb{R}}\frac{1}{\pi}\cdot\mathbb{1}_{\left[-\sqrt{1-x^2},\sqrt{1-x^2}\right]}(y){\rm d}y=\frac{1}{\pi}\int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}}{\rm d}y=\frac{2}{\pi}\sqrt{1-x^2}. $$