Solving numerically an equation involving exponentials I met an equation of the following form:
$$\sum_{i=1}^nk_ip_i e^{-k_i\lambda}~~=~~b,$$
where $p_i\ge 0$, $k_i$ and $b$ are known for $i=1,\cdots, n$. I'd like to know how to find the solution $\lambda$ numerically. Basically, I consider two cases:
1. Assume that $k_i\ge 0$ for all $i=1,\cdots, n$. Then the function $\varphi(\lambda):=\sum_{i=1}^nk_ip_i e^{-k_i\lambda}$ is clearly decreasing and convex on $\mathbb R$. Under this situation, it is known that, for any $b<0$, there is no solution, and for any $b>0$, there is a unique solution. So does there exist some numerical scheme treating the special case?
2. Actually in my problem I can chose $k_i$ with some kind of freedom. So I can simply set $k_i=i/n$ w.l.o.g. and under this situation, solving the equation turns to solve the following polynomial 
$$\sum_{i=1}^na_i z^i~~=~~b,$$
where $a_i=ip_i/n$ and $z=e^{-\lambda/n}$. My question is how to solve numerically this polynomial (assuming $b>0$)? 
Many thanks for the idea and comment!
 A: Pretty much any textbook method should work on a monotonic and convex function. Bisection, for instance, if you want to keep it simple (once you manage to find upper and lower bounds for the solution, which shouldn't be hard).
I recommend Newton's method, because your derivative is easy to compute and one can prove that (on a decreasing convex function) if you start from an $x_0$ smaller than the solution it always converges monotonically and at least quadratically to it: it is a variant of the result mentioned here -- just apply it to $f(-x)$).
I would avoid using solvers for polynomial equations, because it is going to be difficult to enforce that the solution is positive if you use one.
A: Let $f_r$ be the function $f_r(x)= re^{-rx}$. For real $r\gt 0$, $f_r$ strictly decreases as $x$ strictly increases, and so the same holds for any positive linear combination of the $f_r$ where $r$ ranges over a finite set of positive real numbers.
Suppose you have found $\lambda_n$ given $b$, a finite set of $n$ positive $r$'s, and your positive linear combination $C$ using $p_i$ of the $f_r$. Now you are given the next coefficient $p_{n+1}$ and you need to find a bigger $r$ and a bigger $\lambda$ to solve your system which now is $C(\lambda) + p_{n+1}f_r(\lambda)=b$.
Here is an approach.  Pick a nice $\lambda \gt \lambda_n$, compute $y=b - C(\lambda)$ which is greater than 0, and now look for $r$ so that $p_{n+1}f_r(\lambda)=y$. You now have a new $r$ and a new $\lambda$ that you got to pick for your $n+1$ problem.  You can even use the derivative of $C$ to guide your choice for $\lambda$.
Gerhard "Free To Choose The Answer" Paseman, 2017.05.18.
