1

I have an equation for $\sum\limits_{i=1}^ni2^i=\text{res}$

the equation is converted to $$ (n-1)2^{n+1}+2=\text{res} $$ I know the value of res but how to get value of $n$ .

It's OK to have an approximate solution.

Harry Peter
  • 7,819
Madan Ram
  • 115

3 Answers3

3

I am not sure what res is, I am going to assume that it is 20 and show you how I would solve the problem.

You need to solve $$ f(n) = (n-1)2^{n+2} -18 = 0$$ The most general way to do it is the Newton's method that starts with a guess for $n$ and improves it using $$ n_{\text{improved}} = n_{\text{guess}} - f(n_{\text{guess}}) / f'(n_{\text{guess}})$$ which in your case, the improvement function on the right is $$n-{{\left(n-1\right)\,2^{n+1}-18}\over{\log 2\,\left(n-1\right)\,2 ^{n+1}+2^{n+1}}} \tag 1$$ If you start with an initial guess of $n=3$, you can keep improving to get: $$\left[ 3.0 , 2.6333 , 2.5476 , 2.5436 , 2.5436 \right] $$

Note: If res is different then change the 18 to res-2 in equation (1) and change the starting guess accordingly.

added based on what the OP tried to explain

Here is how I would find $n$ if I know res. Again, these calculations are for res = 20. Equation(1) shows how to improve the value of $n$. Starting with a initial guess of $2$, we get the following improvements...

$$\begin{align} \text{guess: $n=2.0000$,} &~~~& \text{improved: $n=2.7383$} \\ \text{guess: $n=2.7383$,} &~~~& \text{improved: $n=2.5616$} \\ \text{guess: $n=2.5616$,} &~~~& \text{improved: $n=2.5438$} \\ \text{guess: $n=2.5438$,} &~~~& \text{improved: $n=2.5436$} \\ \text{guess: $n=2.5436$,} &~~~& \text{improved: $n=2.5436$} \\ \end{align}$$

user44197
  • 9,730
2

If I properly understood, the equation you want to solve for n is : $$ (n-1) \, \left(2^{n+1}\right) + 2 = \text{res} $$

The solution of this class of equations is given by Lambert function (I suggest you have a look at http://en.wikipedia.org/wiki/Lambert_W_function).

For your specific problem, the algebraic solution is given by

$n = 1 + W(z) / \log(2)$ where $z = (\text{res} - 2) \log(2) / 4$

For example, for $\text{res} = 10^4$, the above expression leads to $n = 9.24407$. For $n=9$, your summation gives $8194$ and for $n=10$, your summation gives $18434$.

As shown by user44197, Newton method will solve this problem quite simply but here you have an exact solution based on Lambert function. Where this starts to be interesting is if you look at very large values of "res" which would correspond to large values of "n". Suppose $res=10^{12}$; the exact solution is $n=33.8264$. An approximate value equal to $33.8221$ is obtained using the beginning of the approximation:

$W(z) = \log(z) - \log(\log(z)) + \log(\log(z)) / \log(z) $

given in the Wikipedia page.

Using $\text{res}=10^{1000}$, the exact and approximate solutions are equal to $3309.24$.

  • Leibovich : in the case that there is an integer solution for $n$, which seems to be what the OP is interested in, do you know if there is a formula for $n$ in terms of "res" that does not require exotic functions such the Lambert function (and might use the floor or ceiling function)? Such a formula might use the approximation for $W(z)$ that you give in your answer and that appears in the Wikipedia page. – Stefan Smith Dec 31 '13 at 17:38
  • @StefanSmith. It could be that the solution be an integer; I guess that this would restrict a lot the possible values. The only way I found was an algebraic approach (just as user44197). I should very interested to know how to approach the solution for an integer. By the way, Lambert is not more exotic than logarithm or exponential (Lambert and Euler worked together all these functions). Happy New Year !! – Claude Leibovici Dec 31 '13 at 18:54
  • @adobe. Thanks for editing. – Claude Leibovici Jan 01 '14 at 16:50
  • @ClaudeLeibovici You're very welcome! ;-) –  Jan 01 '14 at 16:57
0

I know you didn't ask, but I just have to tell you:

$$f(x)=\sum_0^n(2x)^k=\frac{(2x)^n-1}{2x-1}\iff f'(x)=\sum_0^n2^k(k\cdot x^{k-1})=\left[\frac{(2x)^n-1}{2x-1}\right]'_x=\ldots$$

Your sum is $f'(1)$. Now, I'll take it that your res{ult} is a natural number, right ? In that case, first subtract $2$ from it, then factor the difference, and try to see which of its divisors is a power of $2$. :-)

Lucian
  • 48,334
  • 2
  • 83
  • 154
  • I edited question there is a problem with 2^(n+1) not 2^(n)+1 – Madan Ram Dec 31 '13 at 04:13
  • ex 10=res and n=2 that is the length of number after 2..... (0,1) of length 1,(00,01,10,11) of length 2 where 0->1,1->2,0->3,0->4,0->5,1->6,1->7,0->8,1->9,1->10,..... – Madan Ram Dec 31 '13 at 04:25