Angles of a triangle using least squares and Lagrange multipliers Here's the question exactly.

The three angles of a triangle have been measured independently. Results:
  $$\phi_{1} = 63^\circ, \phi_{2} = 34^\circ , \phi_{3}=85^\circ $$
  all measurements have $\sigma = 1^\circ$. Estimate the improved measurments $\eta_{1},\eta_{2},\eta_{3}$ with the least squares principle applying the constraint that the sum of the three angles should be $180^\circ$ using the method of Lagrange multipliers.

I understand the constraint is $\phi_{1} + \phi_{2} + \phi_{3} - 180 = 0$, but don't know how to get the rest of it into a format to apply the least squares principle, or how to achieve that.
Any help is much appriceated 
 A: Let us call $\Phi_i$ the real value of angle $\phi_i$. So the problem is to minimize $$F=(\Phi_1-\phi_1)^2+(\Phi_2-\phi_2)^2+(\Phi_3-\phi_3)^2$$ subject to the constraint $\Phi_1+\Phi_2+\Phi_3=180$.
Using Lagrange multpliers, you then need to minimize $$G=(\Phi_1-63)^2+(\Phi_2-34)^2+(\Phi_3-85)^2+\lambda(\Phi_1+\Phi_2+\Phi_3-180)$$ Computing the derivatives and setting them equal to zero, we then have $$G'_{\Phi_1}=2(\Phi_1-63)+\lambda=0$$  $$G'_{\Phi_2}=2(\Phi_2-34)+\lambda=0$$  $$G'_{\Phi_3}=2(\Phi_3-85)+\lambda=0$$ $$G'_\lambda=\Phi_1+\Phi_2+\Phi_3-180=0$$ Eliminate the $\Phi$'s from the first three as functions of $\lambda$; plug the result in the last to get $\lambda$ and go back to the $\Phi$'s. Or use matrix calculations since you only face four linear equations for four unknowns.
Solving the general problem as given at the start of this answer, you should get $$\Phi_i=\phi_i+\frac 13 \left(180-\sum_{i=1}^3\phi_i\right)$$
Just for your curioisity, this problem is named data reconciliation.
