Can I get an explicit function of n in this situation?

62 Views Asked by At

I have recently been working on a CS research project, and I am trying to get an equation in the form of $f(n)=...$ while the relationship between the variables $n, \epsilon, \delta $ is given as $\delta = \frac{\sqrt \pi e^{-n \epsilon^2}}{2\sqrt n}$. With my limited algebraic skills, I can not determine whether there exists an explicit definition of $n$. If anyone is able to figure that out, it would be greatly appreciated!.

1

There are 1 best solutions below

3
On BEST ANSWER

Welcome to MSE!

There is no way to solve this with the "standard" functions we teach in highschool, or even in most undergraduate courses. But that doesn't mean you should give up hope! Lambert's W Function will solve this problem, and is nowhere near as scary is some people think it is. Since it is somewhat esoteric, though, I'll expand both on what it is and how it's relevant here.

First, what is it. Even though the linked wikipedia article has a definition, in the interest of a self contained answer:

$$z = w e^w \implies w = W(z)$$

So we see that the $W$ function lets us invert the function $we^w$, in much the same way that $\log$ lets us invert $\exp$:

$$z = e^w \implies w = \log(z)$$

In fact, there are yet more similarities. If you've done much complex analysis, you'll know that the $\log$ function is actually not well defined on the whole complex plane. We have to pick a branch before we can do anything else. Similarly, there are different branches of the $W$ function, but if you promise to only work with positive real numbers, you don't need to worry about this. Thankfully in your case we are working with positive real numbers, so I won't mention this again.

Now, why is this useful? Well, for the same reason $\log$ is useful! Oftentimes in the wild we come across identities of the form $we^w = z$, and we want to find an expression for $w$ in terms of $z$ -- in fact, your question is one instance of this problem!

To see why, notice:

$$ \begin{aligned} \delta = \frac{\sqrt{\pi}e^{-n \epsilon^2}}{2 \sqrt{n}} &\implies \sqrt{n} e^{\epsilon^2 n} = \frac{\sqrt{\pi}}{2\delta} \\ &\overset{(1)}{\implies} n e^{2 \epsilon^2 n} = \frac{\pi}{4 \delta^2} \\ &\overset{(2)}{\implies} 2 \epsilon^2 n e^{2 \epsilon^2 n} = \frac{2 \epsilon^2 \pi}{4 \delta^2} \\ &\overset{(3)}{\implies} w e^w = z = \frac{\epsilon^2 \pi}{2 \delta^2} \\ &\overset{(4)}{\implies} 2 \epsilon^2 n = w = W \left ( \frac{\epsilon^2 \pi}{2 \delta^2} \right ) \\ &\implies n = \frac{1}{2 \epsilon^2} W \left ( \frac{\epsilon^2 \pi}{2 \delta^2} \right ) \end{aligned} $$

In step $(1)$ we square both sides, in $(2)$ we multiply both sides by $2 \epsilon^2$, in order to make the substitution $w = 2 \epsilon^2 n$ in step $(3)$. Then we apply the definition of $W$ in step $(4)$ to finish things off.

Notice that this really is a useful definition! In the same way that we can calculate $\log$ with a computer to any desired precision, we can do the same thing with $W$! Honestly it's every bit as valid as the $\log$ function is, but it gets a bad reputation because it's not as well known. For instance, if $\epsilon = \delta = 0.01$, we can use sage to find:

sage: epsilon = 0.01
sage: delta = 0.01
sage: n = 1/(2*epsilon) * lambert_w((epsilon^2 * pi) / (2 * delta^2))
sage: n.n() # compute a numerical approximation
37.2703629474026

Now, since you say this is a CS project, you might be interested in the asymptotics of $n$. Much is known about this as well, and you will again find a lot of great information on the wikipedia page.


I hope this helps ^_^