A continuous function $f:[a,b] \to \mathbb{R}$ that is monotonic on $(a,b)$ is also monotonic on $[a,b]$ Let $f:\left  [ a,b \right ]\rightarrow \mathbb{R} $ be a continuous function all over it's domain.
$f$ is monotonic in $(a,b)$, prove that $f$ is monotonic in $\left  [ a,b \right]$.
The statement is somehow very intuitive but I can't find a way to put a proof to work.
 A: hint
Assume that $f$ is inceasing at $(a,b)$.
Let $c\in(a,b)$.
then, for $n$ great enough,
$$a<a+\frac 1n\le c$$
$$\implies f(a+\frac 1n)\le f(c)$$
$$\implies \lim_{n\to +\infty}f(a+\frac 1n)\le f(c)$$
which gives by continuity at $x=a$,
$$f(a)\le f(c).$$
You do the same with $b-\frac 1n.$
A: You need to show that $f(x) \leq f(y)$ for any $a \leq x < y \leq b$. Take any $\epsilon > 0$ such that $x + \epsilon < y - \epsilon$. Then $x + \epsilon$ and $y - \epsilon$ are in $(a,b)$ so by assumption you have
$$f(y - \epsilon) - f(x +  \epsilon) \geq 0$$
But using continuity of $f$ you can take the limit as $\epsilon \rightarrow 0$ 
to obtain
$$f(y) - f(x) \geq 0$$
This gives $f(x) \leq f(y)$ as needed.
A: $f$ increasing in $(a,b)$, i .e.
for $x, y \in (a,b)$, and $x <y$ :
$ f(x) \le f(y)$
Assume there is a $x \in (a,b)$ s.t.
$f(a) > f(x).$
$f$ continuous in $[a,x]$ . 
Intermediate Value Theorem for continuous functions:
Let $u$ be s.t.
$f(a)>u> f(x)$, then there exists  
$c \in (a,x)$ with $f(c) =u$.
We have $a < c <x$; where $f(c)>f(x),$
a contradiction.
A: Hint / proof outline: Without loss of generality assume $f$ is monotone increasing (the case monotone decreasing is the same). We know that $f$ is monotone increasing on $(a,b)$, so we just want to prove that it is monotone increasing at the points $a$ and $b$. To prove this for the point $a$, we want to show that $f(a) \leq f(x)$ for all $x \in [a,b]$. 
In order to show this, assume $f(a) > f(x)$ for some $x > a$. Using the definition of continuity, find a point $y$ satisfying $a < y < x$ and $f(y) > f(x)$. Why is this a contradiction? 
The fact that $f$ is continuous is what makes this proof work. If $f$ were not continuous, you could set the endpoints $f(a), f(b)$ to be whatever you want. Then $f$ would be monotonic on $(a,b)$ but not $[a,b]$. 
A: Here's a topological argument. No epsilon pushing necessary!
Let $f:[a,b] \to \mathbb{R}$ be a continuous function, which we assume WLOG to be monotone increasing on $(a,b)$.  Since $f\Big( [a,b] \Big)$ is the continuous image of a compact set, it must itself be compact, and in particular bounded (Heine-Borel).  Moreover, the image of $(a,b)$ is contained in the image of $[a,b]$, and because the continuous image of a connected set is connected, we deduce that the image of $(a,b)$ is a bounded, connected subset of $\mathbb{R}$—i.e. it is some interval we'll call $I$.  Note that the hyperlinked fact also tells us that $f(b)$ lies within the closure of $I$.  
So what if monotonicity fails at $x=b$?  In other words, letting $s = \text{sup} \Big\{f(x) \ | \ x \in (a,b) \Big\}$, let's see where problems arise if $f(b) = w < s$.  Consider the preimage of the interval $U = (w- \varepsilon, \ w + \varepsilon)$, where $0 < \varepsilon < |s-w|$.  It would look like $f^{-1}(U) = V \cup \ \{b\}$, where $V$ is such that $\{b\}$ is isolated.  Due to this isolated point, $f^{-1}(U)$ cannot be open.  Because $U$ is an open set and $f^{-1}(U)$ is not, $f$ cannot be continuous*.  Thus, continuity forces $f(b) = s$, just as it does $f(a) = \text{inf} \Big\{ f(x) \ | \ x \in (a,b) \Big\}$ by an analogous argument.

*We are using the topological definition of continuity, which states that a function $f:X \to Y$ between topological spaces is continuous $\iff$ the preimage $f^{-1}(U)$ of every open set $U$ of $Y$ is also open in $X$.  When $X$ and $Y$ are metric spaces, this definition agrees with the analysis definition.
A: Following the  modern convention that "$f$ is increasing on $(a,b)$" means $(a<x<y<b\implies f(x)\le f(y)\,):$
(I).Suppose  $f$ is increasing on $(a,b)$ and (by contradiction) that $f$ is not increasing on $(a,b].$ Then there exists $c\in (a,b)$ with $f(c)>f(b).$ Let $\epsilon= (f(c)-f(b))/2.$ Since $f$ is continuous at $b,$ there exists $\delta \in (0, b-c)$ such that $f(x)<f(b)+\epsilon$ whenever $x\in (b-\delta,b).$ In particular, if $x=b-\delta/2$ then $a<c<x<b$ but $f(x) <f(b)+\epsilon<f(c),$ contrary to $f$ being increasing on $(a,b).$
So $f$ must be increasing on $(a,b].$
(II). If $f$ is decreasing on $(a,b)$  then $(-f)$ is increasing on $(a,b)$ and continuous at $b$, so apply (I) to the function $(-f).$ So $(-f)$ is increasing on $(a,b] ,$ so $f$ is decreasing on $(a,b].$
(III). For $x\in (a,b]$ let  $g(x)=f(b+a-x).$ Then $g$ is monotonic on $(a,b]$ and continuous at $x=b.$ So by (I) and (II), $g$ is monotonic on $(a,b].$ So $f$ is monotonic on $[a,b).$
(IV).$f$ is monotonic on $[a,b)$ and on $(a,b].$ Therefore $f$ is monotonic on $[a,b].$
Remarks. With a small modification to (I) we can show that if $f$ is strictly monotonic on $(a,b)$ then $f$ is strictly monotonic on $[a,b].$
And in either case, observe that it suffices that $f(x)$ is continuous at $x=a$ and $x=b,$ but not necessarily continuous on $(a,b).$
Further remarks. We can prove (I), that is, if $f$ is increasing on $(a,b)$ then $f$ is increasing on $(a,b]$ directly rather than by contradiction,using the basic result that if $(y_n)_{n\in \Bbb N}$ is a convergent real sequence with $ y_n\le y_{n+1} $ for all $n,$ then $\lim_{n\to \infty}y_n\ge y_1.$
We want to show that $\forall x\in (a,b)\,(f(x)\le f(b)\,).$ 
For $x\in (a,b)$ let $(x_n)_{n\in \Bbb N}$ be an increasing sequence of members of $(a,b)$ with $x_1=x$ and $\lim_{n\to \infty}x_n=b.$ Let $y_n=f(x_n)$ for each $n.$ Then $y_n\le y_{n+1}$ for all $n.$ Now since $f$ is continuous at $b$ and $x_n\to b$  we have $$f(b)=f(\lim_{n\to \infty}x_n)=\lim_{n\to \infty}f(x_n)=$$ $$=\lim_{n\to \infty}y_n\ge y_1=f(x_1)=f(x).$$ 
A: Lemma 1: Let $A$ and $B$ be two non-empty subsets of $\mathbb{R}$ satisfying
$\tag 1 A \subset B$
$\tag 2 \forall b\in B \; \;\exists a \in A \text{ such that } b\leq a$
Then $\text{sup}(B) = \text{sup}(A)$.
Lemma 2: Let $A$ and $B$ be two non-empty subsets of $\mathbb{R}$ satisfying
$\tag 3 A \subset B$
$\tag 4 \forall b\in B \; \;\exists a \in A \text{ such that } b\geq a$
Then $\text{inf}(B) = \text{inf}(A)$.
Proposition 3: Let $f:\left  [ a,b \right ]\rightarrow \mathbb{R}$ be monotonically increasing on $(a,b)$ and continuous at $x = a$ and $x = b$. Then
$\tag 5 f(a) = \text{inf}\left(f\text{<}\,(a, b)\,\text{>}\right)$
$\tag 6 f(b) = \text{sup}\left(f\text{<}\,(a, b)\,\text{>}\right)$
Corollary 4: Let $f:\left  [ a,b \right ]\rightarrow \mathbb{R}$ be monotonically increasing on $(a,b)$ and continuous at $x = a$ and $x = b$. If $a \lt x \lt b$ then
$\tag 7 f(a) \le f(x) \le f(b)$ 
and $f$ is monotonically increasing on $[a,b]$.
Lemma 5: The function $f$ is monotonically increasing if and only if $-f$ is monotonically decreasing.
