extreme value theorem
Extreme value theorem

The extreme value theorem states that if a real-valued function \[f\] is continuous on the closed and bounded interval \[\left[ a,b \right]\], then \[f\] must attain both a maximum and a minimum at least once.
Mathematically, there must exist a number \[c\] and \[d\] in \[\left[ a,b \right]\] such that \[f(c)\le f(x)\le f(d)\] for all \[x\] in \[\left[ a,b \right]\].
This theorem is more specific than the boundedness theorem, which states that \[f\] is bounded on \[\left[ a,b \right]\] if it is continuous on \[\left[ a,b \right]\], i.e. there exists a real number \[m\] and \[M\] such that \[m\le f(x)\le M\] for all \[x\] in \[\left[ a,b \right]\].
Proof
We will prove the case that \[f\] attains its maximum value on \[\left[ a,b \right]\] by contradiction.
The proof that \[f\] attains its minimum on the same interval is argued similarly.
Since \[f\] is continuous on \[\left[ a,b \right]\], we know it must be bounded on \[\left[ a,b \right]\] by the boundedness theorem.
Suppose the supremum for \[f\] is \[M\].
If there is some \[c\] in \[\left[ a,b \right]\] where \[f(c)=M\] there is nothing more to show, as it is clear that \[f\] attains its maximum on \[\left[ a,b \right]\].
Now, suppose \[c\] doesn't exist. Then it follows that \[f(x)<M\] for all \[x\] in \[\left[ a,b \right]\].
Define a function \[g\] as \[g(x)=\frac{1}{M-f(x)}\]. Since \[M-f(x)\] must be larger than zero, therefore \[g(x)>0\] for every \[x\] in \[\left[ a,b \right]\], and will also be bounded on this interval by the boundedness theorem.
Given that \[g\] is bounded on \[\left[ a,b \right]\], there must exist some \[K>0\] such that \[g(x)\le K\] for every \[x\] in \[\left[ a,b \right]\]. Consequently, for every \[x\] in \[\left[ a,b \right]\], \[\frac{1}{M-f(x)}\le K\implies f(x)\le M-\frac{1}{K}\].
However, since we've established that \[M\] is the supremum, it is impossible for us to find an even smaller upper bound for \[f(x)\]. Thus, we've found our contradiction, which leaves us with the only possibility that there must be some \[c\] in \[\left[ a,b \right]\] where \[f(c)=M\]. In other words, \[f\] attains its maximum on \[\left[ a,b \right]\].
Alternate proof
By the boundedness theorem, \[f\] is continuous on \[\left[ a,b \right]\], so it must be bounded on \[\left[ a,b \right]\]. Hence, by the completeness axiom of real numbers, \[f\] must also have a supremum (\[M\]).
Now, we shall find a point \[c\] in \[\left[ a,b \right]\] such that \[M=f(c)\]. Let \[n\in\mathbb{N}\]. As we've established that \[M\] is the least upper bound, consequently \[M-\frac{1}{n}\] will not be an upper bound for \[f\]. Therefore, there must exist a point in \[\left[ a,b \right]\], call it \[x_{n}\] such that \[f(x_{n})>M-\frac{1}{n}\].
As real numbers are infinitely dense, we can then define an infinite sequence of \[\left( x_{n} \right)\] such that every term in the sequence fulfills the condition \[f(x_{n})>M-\frac{1}{n}\].
Since \[M\] is an upper bound of \[f\], it follows that \[M-\frac{1}{n}< f(x_{n})\le M\] for \[n\in\mathbb{N}\]. As \[n\to\infty\], \[M-\frac{1}{n}\] would approach \[M\], thus the sequence \[\left( f(x_{n}) \right)\] being sandwiched in the middle, would also approach \[M\].
The Bolzano-Weierstrass theorem tells us that there exists a subsequence of the sequence \[\left( x_{n} \right)\], denoted as \[\left( x_{n_{k}} \right)\], which converges to some number, call it \[c\], which also must be between the interval \[\left[ a,b \right]\].
Since \[\left( x_{n_{k}} \right)\] converges to \[c\], then \[\left( f(x_{n_{k}}) \right)\] will converge to \[f(c)\] as \[f\] is continuous at \[c\]. However, \[\left( x_{n_{k}} \right)\] is a subsequence of \[\left( x_{n} \right)\], and as we're established earlier the subsequence \[\left( x_{n} \right)\] converges to \[M\]. Therefore, \[M=f(c)\], and \[f\] attains its supremum \[M\] at \[c\].
The reason why if a sequence converges, then every subsequence converges to the same limit, is that a sequence converges to a limit \[L\] (in our case \[c\]) provided that, eventually, the entire tail of the sequence is very close to \[L\]. If you restrict your view to a subset of that tail, it will also be very close to \[L\].
The general idea of this proof is that we know that there are some points in \[f(x)\], as we called it \[f(x_{n})\], will get very close to \[M\]. However, we aren't actually sure if there is a point that is equal to \[M\]. That's when we utilise Bolzano-Weierstrass' theorem to confirm that there is definitely a \[c\] where \[f(c)\] must be \[M\] due to as a consequence of \[f\] being continuous at \[c\].