Let $X_1,\dots, X_n$ identical independent random variables with $X_i\thicksim N(0,1)$. Prove that $Y=\sum_1^n X_i$ and $Z=\sum_1^n a_iX_i$ are independent iff $\sum_1^n a_i=0$.
I know that
$$E[YZ]=E[( \sum_1^n X_i)( \sum_1^n a_iX_i)]=E( \sum_1^n a_iX_i(\sum_1^nX_i))= \sum_1^n a_i E(X_i(\sum_1^nX_i))$$
Since all the pairs $(X_i,X_j)$ are independent, I can make $E(X_iX_j)=E(X_i)E(X_j)=0$. Using the linearity of $E(\cdot)$, I get:
$$\sum_1^n a_i E(X_i(\sum_1^nX_i))=\sum_1^n a_i E(X_i^2)=\sum_1^n a_i $$
So if $Y$ and $Z$ are independent, then the sum is zero.
For the other side I don't know why the other side of the iff is true, because the fact that $E[XY]=E[X]E[Y]$ is not enought to say it, don't?. It's a property of the normal distributions or something like that?
If $X_1,\ldots,X_n\sim\operatorname{i.i.d. } N(0,1)$ then $\sum_{i=1}^n a_i X_i$ and $\sum_{i=1}^n b_i X_i$ are independent if and only if $\sum_{i=1}^n a_i b_i =0.$ The "only if" part is clear from the fact that the covariance being nonzero entails lack of independence.
The "if" part follows from the invariance of the density under rotations that fix the origin. The joint density is $\text{constant} \times \exp\left( \dfrac{-1} 2 (x_1^2+\cdots+x_n^2) \right).$ You need to show that if $(u_1,\ldots,u_n)$ represents the same point as $(x_1,\ldots,x_n)$ with respect to a different orthonoral basis then the density with respect to that other orthonormal basis is $\text{constant} \times \exp\left( \dfrac{-1} 2 (u_1^2 + \cdots + u_n^2) \right).$ Then choose the basis in such a way that $a_1 x_1 +\cdots+a_n x_n = u_1 \sqrt{a_1^2 + \cdots + a_n^2}$ and $b_1 x_1 + \cdots + b_n x_n = u_2 \sqrt{b_1^2 + \cdots + b_n^2}.$ That is possible only if $a_1 b_1 + \cdots + a_n b_n =0.$