Monday, December 30, 2013

Casting Out Mathematical Demons

Casting Out Mathematical Demons

By Bobby Neal Winters
The other day on his Word of the Day blog, Anthony Esolen made reference to the divisibility test for 9 and 3.  The basic idea is this: take the base 10 expression of a number and add up its digits.  That is called the digit sum/ mathematicians don’t waste their imagination on names for things.  If the digit sum is divisible by 9 (or by 3) then the original number was.  
For example, 5643 is divisible by 9 because 5+6+4+3 is 18 and 18 is divisible by 9.  If you aren’t good enough at arithmetic to know that 18 is divisible by 9, note that 1+8=9.  If you don’t know that 9 is divisible by 9, then I can’t help you.  
There is a name for this beyond the Division Test for Divisibility by 9.  It’s called Casting Out Nines.  The reason for this name might become apparent after you’ve done a lot of testing.  Say that you have a number 9954968 and you want to determine whether 9 divides it.  You only need to calculate 5+4+6+8 because those 9s will not add any information and will only add complication to the addition,  so you cast them out.  Indeed, as that 5+4 is a pat 9, you can leave them out too and only worry about the 6+8=17 which is not divisible by 9.
This test is so good we sometimes there are other division tests.  
  • The number 5 divides a number only if the last digit is 0 or 5;
  • the number 2 divides a number only if the last digit is even;
  • the number 4 divides a number only if the the number that is last two digits are divisible by 4;
  • the number 8 divides a number only if the number that is the last three digits are divisible by 8;
  • the number 6 divides a number that number is divisible by 3 and 2; see the tests above
This takes care of all of the numbers from 2 to 9 with the exception of 7; this demon 7 became a mystery to me until I become math major and was given the keys to the priesthood.  I am now going to share those with you because I don’t think you will believe me, and if you do believe me, you will just forget about it anyway.  
I dare you to believe me. I double dog dare you.
Okay, take the number you want to divide by and call it d and take the number you want to test and call it T. I’ve lost a bunch of people right there because I’ve used variables. Tough.  When you divide T by d you get a remainder r.  The number T is divisible by d exactly when r is 0. I’ve not said anything now that ought to surprize you.  This process is called reducing modulo d. Forget that bit I said about not wasting imagination on names.
The surprize comes next.  You can reduce modulo d in an amazingly simple way. It is called modular arithmetic.
Let’s go back to our first example.  Is 5543 divisible by 9?  Well, 5643= 5x1000+6x100+4x10+3.  Take every term and factor of this an replace it with its remainder when divided by 9.  It is easy in this case because the 5, the 6, the 4, and the 3 don’t change and the 1000, the 100, the 10, and the 1 are all 1.  So 5x1000+6x100+4x10+3=5x1+6x1+4x1+3x1 which is exactly what we had done before.
Now consider the test for divisibility by 4 which only uses the last two digits of a number.  Why?  Well consider that the third digit will be multiplied by 100, the fourth by 1000, the fifth by 10000, and so on.  Each of these number is evenly divisible by 4 and so leaves a remainder of 0. So 5643= 5x1000+6x100+4x10+3 reduces to 5x0+6x0+4x10+3=43. Here, I am not using the full power of the technique for the sake of demonstrating the classical test.  The 4x10+ 3 would reduce to 4x2+3=11 which would reduce to 3.
You can see how the test for 5 would work out neatly as well because all powers of 10 leave a remainder of 0 when divided by 5.
Let me now go though a more complicated example to show you the full power.  Is 5643 divisible by 7?  I don’t know of any classical test for this. If you do, let me know.  Note that 10 divided by 7 leaves a remainder of 3;  then 100=10x10 will leave the same remainder as 3x3=9 which is 2; so 1000=100x10 will leave the same remainder as 2x3=6, i.e. 6. So 5643=5x1000+6x100+4x10+3 reduces to 5x6+6x2+4x3+3=30+12+12+3 which reduces to 2+5+5+3 which reduces to 5+3 which reduces to 1.  
Therefore 5643 is not divisible by 7, and, indeed, leaves a remainder of 1.   A very short calculation on a calculator will confirm this.
If you have a number like 75867 you can forget about the 7s and reduce it to 5860 which will reduce to 5160 which will reduce to 5x1000+ 100+6x10 which reduces to 5x6+2+ 6x3 which reduces to 2+2+4 which again reduces to 1.  
While I find this to be a very entertaining activity, there does come a point where simply dividing by 7 by hand becomes easier and I suspect that is why this is not taught to mere mortals.

Thursday, November 21, 2013

Long Division

Long Division
By Bobby Neal Winters
Long division is hard.  I want to state that up front. I remember when I first encountered it in grade school that it hurt my head.  There were a lot of rules and you had to be able to know your multiplication tables and guess and try and guess again. I learned how to act pitiful to get my mother to do it for me.
More than forty years later, I will admit that it’s a useful technique.  Let’s talk about long division long enough to get into trouble. Consider the easiest case: dividing a number by a smaller number.  For example, 7 divided by 2.
Two time three is six is the largest multiple of two that is less than seven, so we put down a 3 on the top line and subtract 6 from this leaves 1.   When you are a little kid who doesn’t know about decimals, you stop there and say there is a remainder of 1, but when you know about decimals, you put a decimal point after the 3 on the top line and you put a 0 down after the one to make it ten.  Two times five is ten exactly, so you put down a 5 after the decimal and stop.  This yields that 7/2=3.5, which, of course, is the correct answer.  You can always check your answer--but our students never do--by multiplying 3.5 by 2 to get 7.  
This is the easy case not because we are dividing a bigger number by a smaller number, but because the process terminates after a finite number of steps.  Consider a case that doesn’t like two divided by seven.  This is illustrated below:

Note that since seven is larger than two, we have to put down a 0 followed by a decimal on the top line. We then put zero times seven on the line below 2 getting--surprise, surprise--0.  We then take zero from two and put down 2 on the next line.  We put a 0 by it to make it twenty.  We then note that seven times two is fourteen so we put 14 below the 20.  Taking fourteen from twenty leave six, so we put down 6 on the next line and follow it by a 0 to make sixty.  Now seven times eight is fifty-six, so we put 56 below the 60.
You know the drill.  This will literally go on forever.  But before too long this will begin to repeat so that we get 2/7 is equal to 0.285714285714285714285714... .
This works nicely because we have a place-value system to represent numbers.
Mathematicians are never satisfied with just numbers, however.  We like to use letters too.  We work with entities (I almost wrote things there.  Things is sloppy writing, so I used entities there instead.  It means things, by the way.) called polynomials.  If you’ve had an algebra class you’ve seen something like 2+x or 2-x-x2.  You can divide on of these by the other two.  For example, let’s divide 2-x-x2 by 2+x:

I was tempted to explain this division. Indeed I wrote a paragraph of it, but I lost consciousness in the process.  If you’ve had the course, you can do it, but if not, I am not going to abuse your good nature by teaching it here.  Let it be sufficient to say that we go through the same motions as we do when we do the long division of numbers.
Just as in the case of long division of numbers, we can have non terminating cases here too.  Consider 2+x divided 2-x-x2:

Here the final quotient is the infinite series 1+x+x2+x3+x4+... .  This might ring a bell for some of you because not only is it 2+x divided by 2-x-x2 it is also 1/(1-x).  As PeeWee Herman used to say, “I meant that to happen.”
The equation 1/(1-x)=1+x+x2+x3+x4+... is quite famous among math geeks.  It is called the Geometric Series.  I can literally talk for hours about this.  My students will testify to this, as will the piles of legs in the classroom which my students have gnawed off like coyotes in futile attempts at escape.
You can have a lot of fun with this equation.  Let x=0.5.  The left hand side, i.e. 1/(1-x), becomes 2 while the right hand side becomes 1+0.5+ (0.5)2+ (0.5)3+... .  If you add enough terms of that right hand side, you get as close to the sum of 2 as you desire.  
If you let x=1, then the left hand side becomes 1/0 by zero while the right hand side becomes 1+1+1+.... which is infinity.  If you make yourself believe that 1/0 is equal to infinity, then this is not a problem.  Let’s push it further, though.  Let x=-1.  Then the left hand side is equal to 1/2.  The right hand side, however, becomes 1-1+1-1+1-1+.... . Let’s refer to this right hand side as S.  It is possible to argue that S is equal to zero; it is possible to argue that S is equal to one.  All of the arguments make the assumption that you can treat arithmetic operations done an infinite number of times the same way you can those done a finite number of times.
What happened to resolve this is a good example of how mathematicians operate.  We have a formula here that gives good answers in certain circumstances and nonsense in others; we determine exactly what those conditions are.  In this case, we get good answers exactly when the absolute value of x is less than one and nonsense at all other times.  There is a whole language created to talk about it using words like convergent and divergent and the Greek letters epsilon and delta.
So we began with a method for dividing one number by another.  We then extend that method to polynomials.  This led to an infinite series where work had to be done to delineate what could be said.  It would appear to be the end of the matter.  Yet.
Given the theory developed to talk about convergence,  the idea that the series S=1-1+1-1+... might be equal to anything appears to be nonsense, but consider the calculation below.  It is like a twisted coda at the end of a horror movie, Jason lives:

What was it that Scotty said, “If one man calls you an ass, pay him no mind. If two men do, buy a saddle.”
One can talk about Cesaro sums. These are like running averages of series.  The Cesaro sum of S is 1/2.
Let’s go back to the equation 1/(1-x)=1+x+x2+x3+x4+... .  Those who know a little calculus will recognize that taking the derivative of each side will yield 1/(1-x)2=1+2x+3x2+4x3+... .
Putting in x=0.5 makes the left hand side equal to 4 and the right hand side 1+2(0.5)+3(0.5)2+4(0.5)3+... can be made as close to 4 as we desire. This is all good.  It becomes more interested when we let x=-1.  Then the left hand side becomes 1/4 and the right hand side becomes 1-2+3-4+5-... .
But this can be made meaningful as well.  There is a theory of divergent series that has been worked out.  It is not my point here to expound on it--though if I learn any more I might--but to bring it up as an example of what mathematics sometimes do.
We take a technique in one area where it is clearly defined and makes sense and then apply it--sometimes playfully--in another area, where sometimes we get a mixture of good results and nonsense.  We then perform investigations to separate the good results from the nonsense.

It’s not a bad way of doing business.

Tuesday, July 23, 2013

M&M Epilog: Sex-Sex-Sex

I've commented from the time to time that the standard deviation is the problem child of statistics because, relative to what introductory statistic students have done before, it is calculationally intense.

Its calculation can be simplified if we make a study of the quantity that I called "Fred" in one of the earlier entries.  It is also sometimes called the second moment of x and referred to by S subscript xx.  When I say this aloud, it sounds like "sex, sex, sex."  That might make it more amusing to you, but it might create strange associations with math for you. It might be best not to think on this too much.

Below I've worked out the calculations that simplify Sxx.  If you are geeky enough to want to see how it's done, you are probably geeky enough to follow them.  If not, let me know.

M&M Activity: Part 4

For this, we will again return to the data from the first table:
This time we are interested in the variation of the total number of M&Ms in each bag.  This is given in the row along the bottom. In order to find the average, we could simply take the total 177 and divide by 10 to get 17.7, but we will need the standard deviation too, and we will be doing something more complicated later. Therefore, we need to be a little more sophisticated.

Notice that in his table only four different values appear: 16,17,18, and 19.  I've made e frequency table with columns for x, f, x-squared, f times x, and f times x-squared:
It is comforting that the sum of the f times x column comes to 177 because that is what is was when I added it in the usual way. In my calculations at the bottom of the page, I get a value of x-bar=17.7 as before and I get a value of s=1.1 for the sample standard deviation.  The calculations all follow the same principals as for the single color.

Your answers for x-bar and s should be similar to what got.  If you've followed my directions, you should all have a sample size of exactly 10.  This is a small sample.  When we learn more about taking samples, it will be shown that a sample size of 30 or more is to be desired.

However, there are several groups and each of you took a sample of 10 that means if you pooled your samples you would have a much larger sample. But the candy is all eaten now and it would be a lot of work to do this all again. If only there were some easy way.....

Well, in fact, there is an easy way.  The groups will now share their data with each other.  Let me show you how this works by showing you an example with some faked data.

I used faked data rather than run the experience 5 more times.  When I faked the data, I fiddled around with the frequencies in a table similar to the one above and obtained values of the sum of the f column, the sum of the f times x column, and the sum of the f times x-squared column form each.  I put the results in the table on the sheet below:
I am being careful to tell you this is faked data because (1) we must practice intellectual honesty and (2) I don't want the M&Ms folks going all commando on me.

Once the data is gathered, the calculations are simple.  The sum of the Sigma f column is 50.  There are 5 groups and each took a sample of 10, so the pooled sample is 50.

The sum of the Sigma f times x column is the sum of all of the f times x entries in all of the groups.  For this fake data, it is 875.  Similarly, the sum of the Sigma f times x-square column is equal to the sum of all of the entries in all of the tables.  With this fake data, it has a value of 15,412.

We calculate x-bar by dividing 875 by 50.  The sum of the pooled data by the total number of items in the pooled data.

Notice when we calculate "Fred," we give him a different name.  We use the variable Sxx.  When I say this out in class, it sounds like I'm saying "sex, sex, sex." 

Note that the n value is 50, so the n-1 value is 49.

Your assignment is two-fold:
  1. Do the calculations as described to calculate the sample mean and the sample standard deviation for the number of M&Ms in each bag.
  2. Share your data with the other groups; pool it; calculate the sample mean and the sample standard deviation from the pooled data.
Every group's answer on number 2 should be the same if every group does it correctly.  Each groups should make its own submission.

Monday, July 22, 2013

M&M Activity: Part 3

Let us now revisit the original table of data:
Notice that I've added a Totals column to the far right and a Total row to the bottom.   Other than those additions, the data is exactly the same as I've been using.

Look along each row labeled by color.  Notice that there is variation.  In the Red row, for example, the values vary from 1 on the low end up to 4 on the high end.  I've take this separated this data in the table below.

While there is variation, there is not all that much. We calculated in the last activity that the sample standard deviation is only 0.9 which is relatively small.  The range of the data (high minus low) is 3.  While there are rigorous techniques to justify this, it is not unreasonable to assume by just looking at it that each bag contains approximately the same proportion of red as any other.

We will now examine this assumption in more depth.

Notice that at the bottom of the Reds table, I've calculated a quantity that I've called Expected Proportion and have labeled it with the variable p-hat.  Note that p-hat is 17/177 which rounds off to 0.096.  This means that 9.6 percent of the M&Ms we counted are red.  The 17 is obtained as the total of the red row and the 177 is the total number of M&Ms.

The question we ask now, are 9.6 percent of the M&Ms in each bag red?  How do we figure that because, as you may have noticed from our first table, the number of M&Ms in each bag varies from 16 to 19?  Well, if a bag contains 16 M&Ms and 9.6 percent of them are red, then 16 times 0.096 of them (1.7) are red.  I've done this calculation in the table below:
  Compare each entry in the column labeled "Red" to the corresponding entry in the column labeled "Expected Red."  They don't differ too much, do they.

I've carried out this same activity for all of the colors. The results are below.  In carrying out the calculations for Red to three decimals, I noticed they weren't all that much different than using two decimals, so in the subsequent examples, I've only gone to two decimal places.
Take the data that your group gathered, and process it as I have above.
  • Make a table of your original data, adding a total column and a total row as I have. 
  • You will need a separate table for each color of M&M.  
  • You will need to calculate a value of p-hat corresponding to each color.  It is suggested that at least two people, working independently of each other, perform the calculations involved.
  • You will need to submit your data in electronic form.

Friday, July 19, 2013

M&M Activity: Part 2

We are now going to process the data you collected and tabulated in the first part of this assignment.  Recall my data was as follows:
We will begin with the first row, the red M&Ms.  We will be learning how to deal with data in a frequency table.  The first step is to put that data into a frequency table.  There are a variety of ways to do this, but I am going to do this first row by ordering the data and then counting it.

Look first at the top part of the page.  In the first column which is labeled "Raw data," I've simply listed the numbers in the same order as they occured in the original table.  In the column labeled "ordered data," I've listed from the smallest to the largest.  This makes them easier to count.

In the part of the page labeled "Frequency Table," I've set up a five column table with labels x, f, x2(x-squared), fx (f times x), and fx2 (f times x-squared).  In the x column, I put the possible values of x from the lowest that occurs to the highest.  There were 5 bags that contained only one M&M, there were 4 that contained 2, there were no bags that contained 3 (I could've left this row out if I wanted to), and there was one bag that contained 4 M&Ms.

So here f stands for frequency. 

In the x2 column, I've put the squares of the values from the x column.  It kind of makes sense, eh?

In the column labeled fx (f times x), I've put the product of the the value from the f column and the value from the x column: 5 times 1=5, 4 times 2= 8, 0 times 3=0, and 1 times 4 = 4.  I've done a similar thing with the column labeled fx2 (f times x-squared): 5 times 1=1, 4 times 4=16, 0 times 9=0, and 1 times 16 =16.

After filling in this table, I found the sums of the f, fx, and fx2 columns.  They are 10, 17, and 37, respectively. 

I knew before I started that--if I did everything right--the sum of the f column would be 10.  This is because we sampled 10 bags and the sum of the f has to be the sample size.

We can use the sum of the f column and the sum of the fx column to compute the sample mean, x-bar, which is 17/10=1.7.

We need the sum of the fx2 column to calculate the sample standard deviation.  As you may recall, the standard deviation is rather work intensive to calculate.  When you first learns how to calculate standard deviation, you first calculate the sample mean.  Then you put in a new column which consists of the difference between the value of the data item and the value of the sample mean. Then you put in a column which consists of the square of the previous column.  Then you add up that column.  Call the sum Fred (I just like the name) and divide that by the sample size minus 1. 

This is a lot of work just to get Fred. This is awkward as it requires you to calculate x-bar before hand.  However, there is a formula for Fred that removes the awkwardness.  This formula is hard to describe in typing, but I will give it a go. In your left hand, put the sum of the fx2 column.  In your right hand, put what you get when you divide the square of the sum of the fx column by the sum of the f column.  The left hand minus the right hand is Fred.

Don't worry, it's written out on the page above: 37-(17 squared)/10=8.1.  To get the sample standard deviation from this, we go to the next page:
The sample variance is Fred divided by sample size minus 1.  That is 8.1/9=0.90.  The sample standard deviation is the square root of the sample varience. This is 0.949..., but we round it off to one decimal place beyond the original data, making s=0.9.

I've done this for each of the colors of my data:
Your assignment is to take your data and go through this same process.  You will be working in groups, so I would suggest to organize your work in such a way as to have at least two people to independently do the calculations on each. 

The submission for each group may be organized as above.  In whatever way it is organized, it must include
  1. A table for each color of M&Ms with the five columns as above.
  2. A calculation of the sums of the f, fx, and fx2 columns.
  3. A calculation of x-bar (the sample mean) and of s (the sample standard deviation).

Thursday, July 11, 2013

M&M activity

To begin with each group will need the following;
  1. A sack of Fun-Size bags of M&M's.
  2. Small gummed labels.
  3. Sharpie/Felt tipped pen.
  4. Scissors.
  5. Notebook
  6. Pencil
  7. Smart phone with a camera.

(1) Your sack of Fun Size M&M bags should have at least 10 small bags of M&Ms.  You will need at least 10 little bags for this activity.
If you cannot find Plain M&Ms, Peanut will do.  Be mindful if anyone in your group has a peanut allergy though.  If you can't even find Peanut M&Ms, then some other candy will work.  I've had students use Skittles, but the colors are different and the distribution of colors is different.  When you begin the process, you will need ten bags of the same type of candy and each bag of that candy must have a variety of colors.

(2) You will need gummed labels and (3) a Sharpie to number those gummed labels.

you will be using these labels to label 10 of your M&M bags as below:
You could possibly get by with masking tape and a pencil.  This would make it more difficult for me to read the picture your are going to take of this to prove that your group actually did the work.

You will also need (4) scissors to open each bag as below:

Yes, you could just rip it open. (WHY are you being so difficult?) If you rip it open, you might get carried away and spill the bag.  I know how you are under high-pressure situations.

Once you open the bag, you are going to sort the M&Ms by color, count them, and note the number of each color on a piece of paper like this:

The numbers along the top of the page correspond to the numbers you labeled each of the bags with.  The colors to the color of the M&Ms.  The first bag contains 1 red, 5 orange, 3 yellow, 5 green, 2 blue, and 2 brown M&Ms. You can read this off of the column labeled with a 1 at the top.  This is why you need the (5) notebook and the (6) pencil.  Yes, you could carve it in clay with a stick if you like, but isn't this way easier.

I would advise you to wash your hands before you start counting because you are going to eat them afterwards and if you don't wash your hands first you might catch something, but this is up to you.

Oh, yes, this will need to be done in such a way to document that you did it as a group.  Using a smartphone with a camera would be the easiest way.  Some of you Facebook funerals, for Heaven's sake, so you ought to be able to come up with a smartphone among you or your friends.

Your complete assignment will be the data that you've collected and some documentation that provides evidence that everyone took part in some way. I leave this up to you.

Thursday, April 11, 2013

Mister E

Mister E

By Bobby Neal Winters
He was in an unpainted shack by the side of the road.  Above the entrance was a sign that proclaimed “LOANS.”  He sat behind a Dutch door with the top half open.  The bottom half was shut and topped with a small shelf that served in lieu of a desk.  Setting on it was a piece of wood that proclaimed his name: Mister E.
Mister E dressed in clean but faded overalls. His head was topped with a beat up felt hat.  His face was covered with a three-day growth of whiskers and somehow I knew regardless of when I saw him--be it Sunday morning or Saturday night--he would be sporting that three-day growth of whiskers.
Seeing the sign reading loan, I became aware that I had no money, so I decided to borrow some.
“I would like to borrow $100,” I said.
He shook his head back and forth.  Then he turned and spat into a spittoon.  I must confess I didn’t actually see the spittoon, but I heard something viscous hit brass. He then turned his head back to me and exposed tobacco-stained teeth as he began to speak.
“Nope,” he said. “No, sir. We don’t do it that way.  I only loan you a dollar at a time.”
Well, that was strange, but I didn’t have any money at all and borrowing a dollar would allow me to use a pay phone I saw.
Pay phone?  When was the last time I saw a pay phone? I must really be out in the boonies.
“Okay,” I said. “May I borrow one dollar?”
“Yes,” he said. “My business is loans, but before you borrow, you must agree to my terms of interest.”
“What is your interest rate?” I asked, a bit concerned.  I was out in the backwoods, afterall, where they have their own rules and the law is not always just a phone call away.
He spat again.
“It’s 100 percent per year.”
Ouch, I thought.  Well, it’s a good thing he only loans a dollar at a time.
“Okay,” I replied slowly.  I wanted to make sure we understood each other. “So if I borrow this dollar, in one year I will pay you back two?”
He smiled through his tobacco-stained teeth and spat again.  He could make it ring every time, my God!
“Not so fast,” he said.  “We got to compound the interest.”
He began fishing his tongue around in his mouth and gathering up tobacco which he then spat out into his spittoon.  It didn’t ring this time, rather there was a dull thud.
He reached into his pocket and pulled out a length of tobacco shaped like a rope.
He laid out the rope of tobacco on the counter in front of him and it was then I noticed there was a calculator and a pad of paper.
“You know how compound interest works don’t you?” he asked.  I do, but I could tell he wasn’t really asking.  I saw from the look in his eyes and the way his lips parted slightly to expose his ruined teeth that I wasn’t going to be spared a moment of his belabored explanation regardless of what I said.  As a consequence of this, I decided to do what I always do in these situations: Play dumb to minimize the pain.
“No,” I lied. “Why don’t you tell me?”
I regretted it the moment I said it because he smiled a hideous smile and then he began.
“Well, when you do simple interest for 100 percent on one dollar, you take the dollar you are loaned, and then to that 100 percent times that and that gives you 1+1=2. But why wait for the whole year to start paying interest?  You’ve got my money and I want to have it work for me.  Say I only want to wait half a year?”
As if to illustrate his point, he took a pocket knife that had made its way into his hand and cut the rope of tobacco in two.
“When I wait half a year, I can only ask for 50 percent on my money, so I’m owed the borrowed dollar, and then 50 percent of that dollar.  That is $1.50 for the first six months.  Then after the second six months, I am owed that $1.50 plus the interest on that which is 50 percent of that.”
He put his knife and tobacco down and picked up the pencil to write on the paper:
$1.50+ $1.50 x 0.5
“Now,” he said, “if you do a little al-gee-bree, you can make it pretty.”
He took his pencil and wrote:
$1.50+ $1.50 x 0.50 = 1.50 x 1+ 1.50 x 0.50
                             = 1.50 x (1+ 0.50)
“That is pretty,” I said in a vain attempt to escape. “Now..”
“You ain’t seen nothing yet,” he said. “Say I want to charge my interest every quarter.  Then I cut the hundred percent into four pieces.”
He again took his pocket knife and cut the tobacco rope into four pieces to illustrate.  At the end he folded his his knife and put a quarter of the rope into his mouth.
“One quarter of 100 percent is 25 percent.  After the first quarter, you owe your dollar plus 25 percent more.”
He wrote it out on his paper:
1+ 1 x 0.25
“Then in the second quarter, you owe that plus 25 percent on it.”
1 + 0.25+ (1 + 0.25) x0.25=(1+ 0.25) x(1+0.25)
“You see,” he said very proud. “You got that square there because you do it for 2 quarters.  If you do it for 3 quarters, you’d put a 3, and if you did it for 4 quarters, you’d use a 4.  So for a whole year it’s (1.25)4=2.441406.”
He showed the last by using his calculator.
“Now, I think you might see the pattern there,” he said. “If you compounded monthly, you would divide the hundred percent by 12, add that to one, and take the whole thing to the twelfth power. That would be 2.613035.”
His calculator verified this.
“There is a formula for this,” he said.  Then he wrote:
“The n is the number of times a year you compound. If you compounded every week, you’d divide the 100 percent by 52, add to one, and raise that to the 52nd power. That would give you 2.692597.”
Again his fingers danced over the calculator, and the number came up as he predicted.
“But if I only compound every week, you are robbing me.  If I compound every day, you divide the 100 percent by 365, add that to 1, and raise it to the 365 power. That’s 2.714569.
“But this is my money and every minute it’s gone from my hands it means I can’t loan it to someone else.  Now, there are 525,600 minutes in the year.”
I heard the soundtrack of Rent begin to play in the background.
“If I compounded interest every minute, then you would owe me $2.718279 for borrowing that one dollar.”
I was beginning to see that my playing dumb wasn’t going to get me anywhere and that his old dude would compound by the femtosecond if we didn’t cut to the chase, so I cut in.
“Yes, and notice how the numbers are getting closer together: 2, 2.25, 2.441406, 2.613035, 2.692597, 2.714569, and 2.718279.  These numbers are all converging toward a number that mathematicians call e.  Like pi it is transcendental.  Not only does it’s decimal expansion not repeat, but it is not the root of any polynomial with rational coefficients.”
I’d expected the old codger to be annoyed by my cutting him off, but I was wrong.  He just smiled.
“Yep, transcendental, that’s me,” he said.
He popped another chaw of tobacco into his mouth and snapped his fingers.  With that snap of his fingers everything began to face.  The house disappeared first.  Then the calculator and pencil.  
And then him, with those disgusting teeth absolutely last.
The only thing left was a puddle of tobacco juice where the spittoon had been.

Friday, February 15, 2013

The Black Box

The Black Box

By Bobby Neal Winters

Part 1; The Big Dance

It had been one of those evenings.  I’d sat down at my desk to write a C++ program. I did this because I am trying to convince myself that I can still learn, can still use my mathematical skills to solve problems.  Writing computer programs is a good way to exercise that particular demon, at least for a while.  
Computers don’t care about your feelings.  They don’t want anything from you.  With computers it is either right or wrong, yes or no, 1 or 0.  There is no maybe, kinda sorta.  This goes a long way to explaining why math and science types are they way they are, but I digress.
After an evening of this quasi-mathematical activity, I went to bed with the TV on and set to go to sleep after about a half-hour.  I almost said after about a half hour, but it is run by a computer.  There is no about a half hour.  It either is or it isn’t.
There was a movie on the TV.  I forget which one exactly.  (I am not a computer.) But it was a cowboy movie and a musical kind of like Oklahoma! but a different one.  I remember nothing beyond that because I drifted off into sleep and in my sleep, I dreamed.
In my dream, I was high above the world over a flat plain and it was night.  Before me upon the plain--which was green but not the green associated with grass--was a rectangular black barn.  The barn was completely black except for a non-descript sign on the roof that read “The Black Box.”
I gradually lost altitude, coming closer to the barn, as was I did I noticed people.  There were two lines of people.  In my dream, I was floating with my body parallel to the ground.  The rectangular barn had its long axis running from left to right.  The people in the dream were arranged in two lines, each line running parallel to the left-right axis of the building.  One line was above the barn and the other line was below it.
Drawing closer, I noticed they were all wearing cowboy hats.  Getting even closer, I notice that the ones above the barn had braided ponytails, so they must’ve been girls, and the ones below the barn did not, so they must’ve been boys.  And all of them were carrying candles.  Some of the candles were lit and some weren’t.
Both lines were moving toward the barn with a rhythmic motion; they were dancing.  I then noticed there were doors in the sides of the barns.  I noticed this when each of the rhythmic cowboys and girls danced their way into them.
Then, in the manner of dreams, I was suddenly in the barn without ever having gone through a door.  Once inside, I saw that the cowboys and cowgirls were facing each other, still dancing in place.   In between them were children.  They were also dressed in traditional cowboy accoutrements, but they were androgynous.  While a particular one on the other might have had a ponytail or not, I couldn’t tell.  It wasn’t important to the dream.
Once lined up facing each other, with one little “cow-child” looking up at each couple the following ritual began to take place.  It started on the right end and proceeded in turn to the left.  
Each member of the couples had a candle as did the child and between each of threesome and the next was a pole that held the barn up with a lantern hanging from it.  With some of the cowboys and cowgirls both candles were lit, in some neither, and in some one and not the other, and to begin with, none of the lanterns were lit nor any of the children’s candles.  
When it became a particular couple’s turn they would look at their candles and look at the lantern to their right.  If exactly none were lit, they would do nothing.  If exactly one was lit, they would light the child’s candle.  If exactly two were lit, they would light the lantern to their left and leave the child’s candle unlit.  If all three were lit, they would light the child’s candle and then light the lantern.  Then the next couple took its turn. The first couple didn’t have a lantern to their right to look to, but acted as if they did and as if it were unlit.
At the end, as in the manner of dreams, certain things began to go out of focus while other things came in.  The cowboys, cowgirls , and lanterns faded into the background while the children came into focus, each holding his/her own candle whether lit or unlit.
Then I started awake because a cat was crawling across my face and muttered something about computer programming before bed..
In the cold light of the next morning, I realized this dream was about how binary addition works.  That is to say, how computers add numbers.  For computers, buried deep beyond where most users dare venture, numbers are represented as binary numbers, ones and zeroes. Instead of the place values representing one, ten, one hundred, etc from right to left, the places represent 1, 2, 4, 8, etc.
The binary number 10110 is 0 times one, 1 times two, 1 times four, 0 times eight, and 1 times sixteen; this represents the number twenty-two.  If this number were to be added to the binary 01101--thirteen--we could carry out the operation as below:

Lanterns 111000

This is a multi-stage process.  Each stage has three inputs: bit (binary digit) from the first summand; bit from the second summand; and the bit that is carried in.  Each stage has two outputs: the bit that goes into the sum and that bit that is carried to the next stage.  So twenty-two plus thirteen is thirty-five.
This turns addition into a mechanical process.  Mechanical operations yield a result that can be interpreted as a number.  When we type numbers, usually base ten, into a computer, this is what goes on behind the mask as it were.  At least this is how I thought about it for years.
But behind this mask, there are other masks.

Part 2; The Logical Mask

Behind the mask of binary arithmetic is the mask of symbolic logic.  The symbols 1 and 0 can be interpreted to have the truth values of true and false, respectively.  These symbols can be combined using the logical operators of & (and), OR (or), and ~(not), and the statements obtained from these various operations can be evaluated as being either true or false. Consider the following:
“Red is a color” and “Dogs are mammals.”  Each of the these statements is true and the combined statement is true.  However, “Red is a color” and “Dogs are reptiles” is a false statement because the second statement is false.  One can put this into symbols as 1&1=1 and 1&0=0, respectively.  We can summarize these in tables as below:




We see the 1s and the 0s are transformed in different ways with each of these operations and this might make us think about how they interact with each other in binary addition. Using this to capture addition adds additional (HA!) complexity which is why it is hidden behind a mask.
It is at this point where those of you who get motion sick in the movies might want to skim for a while.
The addition of one bit to another actually requires two stages because of the having to deal with whatever is being carried in from the previous stage.  The first stage is called a half adder and it requires two pieces as well: sum and carry.
Think about how we add numbers when we do it by hand. We place our numbers one above the other with the digits having the same place value lined up.  We proceed column by column.  We add together the digits from the current column and we add in the carry from the previous column.
To describe this, I am going to have to label various bits, and to keep it from looking too much like algebra class, I will refer to the names in the story I began with.
When we add together those two bits in the column under consideration, the cowboy bit and the cowgirl bit, the only time there will be a carry is when both bits are 1.  So the carry to the next column--at least before we add in the carry from the previous column--is (cowboy bit)&(cowgirl bit). We will call this the left lantern bit.  Don’t go to thinking we are done with the left lantern bit; it will change before this is over.
Let us now worry about what we give to the child. It’s not so straightforward. If exactly one bit from the cowboy or cowgirl is 1, then the child bit is 1.  Here it looks like OR. However, when both bits are 1 then the child bit is 0.  It doesn’t look like anything we’ve seen before from out logical operations.  However, we can create a new operation by compounding the others to take care of this.  It is called exclusive or and it is denoted XOR.  We can define it by the formula:
a XOR b= (a OR b) & (~(a & b)).
There is a reason for the mask, no?
We set the child bit as (cowboy bit) XOR (cowgirl bit).  Again, don’t grow too attached because child bit will change once before we are done. This is because we must now account for the possibility of a carry from the previous stage.  
(Breath, just breath.  In and out, that’s okay.)
We simply add the carry from the previous stage--right lantern bit-- to the child bit.  This means the final bit that we write down for the some will be (child bit) XOR (right lantern bit).  What happens to the carry to the next column--the left lantern bit--is a bit more subtle.  When we sum the child bit (not the new child bit but the old child bit) with right lantern bit, this creates a carry of its own that is to be added to the carry that we originally generated by adding the cowboy bit to the cowgirl bit. (Did you get that bit?) That carry is:
(child bit) & (right lantern bit).
While it might seem that summing this with the left lantern bit would be,
[(child bit) & (right lantern bit)] XOR (left lantern bit),
The fact is that because of the small number of possibilities for right lantern bit, cowboy bit, and cowgirl bit, there will never be a time when the quantities on the left hand side and the right hand side of this XOR will ever be the same.  As a consequence it is:
[(child bit) & (right lantern bit)]  OR (left lantern bit) .
If you have been paying attention to this, you should be just a little dizzy. Air sickness bags are available from the seat back in front of you.

Part 3; Beneath the Mask of Logic, Transistors

Let us now recall that all of this is to get a computer to add numbers together.  In the computer, the numbers are represented by electricity.  One represents where there is current and zero represents where there is not.  This is a mask too, but I will not remove it until the last section. 

We represent the wiring in symbols.  For example, NOT is represented by:
& is represented by:
OR is represented by
and XOR is denoted by:
To spare you further suspense, the wiring the denotes addition is represented by:
For any of you readers who are still there, we are already well past any reasonable threshold of complication.  However, this diagrams still represents a mask because none of those symbols actually stands for a single component.  Rather, they stand for a collection of electronic components that are wired together in a particular way.
One way to make them work is to use something we’ve all heard of but very few think much about: the transistor.
A transistor is a switch, and there are a few different kinds.  The kind I am going to tell you about is the NPN.  An NPN transistor has three legs pictured as below:
Notice the legs are labeled E, B, and C.  This is for emitter, base, and collector.  Think of electricity as coming in C (the collector--they are working with us) and going out E (the emitter--it works). Think of B as an on-off switch (base? on-off switch? they were doing so nicely).  We send in one current through C to E and when we send another current to B, it will turn the switch on and allow it to pass.  When we turn that switch off, it will not.  
This is represented in a wiring diagram by the figure  below:
By wiring transistors together in various imaginative ways, we can create the logical gates as pictured above. For example the NOT gate can be wired as:

Part 4; Burning Your Fingers

A good question at this point would be how does this circuit yield NOT as an output.  The answer goes as follows.  There is current coming in from the top, all the time.  When there is no signal sent in through the input, i.e. when it is false or 0, the current cannot go through the transistor because it is off.  Therefore it puts out a current, i.e. a true or a 1.  That is to say 0 input gives 1 as an output.  
By way of contrast, if there is a current coming in through the base, i.e. it is true or 1, then current can flow through the transistor from C to E.  This will be the path of least resistance so the current will not go out through the output.  Therefore, there will be no output current.  Therefore, it will be false or 1.  So 1 input gives 0 output.  This is what the NOT gate is supposed to do.
Except its NOT that simple. How do I know?  I wired it on a breadboard with a transistor, resistors, batteries, the whole shooting match.  It took me awhile to get it to work.  Why?  I didn’t use resistors at first.  Resistors are simple--but handy--little things.  They are cheap.  Their purpose is to slow electricity down.  When you don’t have them, the transistor gets hot and doesn’t work well anymore.
How do I know it gets hot?  I burned my finger on it, that’s how.  I got a little transistor-sized blister.
Oh, and the path of least resistance thing.  That’s not exactly true.  It will go through the transistor, but you need to be careful about the amount of resistance in the output direction.  Regardless of that, there will still be a little current.  I never got the resistance high enough so that, although the LED I hooked up to check for current did dim, it never went entirely out.  I suspect you can calibrate things so that you can’t see the LED light but there will still be a tiny amount of current.  
So the 1 and the 0, true and false, are simply masks themselves.  True means the current is above a certain threshold and false means the current is below it.


So what is the point?  There is a collection of masks going downward like a Matryoshka doll.  I was satisfied I’d gotten close enough to the bottom of it when I burned my fingers.  The masks are there for a purpose.  The complexity of this endeavor is just too massive to take in all at once.  We must organize it by putting the masks on so that it can be learned one step at a time.
Consider now the fact that I’ve only talked about addition and only shown the wiring for a small part of even that.  It is all still inside a Black Box, as it were.  The relative number of people who can understand this is vanishingly small, and, as a wise friend of mine says, it is becoming increasingly like magic to the average person.
As a teacher, this motivates me.