There are N agents living in an economy with two goods, $X$ and $Y$. Their preferences are described by the following utility function $u(X,Y) = 2 \sqrt{XY}$. Each agent is endowed with 1 unit of $X$ and $y_{i}$ units of $Y$. Each unit of $Y$ is sells for $p$ units of $X$.
The question is to show that each agent gets a utility of $\frac{1 + py_{i}}{\sqrt p}$.
Here is what I have tried:
The agent chooses $X,Y$ in order to maximise $2\sqrt{XY}$ subject to $X + pY = 1 + p y_{i}$ So I have expressed the resource constraint in units of good $X$. The LHS is what the agent can buy and the RHS is the endowment, also expressed in units of $X$.
I then re-arrange the constraint in terms of $Y$, i.e, $Y = \frac{1}{p} + y_{i} - \frac{X}{p}$ and substitute this in to the utility function, with the FOC with respect to $X$ and then substitute the optimal value of $X$ back in to the utility function to get an expression in terms of $y_{i}$. However, the expression is not what I am supposed to get.
If anyone wants to check my algebra, here it is:
The utility function becomes $2\sqrt {(X/p) + Xy_{i} - X^2/p}$ Differentiating this w.r.t $X$ I find that $X^* = (1/2)(1 + y_{i}p)$. I substitute this in the utility function, $2\sqrt{X^*y_{i}}$ but this does not equal $\frac{1 + py_{i}}{\sqrt p}$.
Any ideas on where I am going wrong?