Let $f:[a,b]\rightarrow \mathbb{R}$ a convex function. Does $f$ have a maximum in $[a,b]$?.
I have thought that if $f$ is not continous at $x=a$ or $x=b$ then I can find a counterexample for which it does not exist a global maximum. The same thing for minimum. Is it right?
If $f$ is convex, then it is continuous (and therefore upper semicontinuous) on $(a,b)$.
I claim that $f$ is upper semicontinuous at $a$ and $b$. If $x \to a$ from the right, we can write $x = \lambda a + (1-\lambda) b$, then by convexity $$f(x) \leq \lambda f(a) + (1-\lambda) f(b),$$ and therefore $$\limsup_{x \to a} f(x) \leq \limsup_{\lambda \to 1}(\lambda f(a) + (1-\lambda) f(b)) = f(a).$$ A similar argument works for $x \to b$ from the left.
Since $f$ is upper semicontinuous on the compact set $[a,b]$, it attains a maximum. (Intuitively, the idea here is that if $f$ is discontinuous at an end point, the discontinuity must be an "upward jump" in order to preserve convexity.)
But $f$ need not attain a minimum. For example, consider $$f(x) = \begin{cases} (x-b)^2, \ \ x \in [a,b)\\ 1, \ \ x=b. \end{cases}$$