Convert this equation to find nth instead I have this equation
a(n) = 2^(n - 1) n
for the series
1,4,12,32,80,192,448,.....
So when n = 4, a(n) = 32
What I am looking for is to get n for a(n), but a(n) is not always in the series
Example
Get n for 50?
50 is between a(4) and a(5)
In this case it will be the smaller one
even if we are getting n for 447, which is between a(6) and a(7), but clearly it is much closer to a(7), I will require n =6
I will be using the equation in a computer program, so if the convertion equasion returns a fraction/decimal, that is fine, as converting it into integer will do the trick.
So basically, I need the above equation converted into
n = .....
Sorry, I don't know what tag best suits the question, please amend if you don't mind.
 A: Here is an analytic solution.
This problem is essentially asking for the inverse function for $y=x\cdot 2^{x-1},$ as if for an integer $n,$ if $x$ is such that $n=x2^{x-1},$ then the number you are looking for is the floor of $x.$
This can be written explicitly using the Lambert $W$ function, as the following: $x=W((2\ln2 )\cdot y)/\ln 2.$ How to best calculate the Lambert $W$ function is answered here.
A: The 2^n part of your equation will dominate what's going on. (I broke off the -1 part to be division by 2).  Taking the log base 2 of a(n) will get you pretty close.  If you don't wish to muss with differential equations, you can use approximation to get what you want.  Start with pretty close and then calculate the a(n) it gives you.  If it's too low, try a(n+1) and if it's too high, try a(n-1).  Once you have answers that are too high and too low, you can trap the correct answer between them. Try n in the middle of them like a(n+.5).  Depending on if that's too high or too low, use it as the new boundary for where n really is.  You can keep cutting the distance between the possible answers by half every time until you're happy with how close you are.
