I need to solve the following equation for a hobby coding project I'm working on and I can't figure out the solution. Wolfram and SymboLab solvers are both stumped.

$$0 = d - (r^{p-1} * (p-1) * c)$$

I'm trying to solve for $p$, where $d$, $r$, $c$, and $p$ are all positive real numbers.

Seems like it should be quite doable. Any help? Thanks.

  • 1
    $\begingroup$ Since it’s numerical, just use Newton’s method. $\endgroup$ – Charlie Frohman Dec 14 '18 at 5:41

I may have a solution. The bad news: you're not going to like it because it's nasty. It ain't pretty.

So first, we get all of the $p$-based terms on one side of the equation, probably the most trivial step. This is kosher since all of the constants are nonzero. This gives us

$$(p-1)r^{(p-1)} = \frac{d}{c}$$

This is where it goes downhill. For simplicity, I let $x = p-1$ to make this a bit prettier, and we reduce this problem to finding $x$:

$$xr^{x} = \frac{d}{c}$$

If you've ever heard of the Lambert $W$-function, this expression absolutely screams its use. If not, the $W$ function is essentially introduced in scenarios where we have $xe^x = c$ for some number $c$ and want to find $x$. Then the $W$ function is applied to both sides to give $x = W(c)$. The $W$ function is basically the "inverse" to $xe^x$, i.e. $W(xe^x) = x$. I'll be honest and admit I don't know a whole lot about it, so I'll link to the Wikipedia article

The article does give us a way to solve $xr^x$ when $r$ is not necessarily $e$: the identity that

$$z = xa^x \;\;\; \Leftrightarrow \;\;\; x = \frac{W(z \ln(a))}{\ln(a)}$$

Take $z = d/c, a = r.$ Then,

$$\frac{d}{c} = xr^x \;\;\; \Leftrightarrow \;\;\; x = \frac{1}{\ln(r)}W\left(\frac{d}{c} \cdot \ln(r) \right)$$

Then, since $x = p-1,$

$$p = 1 + \frac{1}{\ln(r)}W\left(\frac{d}{c} \cdot \ln(r) \right)$$

Per the Wikipedia article, "the Lambert W relation cannot be expressed in terms of elementary functions," so unless there's a method I overlooked in solving this, this might be the best you get.

I'm not sure how it would be evaluated. The Wikipedia article notes some special values and approximation via Newton's method.

  • $\begingroup$ There are many articles and papers published on approximations of $W_0$ (the principal branch). Else, the OP can consider using Newton's method for example to find roots of the inverse of $xe^x$. $\endgroup$ – YiFan Dec 14 '18 at 7:33
  • $\begingroup$ Lambert function is beautiful ! So many applications in so many areas. If you serach for "Lambert" in this site, you will find 2550 entries. $\endgroup$ – Claude Leibovici Dec 14 '18 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.