Solve for a variable with a variable exponent.

102 Views Asked by At

I'm working on a video-game and have come up with the following equation:

$$B^S={B-1\over R} +1$$

I need to solve for B in terms of R and S (which will be supplied at runtime) but for the life of me I can't seem to simplify it. I even tried an online variable solver and it just gives up.

Conceptually grasping what this is supposed to contribute to convinces me there has to be a solution, I'm hoping somebody has the knowledge to arrive at it. For what it's worth, the intended values for R are in the 0 < R < 1 range, and S is intended to be in the 1 <= S <= 2 range.

Much gratitude!

EDIT: In the end I found a different approach for my application which yielded a general solution. Thank you all who contributed, it did help!

2

There are 2 best solutions below

1
On BEST ANSWER

Except for very few specific cases, you cannot get explicit solutions and you need numerical methods.

Consider that you look for the zero(s) of function $$f(B)=B^S-\frac{B-1}{R}-1$$ $$f'(B)=S B^{S-1}-\frac{1}{R}$$ $$f''(B)=(S-1) S B^{S-2}$$ The first derivative cancels at a point $$B_*=\left(\frac{1}{R S}\right)^{\frac{1}{S-1}}$$ and the second derivative is always positive if $ 1 < S <2$ (I do not consider the cases $S=1$ or $S=2$ for which the problem is simple). Since we can bound the function, the solution is always between $\left(\frac 1R -1\right)$ and $1$.

You can also notice that $B=1$ is a trivial solution for any $R,S$ in the provided ranges. Since $f(0)=\frac 1R >0$, if $f(B_*) <0$, then the solution is $> B_*$.

So, what I should do is to compute $f(k B_*)$ for $k=2,3,4,\cdots$ until we find the smallest $k$ such that $f(k B_*)>0$. At this point, let $B_0=k_{min}B_*$ and start Newton method.

Let us take one example using $S=1.234$ and $R=0.567$; this gives $B_*\approx 4.6$. Using the simplistic procedure, we find $k_{min}=2$; so start using $B_0=9.2$ and get the following iterates $$\left( \begin{array}{cc} n & B_n \\ 0 & 9.201489213 \\ 1 & 9.194700041 \\ 2 & 9.194696121 \end{array} \right)$$

Let us repeat using $S=1.357$ and $R=0.246$; this gives $B_*\approx 21.6$. Using the simplistic procedure, we find $k_{min}=3$; so start using $B_0=64.8$ and get the following iterates $$\left( \begin{array}{cc} n & B_n \\ 0 & 64.83555879 \\ 1 & 51.00444906 \\ 2 & 48.72198422 \\ 3 & 48.64769013 \\ 4 & 48.64760965 \end{array} \right)$$

If you want something more sophisticated, we could approximate $B_0$ expanding the function as a truncated Taylor series around $B_*$. This would give $$B_0=B_*+ \sqrt{-2\frac{f(B_*) }{f''(B_*) }}$$ For the worked examples, this would give as starting values $8.76$ and $46.05$.

6
On

Rearrange your equation to $$ B=f(B)=\sqrt[S]{\frac{B-1}R+1}$$

You could start with a rough estimate then apply the function $f(B)$ several times until the answer settles down. $$\begin{split} B_1&=2\\ B_2&=f(B_1)\\ B_3&=f(B_2)\\ B_4&=f(B_3)\\ B_5&=f(B_4)\\ &\hspace{0.55em}\vdots \end{split}$$ You might check first that $S$ isn't exactly 1 or 2. There is no solution when $S=1$ and a simple solution when $S=2$.

EDIT

Sorry, ,Newton's method would be

$$B_2=B_1-\frac{RB_1^S-R-B_1+1}{RSB_1^{S-1}-1}$$ and repeat for B3, and so on.