Essential Supremum with the continuous function? I have a problem when I read about the Essential Supremum of a measurable function. 
Let $f: E\longrightarrow \mathbb{R}$ is a measurable function respect $E$ is Lebesuge measurable set and the Lebesgue measure. Let
$$ \operatorname{ess sup} f = \inf\{z: f\leq z\;\text{almost everywhere}\}$$
We always have $\operatorname{ess sup} f \leq \sup f$, but when $f$ is continuous, why $\operatorname{ess sup} f = \sup f$?
I assume that $\operatorname{ess sup} f < \sup f = \alpha < \infty$, then exist $z$ such that $f\leq z$ almost everywhere and $z < \sup f = \alpha$, then the set $A = \{x\in E: f(x) > z\}$ is a null set, so the set $B = \{x\in E: \alpha > f(x) > z\}$ is also a null set, but $B = f^{-1}\big((z,\alpha)\big)$ is an open set in $E$. But since a set $B$ is open in $E$ if and only if exist an open set $V \subset \mathbb{R}$ such that 
$$ B = V\cap E$$
Now, I can't find any contradiction?, for exmaple, if $E = \mathbb{R}$ then I have a contradiction since $B$ is open and not empty which can't be a null set. But if $E$ is a null set of $\mathbb{R}$, why is contradiction?
 A: Yes, you're right, the equality
$$\operatorname{ess sup}\limits_E f = \sup_E f\tag{1}$$
does not hold for continuous functions on all (Lebesgue) measurable subsets $E \subset \mathbb{R}^n$. If $E$ is a nonempty null set, we have $\operatorname{ess sup}\limits_E f = -\infty < \sup\limits_E f$, and we can construct counterexamples to $(1)$ whenever $E$ contains a point $e$ such that $\mu(E\cap V) = 0$ for some neighbourhood $V$ of $e$. But if $E$ is such that $\mu(E\cap U) > 0$ for every open set $U$ intersecting $E$, then $(1)$ holds.
A: It is done under the assumption that $E$ is open. (More generally, under the assumption that, for every $x_0\in E$, and every $\delta>0$, we have that $m\big(E\cap(x_0-\delta,x_0+\delta)\big)>0$.)
It suffices to show that if $f:E\to\mathbb R$ continuous and upper bounded, then $\mathrm{ess\,sup}\, f\ge \mathrm{sup}\,f$. Or equivalently, if $a<\mathrm{sup}\, f$, then $a<\mathrm{ess\,sup}\, f$. 
In not, there would an $a$ such that $a<\mathrm{sup}\, f$ and $a\ge\mathrm{ess\,sup}\, f$. Then there exists $x_0\in E$, such that $a<f(x_0)\le\sup f$. Let $\varepsilon=(a-f(x_0))/2>0$. Since $f$ is continuous, there is a $\delta>0$, such that $f(x)>a+\varepsilon$, for every $x\in E\cap(x_0-\delta,x_0+\delta)$. But this would imply that $\mathrm{ess\,sup}\, f\ge a+\varepsilon$. Which is a contradiction.
A: I think you've already solved the problem. Following your proof, think about the case where E=Q (endowed with the subspace topology of R) and f is the identity mapping,then f is continuous and esssupf=-∞, supf=+∞.
