Artificial intelligent assistant

Example of a function on $[0,2]$ with no maximum of minimum Can anybody help me by providing an example of a function (or the graph of such a function) defined on $[0, 2]$ but with no maximum and no minimum? An explanation is also appreciated. ### Context Such a function will have to be discontinuous, because we have a theorem that says a continuous function on a closed interval must attain its maximum and minimum. Also, it cannot be monotone, because monotone functions attain max/min values at the endpoints.

Let $f(x)=x$ if $0\lt x\lt 2$, and $f(0)=f(2)=1$.

This function is not continuous on $]0,2]$. That is unavoidable, since a function continuous on a closed interval $[a,b]$ attains a maximum and a minimum on that interval.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 763f70de86917ecc9eb9ac95299df3bc