Maximum of the sum of two functions with different variables Let $x\in \mathbb{R}^n$ and $y\in \mathbb{R}^m$, and let $f:\mathbb{R}^{n+m}\to \mathbb{R}$ such that
$$
f(x,y) = g(x)+h(y)
$$
with $g$ and $h$ real functions (i.e. they map to the reals). Is it then true that $\max(f) = \max(g) + \max(h)$ as long as the maxima exist for all functions and $(\max(g), \max(h))\in Dom(f)$?
EDIT:
I am gonna write again the question but in a different way because I can see why it is confusing (I read it again and I didn't understand it completely myself) and also why I wanted to know this.
Let $f,g,h$ be as above, and let $z^*, x^*, y^*$ be such that $\max(f) =  f(z^*)$, $\max(g) =  g(x^*)$ and $\max(h) =  h(y^*)$. Given the answers, it follows that
$$
f(z^*) = g(x^*) + h(y^*)
$$
but is it also true that $z^* = (x^*, y^*)$?
This question comes from a much simpler answer in which I want to maximize a function of the form $f(p, \pmb{\theta}) = f_1(p) + f_2(\pmb{\theta})$ where $f$ is a density function, $p$ is a scalar and $\pmb{\theta}$ a vector. I maximized $f_1$ and $f_2$ separately and found $p^*$ and $\pmb{\theta}^*$ maximum of their own functions, but is $(p^*,\pmb{\theta}^*)$ also the maximum of $f$? I believe it is true given the definition of maximum, but I wanted to know if there is a general result or theorem regarding this situation.
 A: First, assume that $g$ and $h$ achieve their maximum values at some points $x_h\in\mathbb{R^n}$ and $y_g\in\mathbb{R^m}$. It makes more sense to ask if $(x_h,y_g)\in Dom(f)$ instead, as $max(h)$, and $max(g)$ are in $\mathbb{R}$ (if they are bounded at least), so $(max(h),max(g))\in\mathbb{R^2}$, not necessarily $\mathbb{R}^{n+m}$, the domain of $f$. Even if the domain lines up, we would still probably want to consider inputs that could potentially output maximum values for $f$, not inputs only related to the maximum values of $h$ and $g$.
Now, the answer is, basically, yes, but you should check that the definition of maximum is taken explicitly over values of $h$ and $g$, and not the absolute values of the functions. If so, we may take sequences in $\mathbb{R^m}$ and $\mathbb{R^n}$ such that the image sequences of $h$ and $g$ converge to $max(h)$ and $max(g)$. Then we can construct a corresponding sequence in $\mathbb{R^{m+n}}$ in which the outputs of $f$ converge to $max(h)+max(g)$. Also, observe that for all points $(x,y)$, $f(x,y)=h(x)+g(y)\leq max(h)+max(g)$, so $max(f)=max(h)+max(g)$.
However, if the maximum is defined as the least upper bound of the the range of the absolute values of each function, then this does not work. Try constructing some $h$ always negative and some $g$ always positive. Then their maximums will both be positive, but you will notice $max(f)\leq max(max(h),max(g))$.
A: If you assume all maxima for $f,g,h$ exist, the result is straightforward.
Denote the maximum value the functions attain as $F, G, H$. Clearly $g(x) \leq G$ and $h(y) \leq H$ for any $x, y$. Thus $g(x) + h(y) \leq G + H$ for all $x,y$ too. Therefore $G+H$ is an upper bound of $f$, since $f(x,y) = g(x) + h(y)$. But since we assumed all functions attain maxima, we know that $g$ and $h$ attain their maxima at values say $x_g, y_g$ respectively. $f$ is well defined for these two values, and we see $$f(x_g,y_g) = g(x_g) + h(y_g) = G + H$$
But then $G+H$ is an upper bound that is attained over $f$, so $G+H$ is the maximum of $f$.
