I'm asked to give an example of a function that is bounded in $A=[0,1]$ but it doesn't attain its infimum or supremum, i.e. there is no $y\in A$ such that $f(y)=\sup\{f(x)\mid x\in A\}$ and similarly with infimum.
Clearly, since I have compact and connected domain it is necessary that such function must be discontinuous.
I have got an idea, to define $f$ as it follows: \begin{align} f(x)=\begin{cases} \frac{1}{2^{k}}-1 &\text{if }x=\frac{m}{2^{k}},\, 0<m<2^{k},\,m\neq2\ell\\ \frac{1}{3^{k}}+1 &\text{if }x=\frac{m}{3^{k}},\, 0<m<3^{k},\,m\neq3\ell\\ 0 &\text{anywhere else} \end{cases} \end{align}
Again, is clear that this is not continuous since this rationals are dense in $[0,1]$. The infimum and supremum are $-1,1$ respectively.
But my happiness ended when i see that maybe the supremum and infimum are attained since every rational of that form is in $[0,1]$. If this is true what other example of such a function can be constructed. Thanks in advance.
