Maximum of a function which may not be continuous I have the following function:
$$\frac{2(xe^y + z)}{(x(1+e^y) + z)}$$
I want to find the maximum of the function with the following constraint:
$$x \leq \frac{(1 - z)}{(1 + e^y)}$$
My questions are:


*

*What conditions should I check to make sure that the maximum exists?

*And how to find the maximum value?


Thanks!
 A: The question asks to find the maximum of the function
$$f(x,y,z) = \frac{2(xe^y + z)}{x\left(1+e^y\right) + z} \tag{1}\label{eq1}$$
subject to the constraint of
$$x \leq \frac{1 - z}{1 + e^y} \tag{2}\label{eq2}$$
The domain of $x,y,z$ is unspecified, but I'll assume it's $\mathbb{R}$.
In answer to the first question, I would first check if there is any simplification which can be done with the function in \eqref{eq1}. With the numerator, you have
\begin{align}
2\left(xe^y + z\right) & = 2\left(x + \left(xe^y + z\right) - x\right) \\
& = 2\left(x\left(1 + e^y\right) + z - x\right) \\
& = 2\left(x\left(1 + e^y\right) + z\right) - 2x \tag{3}\label{eq3}
\end{align}
Next, note since $e^y \gt 0$, you can multiply both sides of \eqref{eq2} by $1 + e^y$ to get
$$x\left(1+e^y\right) \le 1 - z \; \iff \; x\left(1+e^y\right) + z \le 1 \tag{4}\label{eq4}$$
This shows the denominator of the fraction in \eqref{eq1} can become arbitrarily close to either side of $0$, indicating no maximum is likely. To confirm this, let $y = 0$, $x = 1$, $z \le -1$ but $z \ne -2$. Then \eqref{eq4} still holds and you can substitute \eqref{eq3} into \eqref{eq1} to get
\begin{align}
f(x,y,z) & = 2 + \frac{-2x}{x\left(1+e^y\right) + z} \\
& = 2 + \frac{-2}{2 + z} \tag{5}\label{eq5}
\end{align}
Next, note that
\begin{align}
\lim_{z \, \to \, -2^{-}} f(x,y,z) & = \lim_{z \, \to \, -2^{-}} \left(2 + \frac{-2}{2 + z}\right) \\
& = \infty \tag{6}\label{eq6}
\end{align}
This formally shows there is no maximum value with just the one current constraint. Also, the limit $z$ going to $-2^{+}$ instead shows no minimum exists either since the limit then is $-\infty$ instead.
