Sunday, June 19, 2016

MTH 495 – Blog Post 3

Modular Arithmetic
Okay, so this intentional, but it seems that I have been on a modular arithmetic spree! Following my last post, I wrote a brief paper on binary numbers and their use in computing. This led to the question, “What is addition, subtraction, multiplication, and division like in a binary world.” I mentioned this to Professor Golden as we were walking out and he mentioned that just like in decimal arithmetic, place value it key. Boy, was he right on that!

So I started with a worksheet that I downloaded which allowed me to practice converting binary to decimal equivalents and decimals to binary equivalents.

I started with converting binary to decimal equivalents. I tried several different methods for this but the one I settled on is this:
First, you give each column a number, n, starting at the first digit on the right starting at zero. For each column with a 1 in it, you simply add 2^n. The sum will be the decimal equivalent. See Image 1.

Next I worked on converting decimals to binary equivalents. For this one I only tried one method.

I started by writing down the decimal value of 2^n for n = 0, … , 11, from right to left (See the top of Image 1). I would then look at the number I was converting and find the column, or place value, that was closest to this number but less than the number. For example, in problem 2b) I had the number 19. The column n=5 had a decimal equivalent value of 32, which was too large but the column n=4 had a decimal equivalent of 16, so I put a one on the page and then subtracted 16 from 19, which left me with 3. Since columns n = 3 and n = 2 have a decimal equivalent larger than 3, I put two zeros to the right of the 1. Column n=1 has a decimal equivalent of 2, so I placed a 1 there and subtracted 2 from 3, which left me with 1. Column n=0 has a decimal equivalent of 1, so I placed a 1 there and was left with zero. There for 19 has a binary equivalent of 10011. To see examples, look at Image 1.

Image 1


I then moved on to binary addition and subtraction. Addition turned out to be a bit easier than subtraction. With addition, if I was adding an even number of ones in a column, I would place a zero in that column and then carry over a 1 to the column to the left for each pair of 1s in the column I was adding. However, if I had an odd number of ones in the column I was adding, I would still carry over a 1 for each pair, but I would also put a 1 in the column I was adding. See Image 2, as I am certain that I am making this far more confusing than it should be.

As for subtraction, all went smoothly until I was force to borrow from the number column to the left. The best way for me to make this work is that I would change the 1 in the column to the left to a zero and put two ones in the column I was subtracting. This would leave me with a pair of 1s minus one 1, leaving me with 1. Once again, see Image 2.

Image 2

Next came binary multiplication, see Image 3. This turned out to be easy and very similar, like the other processes described above, to the process we use for multiplication with decimal numbers. If there is a one in the first column of the multiplier, you simply write the multiplicand below the line. If there is a zero, you just write zero. Below that first row, you write a zero and then if there one in the 2 column, you write the multiplicand after that, adding an additional zero to the end of the multiplicand for each column that has a 1 in it. You then add them all together, using binary addition, to get your final number.

Image 3

I then worked on binary division, which worked very similar to decimal division. Essentially, you start at the left most column and move to the right until you have a number that is higher in value than the divisor. You put a 1 above that column and write the divisor below those columns and subtract it. You then start pulling down digits from the column to attach to the end until you have a number larger than the divisor and repeat until you have reached the end. Yes, I know that this description is terrible, please see Images 4 & 4.1.

Image 4

Image 4.1

It was at this point that I thought I was done. However, I decided to take the time to show all of this to my sons. All of them thought it was cool but Lance was fascinated. We did several problems together and then I show him the application I had downloaded to my iPhone to check my work. It is called Hex Calc and you can find it at: https://itunes.apple.com/us/app/hex-calc-simple-pocket-calculator/id335773208?mt=8

When I showed him the calculator, he noticed that the first 4 buttons at the top are BIN, OCT, DEC, HEX. Below them, in the first three columns, are the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. When you push the BIN button, all of the numbers are grayed out except 0 and 1. When you press OCT, you get 0 through 7, DEC gives you 0 through 9, and of course, HEX gives you 0 through F. This blew his mind and we spent several minutes talking about HEX and how each column would go from 0 to F and then you would have to carry a 1 to the next column to the left. He then asked me to covert several numbers in HEX to DEC. At first I thought this would be easy, after all, wouldn’t it be just like binary? As in, number each column started with zero at the right and going up as you go to the left. Then use that as the exponent. As in 16^0, 16^1, … , 16^n. Well, the answer is yes and no. You do use that method but you then need to multiply that value by the number in the column in question. For binary, this is down without thinking about it. Either it is zero, in which that column is ignored (Because you are basically multiplying 2^n by zero.) or you add 2^n (2^n times 1). Except with HEX, you have more than just 0 and 1 to deal with. Think of it this way, the first column can go from 0 to F which is 0 to 15 in decimal. If you add one to F, you get 10, which is HEX means 1 – 16 and zero ones or, 16 in decimal. However, if you have 50, the decimal equivalent is 5 – 16s, or 5 * 16^1. Way cool and way fun.

Later that day Lance wrote the following problem on the board (See image 5 for my work. It is labeled “Lance’s Problem”.)

DC1+100100

He wanted me to add the HEX number and the BIN number together and give him the answer in DEC. Keep in mind, Lance loves to give me problems like this and never knows the answer himself. I think he just loves to watch me work through then and struggle with the problems. He often gets a chance to walk through the problem with me. Anyway, I did not get the correct answer in my head. Trying to do 16^3*13 was a bit much. Eventually, once I switch to pen and paper, I was able to work it out. The answer, by the way, is 3,557.

Image 5

Now, if you have stuck around this far, you are probably not going to be surprised by what happened next. A question occurred to me, “I wonder what multiplication, division, addition, and subtraction would be like in HEX?!” The examples of that can be found in Image 5 and Image 6.

Image 6

Fascinatingly enough, all of this tied in nicely with our discussion in class on June 16th as we were discussion Carl Friedrich Gauss. You see, Gauss’s favorite tool in mathematics was modular arithmetic, and he used this tool to come up with many proofs that mathematicians had been unable to solve otherwise.

Modular arithmetic is something that we do on a daily basis, every time we look at a clock and deal with time, without even a second thought. Yet, show someone a modular math problem or use a numbering system with a different base, and it is very difficult for us to use until we have spent a good amount of time with it. Either way, it was stressing out my brain cells and so I know it was going me some good, and Lance was fascinated by it, which is an even better reward.

As for me, one of the most challenging aspects of the GVSU course, MTH 210, was dealing with modulo. I think this is because up to that point, I don’t think I had ever dealt with math using anything other than decimal numbers. Just like working through decimal arithmetic can help you see numbers a combination of other numbers, which can help you see patterns that would otherwise miss, working through binary arithmetic and hexadecimal arithmetic, increases your number sense, stretches your understanding of simple as well as complex relationships, and helps you see relationships that you likely would have missed otherwise.

Thank you for reading,
Jerry

Binary Numbers and Computers

Hello,
Recently I wrote a small paper on binary numbers and how they came to be the number system used in computers. I will paste this below along with links to my reference. I am doing this because it partially explains why my next blog post will be on binary and hexadecimal math. :)

Binary Numbers and Computers
The first computers used electrical mechanical switches called relays. The computers are so large that they would take up the space of a large room. The switches were used because it was easy to determine the which state the relay was in; either it was on and current was present or it was off and there was no current. It was for this reason that engineers used the binary number system for computers, since in binary we only have two numbers, 0 & 1, and engineers could use this to correspond to the on/off state of the switch.
This dependency on binary numbers may change if those working on quantum computing have anything to say about it as quantum data has the property, such that, a quantum computer with x can be in an arbitrary superposition of up to 2^x different states simultaneously.
Anyway, the first electronic computer, ENIAC, was built 1946 at the University of Pennsylvania and used binary to calculate data. However, the binary number system had been around for almost 300 years before that, as it was discovered by the coauthor of calculus, Gottfried Wilhelm Leibniz, in 1701.
Binary Math? Binary addition and subtraction are very similar to the 10 based math we have today. I have a handout as an example.
What about Binary multiplication and division? Here’s how it works:
“Binary multiplication   is actually much simpler than decimal multiplication. In the case of decimal multiplication, we need to remember 3 x 9 = 27, 7 x 8 = 56, and so on. In binary multiplication, we only need to remember the following,
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1
Note that since binary operates in base 2, the multiplication rules we need to remember are those that involve 0 and 1 only. As an example of binary multiplication we have 101 times 11,
  101
  x11
First we multiply 101 by 1, which produces 101. Then we put a 0 as a placeholder as we would in decimal multiplication, and multiply 101 by 1, which produces 101.
  101
  x11
  101
1010  <-- the 0 here is the placeholder
The next step, as with decimal multiplication, is to add. The results from our previous step indicates that we must add 101 and 1010, the sum of which is 1111.
  101
  x11
  101
1010
1111

Binary division   is almost as easy, and involves our knowledge of binary multiplication. Take for example the division of 1011 into 11.
          11   R=10
 11 )1011
        -11
         101
          -11
           10  <-- remainder, R
To check our answer, we first multiply our divisor 11 by our quotient 11. Then we add its' product to the remainder 10, and compare it to our dividend of 1011.
     11
  x 11
     11
   11 
  1001  <-- product of 11 and 11
 1001
 +  10
  1011  <-- sum of product and remainder
The sum is equal to our initial dividend, therefore our solution is correct.

I got the information for this at the following pages:
https://en.wikipedia.org/wiki/Quantum_computing

Thursday, June 2, 2016

MTH 495 – Blog Post 2

O Zero, Zero, wherefore art thou Zero?
Perhaps this is just another example of just how long it has been since I was in high school, my 25-year class reunion is this summer, but I do not remember a time in my life were I considered a life or a mathematics without the number zero in it until I started taking classes at GVSU. Since then, I have learned that zero was invented and the meaning of the number and the properties had to be developed. Whoo! What would life be like without zero!?

Well, before we get to that, how about we talk a little bit about what life is like with zero. Here is a link to a School House Rock video about zero (https://youtu.be/3huvvxUHDmM). Did you watch it? What do you think? Is there anything you disagree with or question? Certainly as a kid growing up and watching these videos during Saturday morning cartoons, I never questioned them. Yet now, I am not so sure about some of what the video says:

  • What do they mean that without zero we could never reach a star?
    • That implies a great deal, including that because we have zero, we can reach a start. Yet current experience has shown us that by the time anyone was to reach a star, actually it would be one of the ancestors of those that started out towards the start, they would have serious difficulties dealing with the effects of gravity, to say the least.
  • What do they mean by, “Before you came along, we counted on our fingers and toes.”?
    • I think that the Chinese, Egyptians, and Babylonians might disagree with that.
    • Although, we have to be careful here because without zero, what would the cavemen shown in the video do when they got to the tenth finger or toe?
      • The use of zero in this case seems to refer to using it as a place holder to indicate, for example, the difference between one and ten. Archeologists and historians have found numerous examples of the use of a variety of symbols used as a place holder. Other examples show that no place holder was used and the only way you could tell the difference between six and sixty for example, was by the context it was written in.
  • “When you run out of digits, you can start all over again.”
    • Actually, I am fascinated by math that does not use zero and what it does to the standard mathematical properties that we use every day. This is what I will look at in the next section.
  • “Place a zero after any number and you have multiplied that number by ten.”
    • I love the simplicity of that. Which is why the metric system is so nice and why it is surprising that the US still hasn’t switched to it.
    • Also, it is surprising how many students don’t have a firm understand of this.
  • Zero is definitely useful in our 10 based number system as a place holder but to me, the real power and beauty of zero comes from the properties it has as a number. In class we looked at the definitions of zero laid out by Brahmagupta around 630 AD. His definitions, or should I say properties, used the terms fortune and debt for positive and negative numbers. Interestingly, he had definitions for division by zero! Math teachers: It’s okay! You can come out from under your desk. Because of the conflicts these rules created, we have decided that division by zero is just not something we want to define quite yet.

So, now a brief look at math with and without the number zero. What I will do is set up a 9x9 grid for both addition and multiplication and see what the answers are using a number system that goes on to 10, 11, 12, … and one that wraps around to 1 again after you go past 9. I am interested in seeing what happens.



Okay, I am the first to agree, there is so much more to look at here and explore. We have really just scratch the surface. Please share your observations as a reply. Also, do you have anything to add, did I have an error or miss something? Please share!

Thank you for reading,
Jerry