Find $\mathbb{E}\left[X|Y=\frac{1}{4}\right]$. Let $X,Y$ be random variables with joint density given by
$$f(x,y)=\begin{cases}
                    \frac{3}{8}\left ( x+y^{2} \right ) & \text{ if } 0<x<2,\text{ }0<y<1 \\
                    0 & \text{ otherwise.}
                \end{cases}$$
Find $\mathbb{E}\left[X|Y=\frac{1}{4}\right]$.
$\textbf{My attempt:}$
$$
\begin{align*}
\mathbb{E}\left[X|Y=\frac{1}{4}\right]
&=\int_{0}^{2}xf\left(x,\frac{1}{4}\right)dx\\
&=\frac{3}{8}\int_{0}^{2}x\left(x+\frac{1}{16}\right)dx\\
&=\frac{67}{64}.
\end{align*}$$
Why is this wrong?
 A: Basically, you forgot the definition of $p(x|y)$ and didn't divide by $p(y=\frac14)=\frac{51}{64}$. So the final answer should have been $\frac{67}{51}$.
Instead of $f(x,y)$, I will use the notation
$$
p(x,y)=\frac38 (x+y^2)
\mathbf{1}_{x\in(0,2)}
\mathbf{1}_{y\in (0,1)}.
$$
We have
$$
\begin{align}
p(y)
&=\int_{-\infty}^\infty p(x,y)dx\\
&=\int_{-\infty}^\infty 
\frac38 (x+y^2)
\mathbf{1}_{x\in(0,2)}
\mathbf{1}_{y\in (0,1)}
dx\\
&=\int_0^2 
\frac38 (x+y^2)
dx
\cdot \mathbf{1}_{y\in (0,1)}
\\
&=\frac34 (1+y^2)\mathbf{1}_{y\in (0,1)}\\
&>0.
\end{align}
$$
Recall the definitions $\mathbb{E}(X|Y=y)=\int xp(x|y)dx$, and $p(x,y)=p(x|y)p(y)$. The case where $p(y)>0$ enables us to write $p(x|y)=\frac{p(x,y)}{p(y)}$.
So we calculate $$
\begin{align}
\mathbb{E}\left(X|Y=\frac14\right)
&=\left.\int_{-\infty}^\infty xp(x|y)dx \right|_{y=1/4}\\
&=\left.\int_{-\infty}^\infty x\frac{p(x,y)}{p(y)}dx\right|_{y=1/4}\\
&=\left. \int_{-\infty}^\infty x \cdot \frac{
\frac38 (x+y^2)
\mathbf{1}_{x\in(0,2)}
\mathbf{1}_{y\in (0,1)}
}
{
\frac34 (1+y^2)
\mathbf{1}_{y\in (0,1)}
}
dx
\right|_{y=1/4}\\
&=\int_0^2 x\cdot \frac12 \frac{x+(1/4)^2}{1+(1/4)^2}dx \\
&=\frac{67}{51}.
\end{align}$$
