Let $Y_i$ be uncorrelated and $E(Y_i)=\beta x_i$ and $\mathrm{var}Y_i=\sigma^2$
Let $\hat\beta=\sum_ia_iY_i$ with $a_1,..a_n$ constants.
Use Lagrange multipliers to find $a_1,...,a_n$ that minimize $\mathrm{var} \hat\beta$ with the constraint that $\sum a_ix_i=1$
I managed to do this in matrix form, but the question wants to do it using summs.
For matrix, I did:
$\mathrm{var}\hat\beta=\sum (a_i)^2 \mathrm{var}Y$, hence I need to minimize:
$$\sum(a_i)^2-\lambda (\sum a_ix_i -1)$$ Putting in matrix form, $a^Ta-\lambda(a^Tx-1)$ Differentiating w.r.t. $a_i$ (Can I even do it? $a_i$ are constants):
$2a^T-\lambda(x^T)=0$ and using the constraint $a^Tx=1$, we have: $$a^Tx=\lambda(x^Tx)/2=1\Rightarrow \lambda=2(x^Tx)^{-1}$$
Thus we need $a^T=(x^Tx)^{-1}x^T$
But when I do it using summ which the question asks:
$\sum (a_i)^2-\lambda\sum(a_ix_i-1)=0$ Differentiating:
$\sum 2(a_i)-\lambda\sum x_i$ But now I can't use the consraint $\sum a_ix_i=1$ since $\sum (a_i)=\frac{1}{2}\lambda\sum x_i$ and I can't put $x_i$ directly into the sum. In other words,
$$\sum x_ia_i\ne \frac{1}{2}\lambda\sum (x_i)^2$$
Yes, you can differentiate the expression $$\sum (a_i)^2-\lambda(\sum a_ix_i-1)\tag1$$ with respect to each of the $a_k$. But remember that when you do a partial derivative wrt one of these $a_k$, then the other $a$'s are considered constant. Try writing out each of the sums in expression (1) as an explicit sum of $n$ terms. When you take the partial derivative of (1) wrt $a_1$ the answer will be $2a_1 -\lambda x_1$, because the terms that don't involve $a_1$ will drop out. In general the partial derivative of (1) wrt $a_k$ is $2a_k-\lambda x_k$. Setting these to zero, you get $a_k=\frac\lambda2 x_k$ for each $k$. Using the constraint $\sum a_ix_i=1$ gets you $\frac\lambda2\sum x_i^2=1$, so that $$a_k=\frac{x_k}{\sum x_i^2},$$ as expected.