Is there a shortcut for raising 2 to the power of a number (e.g. $2^{27}$)?

28.4k Views Asked by At

In networking, when dealing with subnetting, you convert the net mask to binary and count the number of ones (for the example in the question there would be $27$ $1$'s) and to figure out how many subnets that will make you raise $2$ since each digit only has two possibilities ($0$ and $1$). The professor told us to start off with the first digit saying the value and counting them that way, but it can get tedious with $27$ integers. I went to one of the math professors and he taught me (I may be incorrect with the name) The Russian Peasants Multiplication Algorithm, which is equally as tedious.

What I am asking is basically if a trick has been discovered to quickly and mentally (hopefully) raise to by any number?

5

There are 5 best solutions below

0
On BEST ANSWER

One unusual mental trick that can help with problems of the form bp is:

Step 1: Convert p to binary, drop the leftmost bit.
Step 2: Working from left to right, and starting with b, take each 0 to mean "square the current total", and each 1 to mean "square the current total and then multiply by b". Work through each of the binary digits until you have your answer.

This is a sort of generalized way of working with Lucian's approach.

Let's try this with 227.

27 in binary is 11011, and dropping the leftmost digit, we have 1011.

We start with a current total equal to the base, 2, and the leftmost 1 in 1011:

1 says "square current total, then multiply by 2". 2 squared is 4, and 4 × 2 = 8 (our new current total).

0 says "square current total". 8 squared is 64 (our new current total).

1 says "square current total, then multiply by 2". 64 squared is 4,096, and multiplying by 2 gives us 8,192.

1 says "square current total, then multiply by 2". (8,1922) × 2 isn't impossible to do in your head, but you do need to be familiar with (and have practied) techniques for squaring 4 digit numbers in your head.

Since you specifically asked for a way to do this mentally, I Hope you find this technique interesting.

EDIT: Looking over Lucian's post about 210 ≈ 103, here's another way you could approximate the answer:

Break the problem up into groups of 210, with the final term being 2x where x < 10 (if needed).

With 227, you'd think of that number as 210 × 210 × 27.

Next, replace the final power with its actual total. 27 = 128, so the problem is now 210 × 210 × 128.

Now you replace each 210 with 103. Our problem now becomes 103 × 103 × 128, or 128 × 106.

Compact that into scientific notation. 128 × 106 = 1.28 × 108.

You might leave that as your final estimation, or you could increase your accuracy, if desired.

103 + 2.4% = 210, and in our 227 example, we used that twice, so we need to add 2 × 2.4%, or 4.8% to adjust our estimate.

I'm a little weak on being able to do 4.8% of 1.28, but 4.8% of 1.3 is about the same. I can just multiply 48 × 13, and divide by 100 (to adjust for multiplying 4.8 and 1.3 each by 10) and 100 again (since 4.8 is actually a percent).

48 × 13 = (48 × 10) + (48 × 3) = 480 + 144 = 624. 624/10000 = 0.0624. Add that to 1.28 and we get about 1.34.

This means our best estimate should be about 1.34 × 108.

The actual answer to 2^27? 134,217,728, or 1.34217728 × 108.

0
On

What I am asking is basically if a trick has been discovered to quickly and mentally $($hopefully$)$ raise two by any number?

$$a\cdot a=a^2,\quad a^2\cdot a^2=a^4,\quad a^4\cdot a^4=a^8,\quad a^8\cdot a^8=a^{16},\quad a^{16}\cdot a^8\cdot a^2\cdot a=a^{27}$$

$\qquad$ You might also want to approximate at each turn, if $($great$)$ precision is not required.

$\qquad\qquad$ For the specific case $a=2,\quad2^{10}\simeq10^3$ might prove to be a helpful shortcut.

0
On

Yes, but its not just $2$, its actually any number. However, majority of people use base $10$ so it would be easiest to explain it like that.

Let's say we want to find $10^{17}$ Well that's easy. Just take a $1$ and follow it with $17$ $0$'s (A well known trick). So we would end up getting $100000000000000000$.

So at this point, its really easy to do for base $10$, but if we wanted to do a different number, say $5$, we need to use a different base: base $5$.

This time we instead of using (0,1,2,3,4,5,6,7,8,9), we will only use (0,1,2,3,4) to count. So here's how counting works: 1, 2, 3, 4, 10, 11, 12, 13, 14, 20 ... (21-30's range then)... 40, 41, 42, 43, 44, 100. And so on. Now the numbers are not removed, (that's why the number 17 still exists in this system), but each number is just re-written. $17$ would now be represented as $32$ because the 17th number in the new counting system looks like 32. This new method of representing numbers gives us a quick way of calculating $5^x$. For example $5^{13}$ would be a $1$ followed by $13$ zeros: $10000000000000_5$ (the $_5$ just we are using base $5$). So using representation of numbers, we can expand from 5 it into any integer (including 2).

So this property is great and all, however it has one flaw. Converting a base into a new base takes way more time than it does than to actually just calculate $2^x$ by multiplication. So this property is only useful if we are doing a lot of these types of calculations.

Now what's so specially about base 2? Well it only uses (0,1). Sound familiar? Yep computers use the base 2 representation of numbers, so when we need to compute $2^{11}$, a computer will write its as: $100000000000_2$. But the correct answer is $2^{11} = 2048$. And this brings back the flaw. Computers can use this property, but if a human (who uses base 10) ever wants to understand the correct answer, it must be converted. But the only way of converting from base 2 to 10 is to calculate $2^x$ anyway.

So, if the calculations were strictly done in a computer, then yes it would be faster, but because humans use the base 10 system, we need to convert it from base to base. However, we can still calculate $10^x$ very easily because we do use base 10.

Lastly there is one interesting property that @Lucian pointed out. It's called Exponentiation by squaring. And that's the easiest way to solve that if you aren't in base 2, but I'll let you read his post.

0
On

The Russian peasant method can be used to multiply or to exponentiate:

// Multiplication                 // Exponentiation
let x0 := x, y0 := y              let x0 := x, y0 := y
r := 0 ;                          r := 1
invariant y0*x0 = r + x*y         invariant y0^x0 = r * y^x
while x != 0                      while x != 0
    if x is odd                       if x is odd
        r := r + y                        r := r * y
        x := x-1                          x := x-1
    x := x / 2                        x := x / 2
    y := y * 2                        y := y ^ 2

On the right is the method mentioned by Lucien and Grey Matters. So there is nothing new here. But since the question mentioned Russian peasant multiplication, I thought I would tie their answers to Russian peasant multiplication.

0
On

Simple way to mentally estimate 2 to any power: $2^{10} \approx 1,000$ (actually 1,024). E.g., $2^{27} = 2^{20} \times 2^7 \approx 1,000^2 \times 128 = 128’000,000$. Real answer is 134 million - not bad for a mental estimate. You’ll always be a bit low because you estimate 1,024 as 1,000, but you’ll be close. The higher the power, the further off. Another way to think of it, separate your power into tens and ones. for every ten powers of 2, you add three zeros to a 1, then for the ones you just double the result that many times. E.g., $2^{13} = 1,000 \times 2 \times 2 \times 2 = 8,000$ E.g., $2^{32} = 1,000’000,000 \times 2 \times 2 = 4$ billion