2

When I'm reading Computer Systems: A Programmer's Perspective, I met the sum of binary numbers and failed to prove it:

$$ 2^0 + 2^1 + 2^2 + 2^3 + \cdots + 2^n = 2^{n+1} - 1 $$

This might be preliminary knowledge, I'm not good at mathematics, any body could give me a hint?

Nick
  • 135
  • 1
    Are you familiar with mathematical induction? – Theo C. Jul 18 '17 at 00:07
  • 3
    What do you get when you multiply the left-hand side by 2? – amd Jul 18 '17 at 00:10
  • Induction is the standard method, but the multiplication-trick is much more elegant. Additionally, it allows to find the value of the sum whereas induction only allows to verify it. – Peter Jul 18 '17 at 00:11
  • @D.Beec Not really. In my opinion, mathematical induction is just like try a small foundation, and test whether a further step is true. I'm also interested to know how this equation came out. – Nick Jul 18 '17 at 00:12
  • ._. You guys are very trigger happy to answer questions that appear very often and are easy. – Simply Beautiful Art Jul 18 '17 at 00:15
  • The trick that works for the more general sum $$S=1+q+q^2+\cdots+q^n$$ We have $$qS=q+q^2+\cdots +q^n+q^{n+1}$$ This immediately gives $$qS-S=q^{n+1}-1$$ Hence, we have $$S=\frac{q^{n+1}-1}{q-1}$$ if $q\ne 1$. In the case of $q=1$, we just have $S=n+1$ – Peter Jul 18 '17 at 00:16
  • 2
    So many answers. Do people have prepared answers on hand for common questions? –  Jul 18 '17 at 00:16
  • my problem is without answering common questions, I'd have no reputation at all I bet. at least without counting the two for changing tags again for potentially easy questions. I have posted 2 questions one got me told there's only one form a matrix multiplication the other went unanswered because it's about the lucas lehmer test. –  Jul 18 '17 at 00:35
  • @ChristianWoll Yes, so many answers in so short time. I could only mark one as the answer. Thank you all. – Nick Jul 18 '17 at 02:13

9 Answers9

7

Express each power $2^k$ in binary: you get one bit 1 and the rest is 0. When you sum these up, you get a number with all bits 1. Adding one to this number yields a number with one bit 1, thus a power of 2. Here is an example with $n=6$:

 0000001
 0000010
 0000100
 0001000
 0010000
 0100000
 1000000
--------
 1111111 = 10000000-1
       1
--------
10000000
lhf
  • 216,483
2

Since $1= 2-1$, you can multiply by $2-1$ and it won't change the value.

$$(2-1)(2^0+2^1+2^2+\cdots + 2^n) $$

$$=2(2^0+2^1+2^2+\cdots + 2^n) -1(2^0+2^1+2^2+\cdots + 2^n)$$

$$= (2^1+2^2+2^3+\cdots + 2^{n+1}) - (2^0+2^1+2^2+\cdots +2^n)$$

$$= 2^{n+1}-2^0.$$

2

$$\begin{array}{rcll} 2S & = & &&2 &+& 2^2& + &2^3& +& \cdots &+& 2^{n}&+&2^{n+1}\\ -S & = & -1 & - &2 & - &2^2 &-& 2^3 & -&\cdots& - &2^n\\\hline S & = & -1&+&&&&&&&&&&+&2^{n+1} \end{array}$$

Laars Helenius
  • 7,965
  • 1
  • 23
  • 35
1

To compute the sum $$ S = 1 + x + x^2 + \ldots + x^{N}, $$ first compute the expression $(1 - x) \: S$. On expanding it and collecting like terms, you will see that $$ (1 - x) \: S = 1 - x^{N+1}. $$ In your case, $x = 2$, but this works for all $x \neq 1$.

avs
  • 6,276
0

This is a geometric series with common ratio 2. A typical way to see how to sum is to call $$ s = 1+x+x^2+\cdot + x^n$$ then $$sx = x+x^2+x^3+\cdot +x^{n+1}$$ Subtracting we find $$ \begin{align} s-sx &= 1-x^{n+1} \\ s(1-x)&= 1-x^{n+1}\\ s& = \frac{1-x^{n+1}}{1-x} \end{align}$$

sharding4
  • 4,917
0

Notice $2^0=2^1-1$.

Then $2^0+2^1=2(2^1)-1=2^2-1$

Then $2^0+2^1+2^2=2(2^2)-1=2^3-1$.

We have $2^0+2^1+2^2...2^{n-1}=2(2^{n-1})-1=2^n-1$.

And to show the this holds for the $n+1$ case, notice that $(2^n-1)+2^n=2(2^n)-1=2^{n+1}-1$.

0

Exploiting the binary representation,

$$111\cdots111_2+1_2=1000\cdots000_2$$ because the carry propagates.

This is exactly

$$2^0+2^1+2^2+\cdots2^{n-2}+2^{n-1}+2^n+1=2^{n+1}.$$


The proof generalizes to other bases. Let $a:=b-1$, then

$$a\cdot111\cdots111_b+1_b= aaa\cdots aaa_b+1_b=1000\cdots000_b,$$ which is a rewrite of

$$(b-1)(b^0+b^1+b^2+\cdots b^{n-2}+b^{n-1}+b^n)+1=b^{n+1}$$ or

$$b^0+b^1+b^2+\cdots b^{n-2}+b^{n-1}+b^n=\frac{b^{n+1}-1}{b-1}.$$

0

You are going to walk a distance of one mile. You walk half the distance and rest. You then walk half the remaining distance and rest. Continue doing this.

So now we can write down everyone's favorite infinite series, $\frac{1}{2} +\frac{1}{4} +\frac{1}{8} +\frac{1}{16} + \dots = 1$

Multiply both sides by by $2^{n+1}$,
$2^{n} + 2^{n-1} + 2^{n-2} +...+2^2+2^1+2^0+\frac{1}{2} +\frac{1}{4} +\frac{1}{8} +\dots = 2^{n+1}$.
OR
$2^{n} + 2^{n-1} + 2^{n-2} +...+2^2+2^1+2^0+1 = 2^{n+1}$.
Subtracting $1$ from each side,
$2^{n} + 2^{n-1} + 2^{n-2} +...+2^2+2^1+2^0 = 2^{n+1}-1$.

CopyPasteIt
  • 11,366
0

You can also do the following. Let S denote the following sum

$S=2^0+2^1+2^2+...+2^n$ Multiply both sides of the equation by 2 and you will obtain the following:

$2S=2^1+2^2+...+2^n+2^{n+1}$

Subtract the first equation from the second one to get:

$S=2^{n+1}-2^0=2^{n+1}-1$ which is the desired equation. I really hope this helps!