Show the image of a continuous function on a closed interval is closed. 
I tried this problem on my own, but got 1 out of 5. Now we are supposed to find someone to help us. Here is what I did:
Let $f:[a,b] \rightarrow \mathbb{R}$ be continuous on a closed interval $I$ with $a,b \in I$, $a \leq b$
If $f(a), f(b) \in f(I)$ let $f(a)\leq y \leq f(b)$. Then by IVT there exists $x$, $a\leq x \leq b$ where $f(x)=y$ $Rightarrow$ The image is also an interval. 
Show closed: Let m be the lowest upper bound and M the greatest lower bound of the image interval. $I=[a,b]$ must be a subset of $[M,m]$ and the function attains its bounds, 
$m,M\in f(I)$. so $f(I)$ is a subset of $[M,m]$, thus is closed. 
Can anyone provide a proof of this statement? Thanks!
 A: Closed intervals are compact in $ \mathbb{R}$. $f$ continuous implies image of $f$ is compact. By Heine-Borel, we know that compact sets are closed and bounded in $\mathbb{R}$, in particular.
Since a closed set contains its sup and inf use that to show that they form the end points of the interval and use the IVP to conclude that it is a closed interval.
A: Hint: Extreme value theorem will yield nice results
More to the point: Consider $[f(x_{min}),f(x_{max})]$
A comment on your attempt:
All you've shown is that there is a closed interval contained in $f(I)$ so it doesn't really get at the heart of the problem. 
Your second part is closer, but you'll see things more clearly without all the renaming of things. What is $M$? you actually know more about it than you are letting on. For example: "the function attains its bounds"...how do you know that?
now the question is: why is this an interval?
A: (1).... Let $J=[a,b]$ with $a\leq b.$ Any sequence $(x_n)_{n\in N}$  of members of $J$ has a convergent subsequence. That is, there is a strictly increasing $g:N\to N$ such that $(x_{g(n)})_{n\in N}$ is a convergent sequence.
Proof: Let $J_1=[a,(a+b)/2]$ if $\{n: x_n\in [a,(a+b)/2]\}$ is an infinite set, otherwise let $J_1=[(a+b)/2,b].$ Recursively,when $J_n=[a_n,b_n],$ let $J_{n+1}=[a_n,(a_n+b_n)/2]$ if $\{n:x_n\in [a_n,(a_n+b_n)/2\}$ is infinite, otherwise let $J_{n+1}=[(a_n+b_n)/2,b_n].$
Now for every $n\in N$ the set $\{n:x_n\in J_n\}$ is infinite, and $J_{n+1}\subset J_n,$ and $b_n-a_n=2^{1-n}(b-a).$
Let $g(1)$ be the least (or any) $m$ such that $x_m\in J_1.$ Recursively, let $g(n+1)$ be the least (or any) $m$ such that $m>g(n)$ and $x_m\in J_{n+1}.$
Then $(x_{g(n)})_{n\in N}$ is a Cauchy sequence because $J_{n+1}\subset J_n\implies \{x_{g(n+1)},x_{g(n)}\}\subset J_n$  $\implies |x_{g(n+1)}-x_{g(n)}|\leq b_n-a_n=2^{1-n}(b-a)$ (which is sufficient to imply the Cauchy condition ). Of course a Cauchy sequence in $[a,b]$ converges to a member of $[a,b].$
(2).... A continuous $f:[a,b]\to R$ is bounded. Proof: (By contradiction).If not, let $x_n\in [a,b]$ with $|f(x_n)|>n$. By (1),let $(x_{g(n)})_{n\in N}$ be a convergent subsequence of $(x_n)_{n\in N}$ with limit point $x\in [a,b].$ Continuity of $f$ requires that $f(x_{g(n)})\to f(x)$ as $n\to \infty.$ But $|f(x_{g(n})|>|g(n)|=g(n)\geq n,$ so $(f(x_{g(n)})_{n\in N}$ is not a convergent sequence, a contradiction.
(3).... A continuous $f :[a,b]\to R$ attains it maximum and minimum. Proof: By (2),   $M=\sup \{f(x):x\in [a,b]\}<\infty.$ Let $x_n\in [a,b]$ with $M\geq f(x_n)\geq M-2^{-n}.$ By  (1) let $(x_{g(n)})_{n\in N}$ be convergent to $x^*\in [a,b].$ Continuity of $f$ implies $f(x^*)=\lim_{n\to \infty}f(x_{g(n)})=M.$ Obtaining $y^*\in [a,b]$ with $f(y^*)=m=\inf \{f(x):x\in [a,b]\}$ is done similarly.
(4)...By IVT, with $x^*$ and $y^*$ as in (3) we have $$\{f(x):x\in [a,b]\}\supset [f(y^*),f(x^*)]=[m,M].$$ By def'n of $ m$ and $M$ we have $$\{f(x):x\in [a,b]\}\subset [m,M].$$
A: Another way of showing "closed", because it's useful to be able to switch between the various definitions of these concepts: recall that continuous functions preserve the convergence of sequences, and that a closed set is precisely one which contains all its limit points.
Let $[f(c_i)]$ be a sequence in $f([a,b])$, and suppose it tends to $y \in \mathbb{R}$. Then the $c_i$ are elements of the closed bounded interval $[a,b]$, so they have a convergent subsequence $c_{n_i}$, say; by closure of $[a,b]$, the limit $x$ of the $c_{n_i}$ lies in $[a,b]$.
Now since $c_{n_i} \to x$, have $f(c_{n_i}) \to f(x)$ by continuity of $f$, so the limit of $[f(c_{n_i})]$ lies in $f([a,b])$.
Finally, since $[f(c_{n_i})]$ is a subsequence of the convergent-by-assumption $[f(c_i)]$, it converges to the same limit; so $f(x) = y$.
This proves that $f([a,b])$ contains all its limit points.
The extreme value theorem tells you that $f([a,b])$ is bounded; it can also be used to prove that it's closed (which I did above in a more roundabout way). I'm sure there's a way to show "bounded" without that, but I haven't given any thought to that.
That $f([a,b])$ is an interval follows in one line from a certain very important theorem from any first course in real analysis.
