Prove the solution $u_i$ of equation $\lambda r_i+\frac{1}{\theta}(u_i-v_i)+\beta \left (\sum_{i=1}^Nu_i-1\right )$ I have an cost function such as
$$E(U)=\lambda \sum_{i=1}^{N} \int_{\Omega}r_iu_idx+\frac{1}{2\theta}\sum_{i=1}^{N} \int_{\Omega}(v_i-u_i)^2dx+ \frac{\beta}{2} \int_{\Omega}\left ( \sum_{i=1}^Nu_i-1\right )^2dx$$
subject to $0 \le u_i(x) \le 1$ for $i=1, ..., N$
The optimal condition is
$$\frac {\partial E}{\partial u_i}=\lambda r_i+\frac{1}{\theta}(u_i-v_i)+\beta  \left (\sum_{i=1}^Nu_i-1\right )=0$$
Now, from the above equation, I want to find the solution of $u_i$. Could you help me to prove that solution of $u_i$ will be
$$u_i=v_i-\lambda \theta r_i - \frac {\beta \theta \left (\sum_{j=1}^N(v_j-\lambda \theta r_j)-1\right )}{1+N\beta \theta}$$
Because I have no idea why has it term $v_j-\lambda \theta r_j$ in the sum.
 A: This is one method to obtain solution to system of linear equations $$\frac {\partial E}{\partial u_i}=\lambda r_i+\frac{1}{\theta}\left(u_i-v_i \right)+\beta  \left (\sum_{j=1}^Nu_j-1\right )=0 $$
for all $i \in \{1, 2, ..., N\}$
Let $$t = \sum_{j = 1}^{N}u_j$$
We have
$$\lambda r_i+\frac{1}{\theta}(u_i-v_i)+\beta t-\beta=0$$
Assuming $\theta \not = 0$ we get
$$u_i =  \beta\theta - \beta\theta t + v_i  - \lambda \theta r_i $$
So 
$$t = \sum_{j = 1}^{N}u_j = N\beta\theta  - N\beta\theta t + \sum_{j = 1}^{N}v_j  - \lambda \theta r_j  $$
Assuming $1 + N \beta \theta \not = 0$ we get
$$t = \frac{ N\theta \beta + \sum_{j = 1}^{N}\left(v_j  - \lambda \theta r_j\right)}{1 + N \beta \theta}$$
Finally we have $$u_i =  v_i  - \lambda \theta r_i + \theta \beta -  \frac{\theta\beta\left( N\theta \beta + \sum_{j = 1}^{N} \left(v_j  - \lambda \theta r_j\right) \right)}{1 + N \beta \theta} $$
$$ =  v_i  - \lambda \theta r_i -  \frac{\theta \beta \left( \sum_{j = 1}^{N} \left(v_j  - \lambda \theta r_j\right) - 1 \right)}{1 + N \beta \theta}$$
