Let $A$ be a non-empty closed subset of $\mathbb{R}^2$, $f : A \to \mathbb{R}$ continuous. Show that $f$ has a maximum in $A$. 
Let $A$ be a non-empty closed subset of $\mathbb{R}^2$, $f : A \to \mathbb{R}$ continuous and $0 \le f(x,y) \le \frac{1}{1+2x^2+3y^2}$ for all $(x,y) \in A$. Show that $f$ has a maximum in $A$.

In order to show that $f$ has a maximum I need to show that $A$ is compact? $A$ is closed by the problem statement so I need to show that it's bounded? I know that $f(x,y)$ is bounded since the denominator of $\frac{1}{1+2x^2+3y^2}$ will tend to $0$ as $x,y$ get large. So $f(x,y) \in [0, 1]$. This doesn't tell me however anything about the boundedness of $A$. What can I do here?
 A: $A$ need not be compact, so you can't use that theorem, you're right. The bound $0 \leq f(x,y) \leq 1$ also holds for all $x,y$, as you deduce.
But think of this : after a certain radius, you know that $f$ is really, really small because of the bound. If you stay within that radius, then you are very much within a compact set.
To use this more precisely, note that the supremum of $f$ on $A$, $L = \sup_{x \in A} f(x)$, exists and is finite (indeed, at most $1$). This is because $f$ is bounded.
We dispose off the case $L=0$, where we must have $f=0$ as a function and therefore $f$ has a maximum everywhere! Let's assume $L>0$ from now on.
Now, pick $x,y$ such that $\frac{1}{1+2x^2+3y^2} < \frac{L}{2}$. Then, for any such $x,y$ we have $f(x,y) < \frac L2< L$ as well.
It follows, that :
$$
\sup_{x \in A} f(x) = \sup_{x \in B} f(x)
$$
where $B = A \cap \{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\}$.
Now, all you need to show is that $B$ is closed and bounded (SHOWN LATER). Then, $f$ is continuous on $B$, and therefore $f$ will have a maximum on $B$. That same maximum will , because of what we wrote earlier also be a maximum on $A$. Done!
Key idea : Truncation of the domain into two parts , one which is bounded and one which is unbounded, but where you know $f$ behaves nicely. This kind of argument is commonly used and worth remembering.

Aim : To show that $B$ is closed and bounded.
To show that $B$ is bounded, it's enough to show that $\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\}$ is bounded, since $B$ is a subset of this.
We write :
$$
\left\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\right\} = \left\{(x,y) : 1+2x^2+3y^2 \leq \frac 2L\right\}
$$
Recall that $\|(x,y)\|^2 = x^2+y^2$, so we note that if $\|(x,y)\| > \sqrt{\frac{1}{L} - \frac 12}$, then :
$$
1+2x^2+3y^2 \geq 1+2x^2+2y^2 \geq 1+2\|(x,y)\|^2 > 1+ 2\left(\frac 1L - \frac 12\right) = \frac 2L
$$
which proves that $$\left\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\right\} \subset \left\{(x,y) : \|(x,y)\| \leq \sqrt{\frac{1}{L} - \frac 12}\right\}$$ i.e. that $\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\}$ is bounded. Hence $B$ is bounded.
To show that $B$ is closed, we must use the fact that the preimage of a continuous function is closed, and that the intersection of closed sets is closed.
So, $A$ is closed. It's enough to prove that $\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\}$ is closed. But then, it's clear that if $g(x,y) = \frac{1}{1+2x^2+3y^2}$, then $g(x,y)$ is continuous and :
$$
\left\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\right\} = \left\{(x,y) : g(x,y) \in \left[\frac{L}{2} , \infty\right)\right\}
$$
is the preimage of the closed set $\left[\frac L2,\infty\right)$ under the continuous map $g$. Therefore, $A \cap \left\{(x,y) : \frac{1}{1+2x^2+3y^2} \geq \frac L2\right\}$ is closed i.e. $B$ is closed.
A: First, assume that $f(0) \neq 0$ (We'll tackle the $0$ case later). Then $f(0) = a > 0 $ Now for large enough $x,y$, we know that $f$ will take values which are less than $a$. Say that this happens whenever $||(x,y)|| > d$. Then to find the maximum of $f$, it suffices to find the maximum of $f$ restricted to the set $K = A \cap \{(x,y :|| (x,y)|| \leq d) \}$. Since $K$ is compact, we have that the maximum does in fact exist!
When $f(0) = 0$, we note that if the function in non-constant, then there is some $p$ for which $f$ takes positive value. From there we repeat the argument.
