I'm a freshman in college with no prior experience in non linear optimization. This is a question I encountered in an MCQ format.
Problem
$\ x_i \epsilon Z $
$\ i = {1,2,3,4,5} $
$\sum_{i=1}^5 x_i = 10$
$\sum_{i=1}^5 x_i^2 = 40$
Find the maximum and minimum value that $\ x_i $ can take.
Attempt
I replaced $x_i$ with $k_i + m$ and found
$\ M = \sum_{i=1}^5 k_i = 10-5m$
$\ P = \sum_{i=1}^5 k_i^2 = 40 + 5m^2 - 20m$
Solving $M^2=P$ yielded $m = 1,3$ which generated the solution set
{1,1,1,1,6}
{3,3,3,3,-2}
indicating that 6 and -2 were the required values, however I'm clueless as to why the math worked out in this manner.
Queries
I'd like to know why $M^2=P$ yielded the critical condition, how many solution sets there are to this problem, as well as a general approach to such questions.
This is my first post on this forum, thank you in advance.
An Interpretation
If you applied the technique of Lagrange multipliers, then you would know that, at an optimal point $\left(x_1,x_2,x_3,x_4,x_5\right)=\left(y_1,y_2,y_3,y_4,y_5\right)$, it must hold that $y_1=y_2=y_3=y_4$. Then, you can set $m$ to be the common value of $y_1,y_2,y_3,y_4$. Write $y_5=m+t$. Then, you have $$t=\sum_{i=1}^5\,\left(y_i-m\right)=\sum_{i=1}^5\,y_i -5m=10-5m$$ and $$t^2=\sum_{i=1}^5\,\left(y_i-m\right)^2=\sum_{i=1}^5\,y_i^2-2m\,\sum_{i=1}^5\,y_i+5m^2=40-20m+5m^2\,.$$ Therefore, $$40-20m+5m^2=t^2=(10-5m)^2\,.$$