How can I get a function that is "approximately similar" to the part I care about in another function?

80 Views Asked by At

I have a function f(x)=$(a+bx)e^{-cx}, x\ge0$ where $a$, $b$, and $c$ are constants, and $c>0$.

How can I get a function that is "approximately the same" as the part after the hump?

I need this so I can get the inverse of it for a computer program; taking the inverse of the function in its current form results in some sorcery that I can't comprehend.

I don't really care about precision close to the hump, but it does matter further away.

Just by playing around in Desmos with my limited mathematical knowledge for a while, I found that $\frac 1 {e^x+1}$ matches close enough to what I'm looking for. Below is a picture of the somewhat arbitrary values I used to come close. I figured that the top of the orange line is probably going to be around twice the maximum value of $f$, so $a$ is the value of $f$ where the derivative is $0$.

enter image description here

1

There are 1 best solutions below

2
On BEST ANSWER

$\require{begingroup} \begingroup$ $\def\e{\mathrm{e}}\def\W{\operatorname{W}}\def\Wp{\operatorname{W_0}}\def\Wm{\operatorname{W_{-1}}}\def\Catalan{\mathsf{Catalan}}$

\begin{align} f(x)&=(a+bx)\exp(-cx) ,\quad x\ge0 \tag{1}\label{1} \end{align}
where $a$, $b$, and $c$ are constants, and $c>0$.

There is absolutely no need to reinvent the wheel in this case, since there is a solution for $f(x)=y$:

\begin{align} x&= -\frac ab-\frac1c\cdot\W\left(-\frac{cy}b \,\exp\left(-\frac{ac}b\right)\right) \tag{2}\label{2} \end{align}

in terms of Lambert $\W$ function (also known as ProductLog), with well-known behavior, which is available in many programming systems. There is just a few things to note: the number of real solutions of \eqref{1} depends on the value of the argument of $\W(z)$ in \eqref{2}.

\begin{align} z&=-\frac{cy}b \,\exp\left(-\frac{ac}b\right) \tag{3}\label{3} \end{align}

and, depending on its value we have

\begin{align} 1)\ z&\ge0: \quad \text{there is one real solution,} \quad x=-\frac ab-\frac1c\cdot\Wp(z) ,\\ 2)\ z&\in(-\tfrac1e,0): \quad \text{there are two real solutions,} \\ x_0&=-\frac ab-\frac1c\cdot\Wp(z) \quad\text{and}\quad x_1=-\frac ab-\frac1c\cdot\Wm(z) ,\\ 3)\ z&=-\tfrac1e: \quad \text{there is one real solution,} \\ x&=-\frac ab-\frac1c\cdot\Wp(-\tfrac1e) =-\frac ab-\frac1c\cdot\Wm(-\tfrac1e) =-\frac ab+\frac1c \\ 4)\ z&<-\tfrac1e: \quad \text{there is no real solutions} \end{align} where $\Wp$ is the principal branch and $\Wm$ is the other real branch of the Lambert $\W$ function.

Don't be scared with this "branch" term - consider these two branches as just two real functions. Usually they are available either as two distinct function names, for example, W0 and Wm1, or as one function with extra parameter, for example W(z) for $\Wp(z)$ and W(z,-1) for $\Wm(z)$, like in python:

from scipy.special import lambertw as W
print (W(-0.2).real, W(-0.2,-1).real)
# -0.25917110181907377 -2.5426413577735265

$\endgroup$