The mean value property and local maximum

I have an exercise in P.D.E that I couldn't solve.

Let $\Omega \subset \mathbb{R}^n$ be a connected open set and $u:\Omega \to \mathbb{R}$ a continuous function that satisfies the following property:

(1) $\forall x \in \Omega \ \exists a(x) > 0$; $\forall 0 < r < a(x): u(x) =\displaystyle\frac{1}{\omega_n r^{n-1}} \int_{S_r(x)} u(y)d\sigma(y)$

Show that, if $u$ has a local maximum or a local minimum, then $u$ is constant in $\Omega$.

I know how to solve that exercise if $u$ has a global maximum, but I don't know how to change the solution for the case of a local maximum.

Of course I know that functions that satisfies the property (1) are harmonic (real-analytic!) but I can't use that because this exercise is just a step to show that functions that satisfies (1) are harmonic!

PS: I'm sorry for my really bad English. I'm from Brazil and almost never have to write in other language than Portuguese. :)

PS2: It would be good if I show how to solve this exercise for the case of global maximum so you guys can help me to adapt the solution?

EDIT: As @D.Thomine noticed, it is necessary to supose that f is continuous.

-
Argue by contradiction: assume $x$ is a strict local maximum for $u$; then for all $y\in B(x;a(x))$ (here and in what follows $B(x;r):=\{ y\in \mathbb{R}^N:\ |y-x|<r\}$ is the open ball with radius $r>0$ centered in $x$) you get: $$\tag{1} u(x)>u(y)\; ;$$ now, taking the integral mean in both sides of (1) with respect to the $y$ variable, you obtain a contradiction... – Pacciu Dec 7 '11 at 11:33
P.S.: I'm assuming that the set you call $S_r(x)$ is the one I named $B(x;r)$, i.e. the open ball. In such a case, in writing the integral mean you have to integrate with respect to $y$ and not w.r.t. $\sigma (y)$ (which I assume to be a surface measure). On the other hand, if $S_r(x) =\partial B(x;r)$ (i.e. if $S_r(x)$ is a sphere), then in writing the integral mean you have to divide by $N\omega_N\ r^{N-1}=\sigma (S_r(x))$. – Pacciu Dec 7 '11 at 11:39
Thanks. It was usefull, but and for x that is a local maximum, but not a strict local maximum? – Max Reinhol Jahnke Dec 8 '11 at 17:05
As stated, what you want to prove is false. For instance, take the function $f$ on $\mathbb{R}$ such that $f(x) = 0$ if $x<0$, then $f(x) = 1$ if $x>0$, and $f(x) = 1/2$ is $x=0$. I think that something like the continuity of $a$ or $u$ is required. – D. Thomine Jan 7 '12 at 22:49

The following argument works under the assumptions that $u$ is continuous in $\Omega$.

Assume your function $u$ has a local maximum in $x$, i.e. $M:=u(x)\geq u(y)$ for each $y$ in some open neighbourhood $U$ of $x$ contained in $\Omega$.

Let $R_x\leq a(x)$ be the radius of greatest ball centered in $x$ which is contained in $U$; then from the mean value property on balls you get: $$\forall 0<r<R_x,\quad M=\frac{1}{\omega_N\ r^N} \int_{B(x;r)} u(y)\ \text{d} y\; .$$ Equality $M=\frac{1}{\omega_N\ r^N} \int_{B(x;r)} u(y)\ \text{d} y$ holds if and only if $u\equiv M$ in $B(x;r)$: in fact, if by contradiction you assume that there exists $\bar{y} \in B(x;r)$ s.t. $u(\bar{y})<M$, then there exists a nonempty open set $V\subseteq B(x;r)$ s.t.: $$\forall y\in V,\quad u(y)<M\; ;$$ hence: $$M=\frac{1}{\omega_N r^N}\int_{B(x;r)} u(y)\ \text{d} y = \frac{1}{\omega_N r^N}\left( \int_{V} u(y)\ \text{d} y + \int_{B(x;r)\setminus V} u(y)\ \text{d} y\right) <M$$ which is a contradiction! Therefore $u(y)=M$ for all $y\in B(x;r)$ and $r<R_x$, that is $u\equiv M$ in $B(x;R_x)$.

Previous argument proves that the set $\Omega_M:=\{y\in \Omega :\ u(y)=M\}$ is both nonempty (because it contains $B(x;R)$) and open (for, if $y\in \Omega_M$ then one can repeat the previous argument to show that there exists an open ball $B(y;R_y)$ which is contained in $\Omega_M$); on the other hand $\Omega_M$ is relatively closed in $\Omega$, because $u$ is continuous.

Thus you found a subset $\Omega_M$ which is nonempty, open and relatively closed in $\Omega$; but $\Omega$ is connected hence its only nonempty, open and relatively closed subset is $\Omega$ itself, therefore $\Omega_M =\Omega$ and $u\equiv M$ everywhere.

On the other hand, previous proof works also if your function $u$ has the mean value property on spheres, that is if: $$u(x)=\frac{1}{N\omega_N r^{N-1}}\int_{\partial B(x;r)} u(y)\ \text{d} \sigma (y)$$ for all $0<r<a(x)$. In fact, equality $M=\frac{1}{N\omega_N\ r^{N-1}} \int_{\partial B(x;r)} u(y)\ \text{d} \sigma (y)$ holds if and only if $u\equiv M$ in $\partial B(x;r)$, hence $u\equiv M$ in $B(x;R_x)=\{x\}\cup \left(\bigcup_{0<r<R_x} \partial B(x;r)\right)$ and you can conclude the argument as before.

-
I think that your argument only works for a global maximum. That is exacly the proof I know for global maximum, but I couldn't show that $\Omega_M$ is open when assuming x is a local maximum. – Max Reinhol Jahnke Dec 9 '11 at 15:48