Limit of a sequence of a supremum. Problem: Suppose that $f$ is continuous on $[a,b]$ and that $f(a)<f(b)$. Prove that there are numbers $c$ and $d$ with $a\leq c < d \leq b$ such that $f(c)=f(a)$ and $f(d)=f(b)$ and $f(a)<f(x)<f(d)$ for all $x$ in $(c,d)$. 
How do we choose a set? 
I was thinking:
$$A = \{a \le x | f(x) = f(a)   \}$$
$$B = \{x \le b | f(x) = f(b)   \}$$
And consider: $c = \sup A$ and $d = \inf B$
But I am not sure how to use a sequenence or a limit to get that $f(c) = f(a)$ I know it can be done, but how?  I am VERY new to that concept.
 A: Your answer is the right idea, but you need a few more details.
Let $c = \sup \{ t \in [a,b] | f(t) = f(a) \}$, then we have $c <b$ and $f(c) = f(a)$ by continuity. Furthermore, $f(x) > f(a)$ for all $ x > c$.
Now let $d = \inf \{ t \in [c,b] | f(t) = f(b) \}$. We have 
$c < d$ and $f(d) = f(b)$. Furthermore, $f(x) < f(b)$ for all $ c \le x < d$,
and from above we have $f(a)=f(c) < f(x) < f(d)=f(b)$ for all $x \in (c,d)$.
Addendum: To show why $f(c) = f(a)$:
Let $S=\{ t \in [a,b] | f(t) = f(a) \}$ and $c = \sup S \le b$. By definition of $\sup$, for all $\epsilon>0$ we can find some $t \in S$ such that $t > c-\epsilon$. So, let $\epsilon={1\over k}$ and let $t_k \in S$ be such that
$t_k > c-{1 \over k}$. Note that $t_k \le c$, since $c$ is the $\sup$, hence we have
$|c-t_k| < {1 \over k}$. This shows that $t_k \to c$. Since $f$ is continuous, we have $f(c) = \lim_k f(t_k)$, and since $t_k \in S$ we have
$f(t_k) = f(a)$ for all $k$ we have $f(c) = f(a)$.
A: This is another approach which avoids $\sup$ and $\inf$.
As mentioned in my answer there is a last value of $x$ in $[a, b]$ for which $f(x) = f(a)$. This value of $x$ we denote by $c$. Clearly $a \leq c < b$. Also note that if $x > c$ then $f(x) > f(c) = f(a)$ (why?). Similarly there is a first value of $x \in [c, b]$ for which $f(x) = f(b)$. This value of $x$ we call $d$ and $c < d \leq b$. Also we have $f(x) < f(b) = f(d)$ for all $x \in [c, d)$. Thus it follows that we have two points $c, d$ such that $a \leq c < d \leq b$ and $f(a) = f(c) < f(x) < f(d) = f(b)$ for all $x \in (c, d)$.
