Pages

Showing posts with label exponents. Show all posts
Showing posts with label exponents. Show all posts

Saturday, April 6, 2013

How big a number is 400!





The other day I was teaching permutations to my Algebra 2 students, and casually asked how many different arrangements are there for our whole school body to be placed for a picture. I don't know the exact number, but I typically use 400 for estimates (yes -- I make enough estimates for our school that I have a "typical"). I knew immediately that the answer was 400! (which is 400*399*398*...*3*2*1 for those of you who have never seen the ! notation before).

My problem was that I had no concept of just how big 400! really was.  How many digits long is that number?

My initial thinking was to simply type it in the calculator, but it was too big for my TI-84 to handle.  That meant it was more than 100 digits long -- but is it more than 400 digits long? 1000 digits?  How can I answer this?

Eventually I think logarithms will be the answer, but for now let's see if we can set some upper and lower limits on things.  Since each of the digits in the multiplication from 400 down to 1 is less than 3 digits long, then the whole product must be less than 400*3 or 1200 digits long.  Since most of the digits are 2 or more digits long, it's safe to assume it must be more than 400 digits long, but just how many are there?

More formally:
   400! = 400*399*398*...*3*2*1 < 1000*1000*1000...  = 1000^400 = (10^3)^400 = 10^1200
   400! = 400*399*398*...*12*11*10! > 10*10*10*...*10*10*10! = (10^390)*10!

Now logarithms are a tool our PreCalc students will be tackling this next week, and could be used to answer this question, and it all hinges on the product - sum property of logarithms:
log_{10}X+log_{10}Y=log_{10}XY
A factorial is simply a lot of multiplications, which would translate into a giant sum of lots of logarithms:

That can be summarized (pun intended...) as:
This gives me something that my calculator CAN handle -- since instead of actually trying to display the number, it simply gives me the magnitude of the number. This can be typed into a TI-84 by typing:
  sum(seq(log(N),N,1,400)) = 868.8 
This means the number 400! is equal to 10^868.8 and is therefore 869 digits long.

A quick check on wolfram alpha verifies this:
(I'm sure some of you were asking "Why didn't he just do that in the first place?" to which I simply respond "Because I didn't have to! God gave me a brain and problem solving skills for a reason!")

As a follow up question -- can I predict how many zeroes are at the end of that number?  In factorials, zeroes come after every multiple of 5.  (Technically, I would need multiples of 2 as well, but there are plenty of those, and relatively fewer multiples of 5).  

Up to 4! there are no zeroes:
  1, 2, 6, 24, 
Between 5! and 9! there is 1 zero:
  120, 720, 5040, 40320, 362880
Between 10! and 14! there are 2 zeroes:
  3628800, 39916800, 479001600, 6227020800, 87178291200
After that my calculator can't display them properly, but I hope you'll anticipate the pattern.

400 is the 400/5 80th multiple of 5, and so 400! is the first factorial to have 80 zeroes at the end of it.  A not-so-quick check on Wolfram Alpha's picture reveals that there are actually 33*3 or 99 zeroes.  Extras!?

That's because there are more multiples of 5 -- 25, 50, 75, ... 400 each contain 2 factors of 5, and 125, 250, 375 each contain three.  Counting these all up should reveal 99 factors of 5 (and way more factors of 2):
  80 Multiples of 5: (5, 10, 15, ..., 390, 395, 400)
  16 Multiples of 25: (25, 50, 75, ... 350, 375, 400)
  3 Multiples of 125: (125, 250, 375)
  99 total factors of 5 therefore 99 zeroes.

And for completeness (since I kept claiming there were way more factors of 2 than 5).
  200 Multiples of 2
  100 Multiples of 4
  50 Multiples of 8
  25 Multiples of 16
  12 Multiples of 32
   6 Multiples of 64
   3 Multiples of 128
   1 Multiple of 256:
  397 Total factors of 2.

What this means is that the prime factorization of 400! contains (among other things) 2^397 and 5^99.
What's the largest prime in 400! is a question for a different night. (Oh, what the heck, why not:)



Wednesday, February 27, 2013

Are you smarter than a calculator?

Lately, I have been noticing how dumb our calculators are. It's become kind of a running theme in my classes, where I've been teaching how to use different graphing tools, and I say several times a week "and remember, you have to be smarter than your calculator" or "you have to help your calculator..."

The calculator doesn't think like humans. God created us--not calculators--in his image, and I believe one aspect of that is the ability we have to reason, to notice patterns, to create, to organize, to see. These are all things that calculators, and in general computers or machines, are all pretty bad at. They are improving, because our minds are helping to generate better and better machinery, but they still don't work like humans.

Perhaps the best example of this is the Captcha messages at the bottom of so many websites. Computers and bots are still horrible at "seeing" things. Most humans can interpret those pictures and type letters or numbers properly, but that relatively simple operation is difficult for most computers. That's because we think about the problems entirely differently.

Likewise, our calculators think about calculations entirely differently than us. We can think algebraically and manipulate symbols, variables, and even numbers in symbolic ways that allows us to simplify problems, or calculate values exactly. Most calculators don't think in that way at all, but are programmed with different algorithms that work with really precise approximations and quick calculations. Even the slowest earliest calculators can do this sort of thing faster than all but the freakest of humans -- but I haven't seen any calculators that are good at playing What's the Word.

Here's a bullet list of items that I've noticed lately:
  • In PreCalc we've been studying complex numbers. One assignment the other day was to calculate i17 which is easy to calculate by recognizing a pattern.  i, i5, i9, i13, and i17 are all equal to the purely imaginary number i, but the calculator spit out -1E-13 + i.  Yes, the -1E-13 is a ridiculously small number, close to zero, but it shouldn't be there AT ALL! What strange algorithm does the calculator use to calculate that instead of just recognizing the pattern like humans?
  • Similarly, some versions of the calculator were not able to convert some of our operations involving complex numbers into exact fraction form -- where as we could. Some calculated approximations (admittedly better approximations than we could find in anything short of five/ten minutes) but several others gave an ERR: data type message instead
  • In Algebra 2, we gave been using the calculator to calculate summations, and the notation for summations is sum(seq(function,VAR,start,end)) and we have been laughing at the fact that even though our functions only have one letter in them, we still need to write that variable again. I understand you could certainly have many variables in a function and then you'd have to specify which one is the index -- but when there's only one, you'd think the calculator would be able to figure that out.
  • In Algebra 1 we've been graphing systems of equations, and numerous stupid calculator quirks have popped up. Though we set the word problems up with sensible variables like N for the number of nickels and D for the number of dimes, when we went to graph things, we had to use the letters X and Y. Again, you could maybe give your calculator the benefit of the doubt because maybe those letters are going to be used for constants (like I do in physics storing 6.67E-11 in for G) but...
  • Then we try to calculate the intersection of two lines and we have to tell it which lines we're interested in and help guide it towards the solution. Seriously?! There's only two lines on the screen! And they're lines! Not curves!  
  • If the intersection isn't on the visible window screen, the calculator won't be able to find it for you -- you need to realize that those lines will intersect above, left, right, etc. of the screen and adjust the window yourselves.
  • And what's with providing the answer as 1.999946 when it's clearly and exactly 2?  The algorithm that calculates the intersection necessarily has limits to its precision, and sometimes those fall short. My students better not ever report an answer of x=1.999946 to me.
  • To be fair, let's pick on non-TI84 calculators -- one of my newfound favorites is the app MyScript Calculator which interprets my handwriting and calculates things for me.  I'll admit, I played with it for a good 30 minutes after downloading it -- only true math nerds play with their calculators right?  But I noticed pretty quickly that it's trig values didn't always calculate properly, which was a bug that their updated version supposedly has fixed. I knew that because I knew the limits of sine and cosine values, and even had several memorized -- and also can estimate relatively well and had ideas of what the answers should be ahead of time.

Thursday, January 3, 2013

Exponential Growth in Settlers of Catan

Our family loves playing Settler's of Catan. Settler's is board game where you must collect resources (wood, wheat, ore, sheep, and brick) in order to build different things (settlements, roads, cities, knights, ships, etc). The resources you collect each turn depends on how much you have built, and where you have built, and the roll of a dice. If you have built next to certain numbered tiles, then you collect those resources when that number is rolled. As you expand, you touch more numbered tiles and collect greater resources.

Mathematically, this means that the number of resources you collect as the game progresses follows an exponential curve, shown to the below.  This is a very common curve for growth, and is especially common in places where how much you grow depends on how much you have.  Other common places of exponential growth is financial (interest on money grows depending on how much you have invested) and populations (the more people or animals there are, the more they are making babies).

This exponential nature of the game suggests a very important strategy -- which I like to think of as "steepen the curve". The most important thing that you can do in the game is to increase your chances at collecting resources. Every time you do this, you increase the number of resources you're likely to obtain until your next turn, making your next turn even more powerful than your last. Even though there may be quicker ways to earn points, like making a longer road for instance, do whatever it takes to get another settlement, or another city.

Setting up the game, you start off with a settlement and a city, which allows you to touch or collect resources from up to six different numbered hexes. To begin, you need to build a road and a settlement faster than anyone else. This requires two wood, two brick, a wheat and a sheep. If you can collect these before any of your opponents, you have significantly increased your odds of winning. While I have not been nerdy enough to record these statistics during all the games I've played, I feel confident saying that more than half the times I've played and managed to build the first settlement, I've won.

To illustrate why, let me show a graph. On the x axis is the number of turns in a game, and on the y-axis I have graphed "Resource Cards Obtained". To begin, your six (or so) tiles probably have a collective rate of return of somewhere around 2/3 of a card per roll of the dice (more about this in a different post).  Starting out with 3 cards, this puts you and your opponents on the line y = 2/3x + 3.  This suggests it would take you about 6 dice rolls before you'll have enough cards (actually 7, one more than enough) to buy a settlement. That is point A on the graph. If you are able to buy a new settlement, this ought to increase your chances at collecting resources -- perhaps to around an average of 1 card per roll now. This is indicated by the steeper line in the graph. Now you'll gain more resources, and reach the next pivotal point faster than your opponents.

The next chance you have to steepen your curve, do it. This will require either building another city (two wheat and three ore) or a settlement (two wood, two brick, a wheat and a sheep).  Either way, on average it will take another six rolls to obtain this.  I'll take a moment to illustrate the strategy of building a settlement/city as soon as I can. My assumption is that on average each new settlement will increase the slope of my resource gaining line by 1/3 of a card per dice roll. On average it will take 5 to 6 cards (granted, they have to be the right cards, but that's what trading is for) to earn a chance to build. Within 6 more rolls I can probably build again, and then it only takes about 4 to build again, and then only about 3.  With each successive build, the number of rolls before I can build again goes down on average. This produces the steepening set of lines drawn to the right. Taken as a whole, this looks very similar to the exponential curve shown earlier -- even though it's a series of lines.

Why is this strategy so important?  Let me illustrate with a simple choice, early on in the game. There is a rule that says you must build your first settlement two roads away. Suppose instead you decide to take time to build three roads away -- figuring it will help you to branch out a little first. This will likely take an additional 3 rolls at the beginning of the game, because you only average 2 cards per 3 rolls early on. This seemingly insignificant choice actually puts you significantly behind.  If you now change strategies and try to build as aggressively as your opponent did from the get-go, you'll find yourself just falling further and further behind. In this final graph - the red curve shows aggressive building from the beginning and the black curve growth delayed by just one choice - waiting to build a settlement after an extra road. Notice how the two curves are getting further and further spread out as the game progresses.


Now I'll admit this is a simplified graph - and there are times where building farther away might be advantageous. For example, maybe building in one location over another allows you to create a much steeper rate of return than another location -- but in the grand scheme of things, it would have to be perhaps twice as good to make up for the extra turn it takes to build there.  If it only causes you to touch a 6 instead of 5 -- it's probably not going to catch up with someone who has already built and started walking along the red curve.

It also suggests making efforts to obtain the important cards that cause you to build quickly. Wood and bricks (to make roads and settlements) are crucial at the beginning -- the others can be obtained in time, which you'll have if you are able to build a settlement first and always be on a steeper curve than your opponents.

Friday, December 28, 2012

Storage Capabilities of the 8.5x11


A former student of mine had an instagram that inspired a dorky series of tweets between the two of us touting the features of this amazing new technology: the sheet of paper. I was trying to be sarcastic because I hadn't seen a sheet of paper in so long, writing all my essays and lesson plans and everything digitally.

The series of tweets:
The sad tale of an engineer attempting to write an essay. 
 what is that thin white note taking device in front of your laptop? Is that a new Christmas present? Wireless? Bluetooth?
 It's the newest in pressed wood pulp. Functions without a processor and get's great battery life!
 what kinda storage? 200Gb?
 college ruled, 56 lines, expandable to margins. Also compatible with multi-ring long-term storage devices.
 wow 56 lines! I was only familiar with older 33 line models.

Anyway, taking it a step too far I'm sure, I decided to investigate the storage capabilities of a simple sheet of paper. To begin, I found a sheet of paper -- though it took a while. I also had to find a stylus that was compatible with the paper -- after a handful of failed attempts, I found one with enough battery left (you can always count on Sharpie models!) to input text:

I counted the number of characters on each line, including spaces and punctuation.  I found 63, 62, and 65 characters on each line, and so I'm going to average them and suggest that a typical line stores 64 bytes. I'm thrilled this is a power of 2 -- it makes me confident that it's technology, because everything else in technology comes in powers of two.  Let me save that number in memory as 2^6.

After counting the number of available rows, I found another convenient power of 2, or 32 lines.  2^5.

Multiplying these numbers together, I get 2^11 bytes, or 2*(2^10).  2^10 is 1 KB, and so one side of one sheet of paper is 2KB. Utilizing both sides of every sheet of paper yields the following storage capabilities for the following standard models:

70 sheet 1 subject sprial notebook:  280 KB
100 sheet looseleaf unbound package: 400 KB
500 sheet ream of paper: 2 MB

Of course, using different fonts and font sizes could significantly increase or decrease storage capabilities.    

Friday, June 22, 2012

153

In John 21, John recalls a time when they were fishing, and Jesus asked them to throw their nets on the other side of the boat, and when they obeyed they were unable to haul the nets in. This was the second time this had happened, one of the times Jesus appeared to the disciples after his resurrection.

I always loved the little detail John throws in verse 11: there were 153 fish.

That particular number always seemed a little odd to me. (yes, pun intended... you can stop laughing and start reading again anytime...)

Besides being odd, 153 has a lot of other interesting properties, and the one I want to describe is a remarkable fact that 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153.  How remarkable is that?! When you cube the digits of a number, and add them up, you get the same number back! Now, does that always happen? That is, when you do this little operation--I'm going to call it a "cubic sum"-- do you always get your number back?

That's easy enough to check -- lets find the "cubic sum" of 972.
    9^3 = 729
    7^3 = 343
 + 2^3 = 8
    1080

Nope. In fact, 153 is one of very few numbers that equals the "cubic sum" of its digits. Wikipedia calls that a "Narcissistic Number" but I call it cool. The only other numbers with that property (for cubes at least) are 0, 1, 307, 371, and 407.  Lets check 371 a second:
    3^3 = 27
    7^3 = 343
 + 1^3 = 1
    371

Now if that was all that I knew on the topic, that would be cool enough, and your day would be better for having read it, but there's one more fact about 153 and these "cubic sums" that needs to be told.  Lets go back to our first effort of 972.  When we found its cubic sum, it gave us 1080, and we were bummed that we didn't get what we were hoping for. Lets find 1080's cubic sum:
    1^3 = 1
    0^3 = 0
    8^3 = 512
+  0^3 = 0
    513
So what?  Well, let's keep going... find the cubic sum of 513 and you get ... drum roll please ... 153!  I have a feeling that's why these numbers are called narcissistic -- because this process often leads back to themselves, even when starting with other numbers!

Now, not every number chosen at random leads to 153, here's a chain I found that leads to 370, having started with the number 259.

259 --> 862 --> 736 --> 586 --> 853 --> 664 --> 496 --> 1009 --> 730 --> 370 --> 370 ...

Some chains lead to 371 instead, like:
 524 --> 197 --> 1073 --> 371.

In fact, most of the numbers I initially tried went to 371 -- perhaps its even more narcissistic than 153?    Actually, I was just unlucky in the numbers I tried -- because every multiple of 3 will cycle around to 153. I had forgotten that fact... Try 51 = 17*3  and you'll find:
  51 --> 126 --> 225 --> 141 --> 66 --> 432
    --> 99 --> 1458 --> 702 --> 351 --> 153 




I know its even possible to create a loop of numbers that just cycle among themselves, like a clique one such clique of numbers is 133 --> 55 --> 250 --> 133 ...

Saturday, June 16, 2012

... is 3

Yesterday's puzzle was "What is the last digit of 3^2153?"  Today I'll show a technique for answering the question.

The simplest approach is to simply get out the calculator and type in 3^2153 and see what the last digit is. Unfortunately, my calculator isn't powerful enough to answer that question, giving me the screenshot off to the side. The reason for this is that my calculator, (which is the same TI 83 or TI 84 that most of my students have access to) is only capable of working with numbers that have less than 100 digits. Worse, it will only display approximately 10 of those digits (though there are tricks you can use to display a few more!).

Just how many digits does this number have anyway?  When asking that question, the tool to use is the log function. Typing log(3^2153) would hypothetically give you the answer (you'll have to round up to the nearest whole number) but even that is impossibly big for the calculator. I can use a property of logarithms to rewrite it as 2153* log (3) which is calculable:  . Practically, this means that the number 3*2153 has 1028 digits in it, and I'm interested in just the last one.  Interestingly, this subquestion of how many digits a huge number has been able to be answered for far longer than we have had calculators, by using log tables, but that's an entirely different story.

Back to the question at hand.  If we aren't going to just cheat and look at all the digits of a supercalculator, how can we answer the question?  Someone always suggests just multiplying it out by hand. As ridiculous as that would be (simply multiplying the last step would probably take 5 minutes, and that's after getting there in the first place!) the approach actually reveals something very important that can apply, so lets try it.
The numbers are already getting pretty big, but the final digit of each is all that's important to this discussion, and if you pay attention, you'll notice that there is a definite pattern to those digits. The last digits are 3, 9, 77, 1, 3, 9, 7, 1, and so on. This pattern will continue up long past the ability of our calculators (or pencils and papers) to handle, and all that is necessary to answer the question is where in this sequence of numbers 3^2153 falls.

Notice, this cycle of numbers repeats every four digits. Specifically, every multiple of four (3^4, 3^8, and 3^12) ends in a 1.  The closest power of four to 2153 is 2152, and so:
And so we have it -- 3^2153 ends in a 3.

I encourage you to try to answer the rest of these questions, which can all be answered using similar techniques:
     Last digit of 2^2153
     Last digit of 4^2153
     Last digit of 5^2153
     Last digit of 6^2153
     Last digit of 7^2153
     Last digit of 8^2153
     Last digit of 9^2153
Related Posts Plugin for WordPress, Blogger...