# Existence of maximum value of a discontinuous function

If $f(x)$ takes a finite real value for all $x$ on the closed interval $[a,b]$, must there be a real number $M$ such that $M\geq f(x)$ for all $x$ on this interval? It seems that if not, there must be a point $c\in[a,b]$ such that $\lim_{x\to c}f(x)=+\infty$, and so $f(x)$ must be undefined at some point on this interval, but I don't know how to make this rigorous.

Edit: I see that $f(0)=0$, $f(x)=1/x$ on $(0,1]$ is a counterexample. I also see that I have been imprecise with terminology. Let me modify the question: Is there always a sub-interval $[a',b']$ with $a<a'<b'<b$ such that there is an upper bound for $f(x)$ on this sub-interval?

-
Your title is different from the question in the post: $M\ge f(x)$ does not mean that $M$ is maximum, it is an upper bound. In the other words, if such $M$ does not exist, $f$ is not bounded from above. –  Martin Sleziak Nov 2 '12 at 15:44
If $f$ is continuous, then it must be bounded, see ProofWiki. It seems that in your post you use the assumption $f(c)=\lim\limits_{x\to c}f(x)$, which is an equivalent condition for continuity of a function $f \colon \mathbb R \to \mathbb R$. –  Martin Sleziak Nov 2 '12 at 15:46

How about: $f(x)$ on $[0, 1]$ where $f(0) = 0$ and, for all other points, $f(x) = 1/x$.

Edit: Since you added an extra part to your question, you could use the following function:

$f(x) = x$ if $x$ is irrational;

$f(x) = n$ if $x$ is rational in lowest terms, where $n:=$ highest power of $2$ dividing $x$'s denominator.

-

Is there always a sub-interval $[a',b']$ with $a<a'<b'<b$ such that there is an upper bound for $f(x)$ on this sub-interval?
See Function with range equal to whole reals on every open set at MO. Many functions from this question work too: Can we construct a function $f:\mathbb R\to \mathbb R$ such that it has intermediate value property and discontinuous everywhere?. Discontinuous solutions of Cauchy functional equation have this property, see e.g. here.
To give a very simple example, we define $f \colon [0,1] \to \mathbb R$ by $$f(x)= \begin{cases} 0; & x\notin\mathbb{Q},\\ q; & x=\frac{p}{q}; \gcd(p,q)=1; p\ne 0,\\ 1; & x=0. \end{cases}$$ (We took reciprocals of non-zero values of Thomae's function.)
For each prime number $q$ if you take interval of length greater then $\frac2q$ then this interval will contain an $x$ such that $f(x)=q$.