Continuity Proof “If $f(x,w)$ is continuous and its domain is a cartesian product, $\max_{w}f(x,w)$ is continuous.”

I posted several questions about the continuity of $$max$$ functions.

Let me assume that the function $f(x,y,z,w)$ is continuous. Is the $\max_{w} f(x,y,z,w)$ continuous?

Continuity proof for compact domain

Continuity proof "If $f(x,y,z,w)$ is continuous and domains of $x,y,z,w$ are all convex set, then $\max_{w} f(x,y,z,w)$ is continuous."

I combined the answers about the continuity and the condition that the domain is convex or compact is not sufficient for showing that the $$\max_{w} f(x,w)$$ is continuous.

However, in Continuity proof for compact domain, Hans Engler gave me a comment that $$\max_{w} f(x,w)$$ is continuous if the domain is a Cartesian product.

So I want to know how to prove: "If $$f(x,w)$$ is continuous and $$x\in [0,x_1]\times[0,x_2]\times[0,x_2]\times[0,x_2]\times[0,x_4]$$, $$w\in[0,w_1]$$, $$\max_{w}f(x,w)$$ is continuous. ($$x_1,x_2,x_3,x_4$$ and $$w_1$$ is real number.)"

Good news, this should be true!

We denote the domain for $$x$$ by $$X$$ and the domain for $$w$$ by $$W$$. We also define $$g(x):= \max_{w \in W} f(x,w).$$

For proving continuouity of $$g$$ at a point $$\bar x$$, let $$x_n$$ be a sequence such that $$x_n\to \bar x$$. We have to show that $$g(x_n)\to g(x_0)$$. Let $$w_n$$ be such that $$g(x_n)=f(x_n,w_n)$$. Since $$w_n$$ is from a compact domain, it has a convergent subsequence $$w_{n_k}$$ with limit $$w$$. Then it follows that $$g(x_0)\geq f(x_0,w) = \lim_k f(x_{n_k},w_{n_k}) = \lim_k g(x_{n_k}).$$ By using the same argument for a suitable subsequence of $$x_n$$, it follows that $$g(x_0)\geq \limsup_n g(x_n).$$

Let $$w_0$$ be such that $$g(x_0)=f(x_0,w_0)$$. It remains to show that $$g(x_0)\leq \liminf_n g(x_n)$$. But this is true due to the following calculation. $$g(x_0) = f(x_0,w_0) = \liminf_n f(x_n,w_0) \leq \liminf_n g(x_n).$$ This completes the proof.

some comments: Note that we only need the compactness of $$W$$ (for the existence of maximizers and converging subsequence). For $$X$$ we do not need compactness. We also dont need any convexity (neither for $$X$$ nor for $$W$$).

Let $$K$$, $$W$$ be compact metric spaces (with distances $$d_K$$ and $$d_W$$) and $$f\colon K\times W\to\Bbb R$$ continuous. Then $$M(x)=\max_{w\in W}f(x,w)$$ is continuous on $$K$$.

Proof. Since $$K\times W$$ is compact, $$f$$ is uniformly continuous. Given $$\epsilon>0$$ there exists $$\delta>0$$ such that $$x,y\in K,\quad d_K(x,y)\le\delta\implies |f(x,w)-f(y,w)|\le\epsilon\quad\forall w\in W.$$ Then $$f(x,w)\le f(y,w)+\epsilon\le M(y)+\epsilon\quad\forall w\in W.$$ Taking the maximum with respect to $$x$$ we get $$M(x)\le M(y)+\epsilon.\tag{1}$$ Similarly, we can prove that $$M(y)\le M(x)+\epsilon.\tag{2}$$ From (1) and (2) we finally get $$|M(x)-M(y)|\le\epsilon.$$

In your case, $$K=[0,x_1]\times[0,x_2]\times[0,x_2]\times[0,x_2]\times[0,x_4]$$ and $$W=[0,w_1]$$.