Find min and max of sum function I need to find min and max of this function:
$$f(x_{1}, x_{2},.....,x_{n}) = \sum_{i=1}^{n} x_{i}^{2}$$, s.t $$\sum_{i=1}^{n} \frac{x_{i}}{a_{i}}= 1, a_{n}>0$$
I used Lagrange method:
$$L = \sum_{i=1}^{n} x_{i}^{2} + \lambda_{1}(\sum_{i=1}^{n} \frac{x_{i}}{a_{i}}- 1)$$
\begin{align*}
  L_{x_{1}}^{'} = 2x_{1} + \frac{\lambda_{1}}{a_{1}} = 0 \\ 
  L_{x_{2}}^{'} = 2x_{2} + \frac{\lambda_{1}}{a_{2}} = 0\\ 
  \cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\cdot\\
  L_{x_{n}}^{'} = 2x_{n} + \frac{\lambda_{1}}{a_{n}} = 0\\
  \sum_{i=1}^{n} \frac{x_{i}}{a_{i}}- 1 = 0
\end{align*}
Solving that system gave me this:
\begin{align*}
  a_{1}x_{1}= a_{2}x_{2}=a_{3}x_{3}=....=a_{n}x_{n} \\ 
  \sum_{i=1}^{n} \frac{x_{i}}{a_{i}}- 1 = 0
\end{align*}
Now i don't know how to find extremums from that. How to solve it? Did i do something wrong here?
 A: With your system, you have for the minimum coordonates :$$x_i=-\frac{\lambda_1}{2a_i}, \ \forall i$$
replace that in $\sum_{i=1}^n \frac{x_i}{a_i}-1=0$ and find the Lagrange coefficient $\lambda_1$ :
$$\lambda_1=\frac{-1}{\sum_{i=1}^n\frac{1}{a_i^2}} $$
Hope this help.
A: Preliminary note: I am going to assume that your $x_i$ values have to be non-negative.  (If they don't, and if $n>1$, then there is no maximum, since you can make the function value as large as you want.)

Finding the maximum: Under this assumed constraint, it is clear from the form of the function that the maximum is acheived by setting one element to the maximum allowable value under the constraint, and all other elements to zero.  Define the index $K$ so that $a_K = \max_i a_i$ (i.e., it is the index of a maximum value).  Then under the above presumed constraint, the maximum of the function occurs when $x_i = a_i \cdot \mathbb{I}(i=K)$, which gives:
$$f(\mathbf{x}) = x_K^2 = a_K^2.$$
Note that this is a boundary point on the constraint set.  (The critical point you get is a minimising point, not a maximising point.)
