# Is supremum over a compact domain of separately continuous function continuous?

Let $(X,d_X)$ and $(Y,d_Y)$ be metric spaces, and consider the product metric space $(X\times Y,d)$ with a product metric $d$.

Let $f(x,y):X\times Y\to \mathbb{R}$ be a separately continuous function.

Suppose $X$: compact.

Is $g(y)=\sup\limits_{x\in X}f(x,y)$ continuous?

What if $Y$ is also compact?

++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++

Suppose $X$ is not compact. Then, it fails even when $f$ is (jointly) continuous. A counter example is given http://at.yorku.ca/cgi-bin/bbqa?forum=ask_an_analyst_2005&task=show_msg&msg=4110.0001. That $x$ can go as far as possible does bad.

Another counter example where $X$ is not compact is Supremum of continuous functions is continuous?.

Suppose $X$ and $Y$ are compact, and $f$ is (jointly) continuous. Following the argument here: How prove this $g(x)=\sup{\{f(x,y)|0\le y\le 1\}}$ is continuous on $[0,1]$ it seems to hold, using $f$ being uniformly continuous on $X\times Y$.

Go back to my question. In this case, we cannot use the uniform continuity. I tried doing the following and got stuck. From the compactness of $X$ and continuity in $x$, we can take $x^*_j\in\mathrm{argmax}_x f(x,y_j)$, ($j=1,2$), and $$|g(y_1)-g(y_2)|\le |f(x_1^*,y_1)-f(x_1^*,y_2)|+|f(x_1^*,y_2)-f(x_2^*,y_2)|.$$ The first term is good as $f(x_1^*,\cdot)$ is continuous, but I could not do anything with the second term, and started to think maybe this is not true.

Here is a counterexample.

Take $f\colon [0,1]\times[0,1]\to \mathbb R$ defined by: $$f(x,y) = \frac{2xy}{x^2+y^2},\quad f(0,0)=0.$$ Notice that $2xy = x^2 + y^2 - (x-y)^2 \le x^2+y^2$ hence $f(x,y)\le 1$. While $f(y,y) = 1$.

Of course $f$ is separately continuous, but for $y>0$ one has: $$\sup_x f(x,y) = f(y,y) = 1$$ while $f(x,0)=0$ hence $\sup_x f(x,0) = 0$.

This is not true in general. As a counterexample, I will use the compact space $X = \overline {\Bbb {N}}=\Bbb {N}\cup \{\infty\}$, the one point compactification of $\Bbb{N}$.

If we have a sequence of functions $(f_n)_n$ defined on any metric space $Y$ (we will consider $Y=[0,1]$) with $f_n (y)\to 0$ for all $y\in Y$ and if each $f_n$ is continuous, then $$F : X\times Y \to \Bbb {R}, (n,y)\mapsto \begin {cases} f_n (y),&y \in \Bbb {N}\\0,&y=\infty \end {cases}$$ is separately continuous. It suffices to find such a sequence, so that $$y\mapsto g (y):=\sup_{x \in X} F (x,y)=\sup_{n \in \Bbb {N}} f_n (y)$$ Is not continuous.

To this end, let $f_n :[0,1]\to \Bbb {R}$ be affinely linear on the intervals $[0,1/n], [1/n,2/n]$ with $f_n (0)=0$, $f_n (1/n)=1$, $f_n (2/n)=0$ and $f_n (y)=0$ for $y \geq 2/n$ (draw a picture!).

Then all properties from above are satisfied, but we have $g (0)=0$, while $g (1/n)\geq 1$ for all $n$. Thus, $g$ is not continuous.