For two investments with returns $X$ and $Y$, we can allocate the cash in proportions $\alpha$ to $X$ and $1-\alpha$ to $Y$, making the total variance of our investment $$\text{Var}(\alpha X+(1-\alpha)Y).$$ In a textbook I'm told that the value of $\alpha$ such that this quantity is minimised (i.e. the value of $\alpha$ to minimise the risk of the distribution of capital) is $$\alpha=\frac{\sigma_Y^2-\sigma_{XY}}{\sigma_X^2+\sigma_Y^2-2\sigma_{XY}},$$ where $\sigma_X^2$ and $\sigma_Y^2$ are the variances of $X$ and $Y$, and $\sigma_{XY}=\text{Cov}(X,Y)$. (This is page 187 of 'An Introduction to Statistical Learning' by Gareth James etc.)
I'm struggling to yield the answer when I try to prove this myself.
My Attempt
I start off by reducing the variance of the expected return to an easily differentiable function:
\begin{align} \text{Var}(R) & = \text{Var}(\alpha X+(1-\alpha) Y) \\ & = \text{Var}(\alpha X)+\text{Var}((1-\alpha)Y)-\text{Cov}(\alpha X,(1-\alpha)Y) \\ & = \alpha^2\text{Var}(X)+(1-\alpha)^2\text{Var}(Y)-\alpha(1-\alpha)\text{Cov}(X,Y) \\ & = \alpha^2\sigma_X^2+(1-\alpha)^2\sigma_Y^2-\alpha(1-\alpha)\sigma_{XY} \\ & = \alpha^2\sigma_X^2+\sigma_Y^2-2\alpha\sigma_Y^2+\alpha^2\sigma_Y^2-\alpha\sigma_{XY} +\alpha^2\sigma_{XY}\\ & = \alpha^2(\sigma_X^2+\sigma_Y^2+\sigma_{XY})-\alpha(2\sigma_Y^2+\sigma_{XY})+\sigma_Y^2 \\ \end{align}
Now we can take the derivative and set it equal to zero to minimise the variance of the return:
\begin{align} \frac{\partial\text{Var}(R)}{\partial \alpha} & = 2\alpha(\sigma_X^2+\sigma_Y^2+\sigma_{XY})-2\sigma_Y^2-\sigma_{XY} \\ 0 & =2\alpha(\sigma_X^2+\sigma_Y^2+\sigma_{XY})-2\sigma_Y^2-\sigma_{XY} \\ \implies \alpha & = \frac{2\sigma_Y^2+\sigma_{XY}}{2(\sigma_X^2+\sigma_Y^2+\sigma_{XY})} \end{align}
My issue
My final result is not the same as the one given in the text. Have I misused some identities for variances and covariances? I don't think I've made any algebraic mistakes - I've gone over it a number of times.
What am I doing wrong here?
$\newcommand{\Var}{\operatorname{Var}}\newcommand{Cov}{\operatorname{Cov}}$The variance was not expanded correctly. Recall that $\Var(X+Y)=\Var(X)+\Var(Y)\color{blue}{+2\Cov(X,Y)}$. Thus $$\Var(\alpha X+(1-\alpha)Y)=\alpha^2\Var(X)+(1-\alpha)^2\Var(Y)\color{blue}{+2\alpha(1-\alpha)\Cov(X,Y)}.$$