Let $X,Y$ be random variables with joint pdf $$f(x,y)=\frac{1}{8}\cdot e^{-y}\cdot(y^2-x^2)\cdot I_{\{\;|x|\;\leq \;y\;, \;y>0\}}$$ Find $E[X]$.
I found that the marginal density of $X$ is $$f_X(x)=\frac{1}{4}e^{-|x|}(1+|x|)\cdot I_{\{x\;\in\;\mathbb{R}\}}$$ $$=\begin{cases} \frac{1}{4}e^{-x}(1+x) & x\geq 0 \\ \frac{1}{4}e^{x}(1-x) & x< 0 \\ \end{cases} $$ Assuming I've defined my domain correctly, we should then have that $$E[X]=\int_{\mathbb{R}} xf(x)dx$$ $$=\int_{\mathbb{R^-}} \frac{1}{4}e^{x}\cdot x(1-x)$$ $$E[X]=\int_{\mathbb{R}} xf(x)dx$$ $$= \int_{\mathbb{R^\textbf{_}}} \frac{1}{4}e^{x}\cdot x(1-x)dx +\int_{\mathbb{R^\textbf{+}}}\frac{1}{4}e^{-x}(1+x)dx = 1$$ $$\implies E[X]=1$$
But apparently the answer is $0$ (maybe the textbook is wrong?). Did I represent my piecewise function incorrectly?
The text book is correct. The marginal density of $X$ is indeed $$ f_X(x)=\int_{-\infty}^{+\infty}f(x,y)dy=\begin{cases} \frac{1}{4}e^{-x}(1+x) & x\geq 0 \\ \frac{1}{4}e^{x}(1-x) & x< 0, \\ \end{cases} $$ giving
Apparently, your mistake comes from your computation of $\displaystyle\int_{\mathbb{R^-}} \frac{1}{4}e^{x}\cdot x(1-x)dx$.