Show the subset $A$ of $\mathbb{R}^n$ is compact 
Show the subset $$A = \{(x_1, . . . , x_n) ∈ \mathbb{R}^n| −1 ≤ x_1 ≤ x_2 ≤ · · · ≤ x_n ≤ 1\} \subset \mathbb{R}^n $$ is compact, and show the function 
  $$\left\{\begin{array}{}f : A → \mathbb{R}\\
 f(x_1, . . . , x_n) = \sum_{i=1}^n x_i \cos x_i\end{array}\right.$$
  attains its maximum and minimum values.

For the first part, all I can come up with is that the subset $A$ appears to define a closed square in $\mathbb{R} ^2$, ( unsure how to phrase this generally for $\mathbb{R} ^n$) with side length 2, centred on the origin. This implies its closed and bounded, and hence compact. But I'm unsure how to formally go about this.
 A: Let $\{a_i\}$ be a sequence in $A$ which converges in $\mathbb{R}^n$. Let $a$ be the limit of this sequence. If we can show that $a \in A$, then we have shown that $A$ is closed (in fact sequentially closed, but this is enough as we are in a metric space). Letting $a_i = (a_i^1, \dots, a_i^n)$ and $a = (a^1, \dots, a^n)$, as $a_i \to a$, we know that $a_i^j \to a^j$ for $j = 1, \dots, n$. As $a_i \in A$, we have $$-1 \leq a_i^1 \leq \dots \leq a_i^n \leq 1$$ for each $i$. Now take the limit as $i \to \infty$ and use the fact that if $x_i \leq y_i$ for all $i$, then $\lim\limits_{i\to\infty}x_i \leq\lim\limits_{i\to\infty}y_i$. This will allow you to conclude that $A$ is closed.
As $A$ is contained in the cube $[-1,1]^n$, $A$ is bounded. Therefore, by the Heine-Borel Theorem, $A$ is compact. The second part of your question has been answered in the comments.
A: The set $A$ is compact in $\mathbb{R}^n$ since it is closed and bounded. It is bounded since it is contained in the ball $B[0,\sqrt{n}].$ Indeed: $$ \sum_{i=1}^n x_i^2\le \sum_{i=1}^n1=n \implies (x_1,\cdots,x_n)\in B[0,\sqrt{n}].$$ To show that it is closed we will show that its complement is open. Let $(x_1,\cdots,x_n)\in A^c.$ By definition of $A$ it is $x_{i+1}<x_i$ for some $i.$ Let's denote $2r=x_{i}-x_{i+1}>0.$ Then, $(x_1-r,x_1+r)\times \cdots (x_n-r,x_n+r)\subset A^c.$ Assume that $(y_1,\cdots,y_n)\in(x_1-r,x_1+r)\times \cdots (x_n-r,x_n+r)\cap A.$ Then,
$$y_{i+1}<x_{i+1}+r=x_i-r<y_i,$$ which gives us a contradiction. So, $A^c$ is open, and thus $A$ is closed.
With respect to the second question, you are asked to show that the function attains its maximum and minimum, not to find their values. But a continuous function on a compact set attains its maximum and minimum at some points on the set.
A: Let $\big(x^i_1,\cdots,x^i_n\big)_{i\in\mathbb{N}}$ be a sequence of members  $A$ which converges to $(l_1,\cdots,l_n)$. It's equivalent to this fact that for each $j$, we have : $x^i_j\rightarrow l_j$, as $i$ tends to $\infty$.
Obviously, for each $j$ we have : $-1\le l_j\le1$ .
So It's sufficient to prove $l_1\le l_2\le \cdots\le l_n$. And this is also clear as follows :
$$\forall j\:: x^i_j\le x^i_{j+1} \iff x^i_j - x^i_{j+1} \le0 \Longrightarrow l_j-l_{j+1}\le0 \iff l_j\le l_{j+1}$$
Therefore, $A$ is bounded and closed and equivalently compact.
A: Clearly $A$ is bounded. Let $g : \mathbb{R}^n \to \mathbb{R}^{n+1}$ be given by
$$g(x_1, \ldots, x_n) = (x_1, x_2 - x_1, x_3 - x_2, \ldots, x_n - x_{n-1}, x_n)$$
Then $g$ is continuous, so the inverse image of the closed set
$$[-1,1] \times [0,2] \times [0,2] \times \cdots \times [0,2] \times [-1,1]$$
is closed. But this is just $A$. We have shown that $A$ is a closed and bounded subset of $\mathbb{R}^n$, which means it's compact.
