TITLE: How many real solutions does $\lambda_1 e^{y - \lambda_1 e^y} (1 - \lambda_1 e^y ) + \lambda_2 e^{y - \lambda_2 e^y} (1 - \lambda_2 e^y ) = 0$ have?
QUESTION [9 upvotes]: I am trying to work out for what $\lambda_1, \lambda_2 > 0$ is it true that  $f(y) = \lambda_1 e^{y-\lambda_1 e^y} + \lambda_2 e^{y-\lambda_2 e^y}$ is unimodal?
Experimentally it seems it is unimodal when $\lambda_1 < \lambda_2$ and $\frac{\lambda_2}{\lambda{1}} <  7.5$ .
To work this out I started with:
$$\frac{d}{dy} \left(\lambda_1 e^{y-\lambda_1 e^y} + \lambda_2 e^{y-\lambda_2 e^y} \right) = \lambda_1 e^{y - \lambda_1 e^y}  (1 - \lambda_1 e^y ) + \lambda_2 e^{y - \lambda_2 e^y}  (1 - \lambda_2 e^y )$$
It seems we then need to check when
$$\lambda_1 e^{y - \lambda_1 e^y}  (1 - \lambda_1 e^y ) + \lambda_2 e^{y - \lambda_2 e^y}  (1 - \lambda_2 e^y ) = 0$$
has more than one solution when solved for $y \in \mathbb{R}$.  How can we determine the conditions under which it has different numbers of solutions?
Added:
Substituting $z = e^y$ and dividing by $e^{y-1}$ we are trying to determine how many solutions
$$
 \lambda_1 e^{1-\lambda_1 z}(1-\lambda_1 z) +\lambda_2e^{1-\lambda_2 z}(1-\lambda_2 z) = 0
$$
has with $z > 0$.
Examples:
Example $\lambda_1 = 1, \lambda_2 = 7$ with only one mode (code in python):
import matplotlib.pyplot as plt
import numpy as np
def pdf_func(y, params):
    return sum([lambd*np.exp(y - lambd * np.exp(y)) for lambd in params])
params = [1, 7]
xs = np.linspace(-10,10,1000)
plt.plot(xs, [pdf_func(y, params) for y in xs])


Example $\lambda_1 = 1, \lambda_2 = 50$ with two modes:

Questions

How can one prove (assuming it is true) that that the number of local maxima that $f(y)$ has is either 1 or 2 and there are no other possibilities?
Is it true that for $\lambda_2 > \lambda_1 > 0$, there exists a threshold $c$ so that if $\frac{\lambda_2}{\lambda_1} < c$ then $f(y)$ is unimodal and if not it has two local maxima? (My guess is that the answer is yes and this threshold is around $7.5$.)

REPLY [2 votes]: The proof is not hard but long. 
Let $w = \lambda_1 \mathrm{e}^y$ and $c = \frac{\lambda_2}{\lambda_1}$.
Let $$g(w) = w\mathrm{e}^{-w} + cw \mathrm{e}^{-cw}.$$
We first give the following auxiliary result. The proof is given later.
Fact 1: Let $w_1 = \frac{c+1 - \sqrt{c^2-6c+1}}{2c}$ and $w_2 = \frac{c+1 + \sqrt{c^2-6c+1}}{2c}$. Then we have:
i) $g'(w_1) < 0$ for $c > 3 + 2\sqrt{2}$.
ii) $g'(w_2) = 0$ has exactly one solution on $(3+2\sqrt{2}, \infty)$, denoted by $c_0 \approx 7.566278$.
iii) $g'(w_2) \le 0$ for $3 + 2\sqrt{2} < c \le c_0$. 
iv) $g'(w_2) > 0$ for $c > c_0$.
Now let us proceed. We give the results for $c \ge 1$ as follows. The proof is given later.
Lemma 1: If $1\le c \le c_0$, then $g(w)$ is unimodal on $(0, \infty)$. If $c > c_0$, then $g(w)$ has exactly two local maxima on $(0, \infty)$.
For $0 < c \le 1$, simply let $c_1 = \frac{1}{c}$ and $w_1 = cw$ to get $w\mathrm{e}^{-w} + cw\mathrm{e}^{-cw}
= c_1w_1\mathrm{e}^{-c_1w_1} + w_1\mathrm{e}^{w_1}$. Thus, we immediately have the following results:
Lemma 2: If $\frac{1}{c_0} \le c \le 1$, then $g(w)$ is unimodal on $(0, \infty)$. If $0 < c < \frac{1}{c_0}$, then $g(w)$ has exactly two local maxima on $(0, \infty)$.
$\phantom{2}$
Proof of Fact 1: Note that $\frac{1}{c} < w_1 < w_2 < 1$. We have
\begin{align}
g'(w_1) &= \mathrm{e}^{-w_1}c(cw_1-1)\big(\frac{1-w_1}{c(cw_1-1)} - \mathrm{e}^{(1-c)w_1}\big), \\
g'(w_2) &= \mathrm{e}^{-w_2}c(cw_2-1)\big(\frac{1-w_2}{c(cw_2-1)} - \mathrm{e}^{(1-c)w_2}\big).
\end{align}
Let
\begin{align}
h(w_1) &= \ln \frac{1-w_1}{c(cw_1-1)} - (1-c)w_1, \\
h(w_2) &= \ln \frac{1-w_2}{c(cw_1-1)} - (1-c)w_1.
\end{align}
For $c\in (3+2\sqrt{2}, \infty)$, let $t = c + \sqrt{c^2-6c+1}$, then we have $t \in ( 3 + 2\sqrt{2}, \infty)$ and $c = \frac{t^2-1}{2t-6}$.
With this substitution (actually the so-called Euler substitution), we have
\begin{align}
h(w_1) &= \ln \frac{2(t-3)^3}{(t+1)^3(t-1)} + \frac{2(t^2-2t+5)}{(t+1)(t-3)} \triangleq h_1(t), \\
h(w_2) &= \ln\frac{8(t-3)}{(t-1)^3(t+1)} + \frac{t^2-2t+5}{2t-2} \triangleq h_2(t).
\end{align}
We have
\begin{align}
h_1'(t) &= -\frac{(t^2-6t+1)(t^2-10t+5)}{(t-3)^2(t-1)(t+1)^2}, \\
h_2'(t) &= \frac{(t^2-6t+1)(t^2-4t-1)}{2(t-1)^2(t+1)(t-3)}.
\end{align}
It is easy to prove that $h_1'(t) > 0$ for $t\in (3+2\sqrt{2}, 5+2\sqrt{5})$ and $h_1'(t) < 0$ for $t\in (5+2\sqrt{5}, \infty)$.
Thus, $h_1(t)$ is strictly increasing on $(3+2\sqrt{2}, 5+2\sqrt{5})$ and strictly decreasing on $(5+2\sqrt{5}, \infty)$.
Note that $h_1(5+2\sqrt{5}) < 0$. Thus, we have $h_1(t) < 0$ for $t\in (3+2\sqrt{2}, \infty)$.
Thus, $g'(w_1) < 0$ for $w\in (3 + 2\sqrt{2}, \infty)$.
Also, it is easy to prove that $h_2'(t) > 0$ for $t\in (3 + 2\sqrt{2}, \infty)$. Thus, $h_2(t)$ is strictly increasing on $(3 + 2\sqrt{2}, \infty)$.
Note also that $h_2(3+2\sqrt{2}) < 0$ and $h_2(\infty) = \infty$. Thus, $h_2(t)=0$ has exactly one solution on $(3 + 2\sqrt{2}, \infty)$, \
denoted by $t_0 \approx 11.15109339$.
Also, $h_2(t) < 0$ for $t\in (3+2\sqrt{2}, t_0)$ and $h_2(t) > 0$ for $t\in (t_0, \infty)$.
Let $c_0 = \frac{t_0^2-1}{2t_0-6}\approx 7.566278$. We have $g'(w_2) < 0$ for $3 + 2\sqrt{2} < c < c_0$, and $g'(w_2) > 0$ for $c > c_0$.
The desired result follows. This completes the proof of Fact 1.
$\phantom{2}$
Proof of Lemma 1: If $c = 1$, we have $g(w) = 2w\mathrm{e}^{-w}$ which is unimodal on $(0, \infty)$.
In the following, assume that $c > 1$. We have
$$g'(w) = \mathrm{e}^{-w}\big(1 - w - c(cw-1)\mathrm{e}^{(1-c)w}\big).$$
Clearly, $g'(w) = 0, \ w\in (0, \infty)$ is equivalent to
$$\ln \frac{1-w}{c(cw-1)} = (1-c)w, \quad \frac{1}{c} < w < 1.$$
Let
$$h(w) = \ln \frac{1-w}{c(cw-1)} - (1-c)w.$$
We have
$$h'(w) = \frac{-(c-1)(cw^2 - (c+1)w + 2)}{(cw-1)(1-w)}.$$
There are two possible cases:
1) If $1 < c \le 3+2\sqrt{2}$, we have $cw^2 - (1+c)w + 2 \ge 0$ for $w\in (-\infty, \infty)$,
with equality only if $c = 3 + 2\sqrt{2}$ and $w = 2-\sqrt{2}$.
Thus, $h'(w)\le 0$ for $\frac{1}{c} < w < 1$, with equality only if $c = 3 + 2\sqrt{2}$ and $w = 2-\sqrt{2}$.
Thus, $h(w)$ is strictly decreasing on $\frac{1}{c} < w < 1$.
Note also that $h(\frac{1}{c}^{+}) = \infty$ and $h(1^{-}) = -\infty$.
Thus, $h(w) = 0$ has exactly one solution on $\frac{1}{c} < w < 1$.
Thus, $g'(w)=0$ has exactly one solution on $(0, \infty)$.
Note also that $g'(0) > 0$ and $g'(\infty) = -\infty$. Thus, $g(w)$ is unimodal on $(0, \infty)$.
2) If $c > 3 + 2\sqrt{2}$, then $h'(w) < 0$ for $w\in (\frac{1}{c}, w_1)$, $h'(w) > 0$ for $w\in (w_1, w_2)$ and
$h'(w) < 0$ for $w\in (w_2, 1)$ where $w_1, w_2$ are the two distinct real solutions of $h'(w)=0$ on $(\frac{1}{c}, 1)$ given by
$$w_1 = \frac{c+1 - \sqrt{c^2-6c+1}}{2c}, \quad w_2 = \frac{c+1 + \sqrt{c^2-6c+1}}{2c}.$$
Thus, $h(w)$ is strictly decreasing on $(\frac{1}{c}, w_1)$, strictly increasing on $(w_1,w_2)$,
and strictly decreasing on $(w_2, 1)$. There are two possible cases:
Case I $3+2\sqrt{2} < c \le c_0$: 
From Fact 1, we have $h(w_2)\le 0$. Since $h(w_1) < h(w_2) \le 0$ and $h(\frac{1}{c}^{+}) = \infty$, there exists $d\in (\frac{1}{c}, w_1)$
such that $h(d) = 0$, $h(w) > 0$ for $w\in (\frac{1}{c}, d)$, $h(w) < 0$ for $w\in (d, w_2)$
and $h(w) < 0$ for $w\in (w_2, 1)$. Note that for $w\in (\frac{1}{c}, 1)$,
$$g'(w) = \mathrm{e}^{-w}c(cw-1)\Big(\frac{1-w}{c(cw-1)} - \mathrm{e}^{(1-c)w}\Big).$$
Thus, $g'(w) > 0$ for $w \in (\frac{1}{c}, d)$, $g'(w)<0$ for $w\in (d, w_2)$ and $g'(w) <  0$ for $w\in (w_2, 1)$.
Also, clearly $g'(w) > 0$ for $w\in (0, \frac{1}{c}]$ and $g'(w) < 0$ for $[1, \infty)$.
Thus, $g'(w)>0$ for $w\in (0, d)$, $g'(w) < 0$ for $w\in (d, w_2)$ and $g'(w) < 0$ for $w \in [w_2, \infty)$.
Thus, $g(w)$ is strictly increasing on $(0, d)$, and strictly decreasing on $(d, \infty)$.
Thus, $g(w)$ is unimodal on $(0, \infty)$.
Case II $c > c_0$: From Fact 1, we have $h(w_1) < 0$ and $h(w_2)> 0$.
Note also that $h(\frac{1}{c}^{+}) = \infty$.
Thus, there exists $d_1\in (\frac{1}{c}, w_1)$, $d_2\in (w_1, w_2)$ and $d_3\in (w_2, 1)$ such that
$h(w) > 0$ for $w \in (\frac{1}{c}, d_1)$, $h(w) < 0$ for $w\in (d_1, d_2)$,
$h(w) > 0$ for $w\in (d_2, d_3)$ and $h(w) < 0$ for $w\in (d_3, 1)$.
Note that for $w\in (\frac{1}{c}, 1)$,
$$g'(w) = \mathrm{e}^{-w}c(cw-1)\Big(\frac{1-w}{c(cw-1)} - \mathrm{e}^{(1-c)w}\Big).$$
Thus, $g'(w) > 0$ for $w \in (\frac{1}{c}, d_1)$, $g'(w) < 0$ for $w\in (d_1, d_2)$,
$g'(w) > 0$ for $w\in (d_2, d_3)$ and $g'(w) < 0$ for $w\in (d_3, 1)$.
Also, clearly $g'(w) > 0$ for $w\in (0, \frac{1}{c}]$ and $g'(w) < 0$ for $[1, \infty)$.
Thus, $g'(w)>0$ for $w\in (0, d_1)$, $g'(w) < 0$ for $w\in (d_1, d_2)$,
$g'(w) > 0$ for $w\in (d_2, d_3)$ and $g'(w) < 0$ for $w\in (d_3, \infty)$.
Thus, $g(w)$ is strictly increasing on $(0, d_1)$, strictly decreasing on $(d_1, d_2)$,
strictly increasing on $(d_2, d_3)$, and strictly decreasing on $(d_3, \infty)$.
Thus, $g(w)$ has exactly two local maxima on $(0, \infty)$. This completes the proof of Lemma 1.