Archive for the ·

Mathematics

· Category...

Don’t forget to carry the 1

1 comment

I’ve been working on my assignment for almost five hours now. I know that it shouldn’t take this long but sometimes when you’ve been working on something for a long period of time, obvious things aren’t so obvious. It took me two hours to work on a problem and I’ve finally solved it. Now I can carry on to the other part of the assignments.

This assignment for my networking class is about cryptography, mainly the RSA algorithm. This algorithm was created by Ron Rivest, Adi Shamir, and Leonard Adleman hence that’s how it got its name. The whole thing involves three steps, key generation, encryption and decryption. The last two steps are easy so long as you’ve completed the first step correctly.

The key generation step involves the following.

You need two prime numbers, p and q. Next, you have to compute n = pq. Then you compute the φ(n) = (p – 1) (q – 1). And finally, you have to solve for d which is the private key. For my assignment, the numbers were as follows:

p = 23
q = 17
e = 19
n = pq
n = 23 x 17
n = 391
φ(n) = (p – 1) (q – 1)
φ(n) = (23 – 1)(17 – 1)
φ(n) = 22 x 16
φ(n) = 352

With all of these calculations out of the way, I can go ahead and solve for d. I had a little bit of a hard time solving this equation because I kept losing track of what number goes where and which numbers to subtracted from which column. I took me about two hours before I finally arrived at the correct answer.

e φ(n) (1,0) (0,1) Comments
19 352 (1,0) (0,1)  
19 10 (1,0) (-18,1) y = 18, r = 10; (0,1) – 18(1,0) = (0,1) – (18,0)
9 10 (19,-1) (-18,1) y = 1, r = 9; (1,0) – (-18,1) = (19,-1)
9 1 (19,-1) (-37,2) y = 1, r = 1; (-18,1)-(19,-1) = (-37,2)
0 1 (314,-19) (-37, 2) y = 9, r = 0; (19,-1) – 9(-37,2) = (-19,-1) – (-333,18) = (314,-19)

What is happening here is that you would keep calculating the numbers until either the e or the φ(n) reaches a value of 1, in this case, it did in a few steps. Whichever column has a value of 1, that’s where the answer is for d. In this case, it’s -37 but d cannot be negative so we have to solve it further.

d = -37 mod φ(n)
d = -37 mod 352
d = 315

For anyone who isn’t familiar with programming, mod means to divide and take the remainder. So 5 mod 4 means that 4 goes into 5 once and has a remainder of 1. In this case, the remainder would be a negative number so you subtract from the divisor. I don’t remember learning that part when I was in school but now I know.

So d = 315 and that becomes the private key. Now that you have the private key, you can encrypt and decrypt your message. To encrypt the message you use this formula:
c = md mod n
and to decrypt you use this formula:
m = cd mod n
Where m is the message and c is the cipher text.

During the key generation step, I did everything that I was supposed to do only I forgot to carry the one and received an answer of -27 instead of -37 and that’s what messed everything up. The stupid part about it was that I kept getting -27 every time and I didn’t see that mistake until I went over it again and again. But at least I managed to get a lot of practice working in this because I know that it’ll be on the exam and now I can do it all by hand.

Nullity

2 comments

Anyone who has taken a Computer Science course will know about the “Divide by Zero” error message. In mathematics, you cannot divide by zero because it’s an operation that you can’t find an answer to. I always wondered why exactly you couldn’t do it. It took me a while to understand it but later on I came to the same fork in the road and found myself wondering about it again.

The reason why you cannot divide by zero is because of the way that division and multiplication are related. A number multiplied by another number will give you a product. So the product divided by one of the numbers should give you the other number. But with zero, it doesn’t work out.

325 / 25 = 13 because 13 x 25 = 325
325 / 0 = ? because ? x 0 = 325

Zero multiplied by any number will produce zero so you cannot divided by zero. If you were to think about it, it would seem to make sense to say that a number divided by zero is that number. Since zero means nothing and if you’re dividing by nothing, you’re not dividing at all. So shouldn’t the answer be the initial number? When you’re talking about it, it may work but mathematics is a whole other language of its own. Saying something one way works out to be the same if you were to say it completely backwards.

Multiplication involves grouping thing together and division involves separating them into those groups. In the example above, 13 groups of 25 will give you a total of 325 units. But how many groups of zeros can you separate into 325? You can’t do it because no number of groups of zero will give you 325. So anything divided by zero becomes undefined because the multiplication isn’t consistent with the division.

The only time where the multiplication is consistent with the division is if you multiply zero by zero and divide zero by zero. For both equations you get zero as the answer. But this seems to be the only case where it works. It doesn’t work anywhere else. This is know as an indeterminate.

Only recently has something come up to explain this issue with dividing by zero. It was solved by a university professor, Dr. James Anderson. He has found a way to explain zero to the zero power, an equation that was unsolved for 1200 years. The explanation appears to be rather simple too. The equation is as follows:

Define:
∞ = 1/0
-∞ = -1/0
Φ = 0/0

=00
=0(1-1)
=01 x 0-1
=(0/1)1 x (0/1)-1
=0/1 x 1/0
=0/0
=Φ

The symbol I used is the Phi, it’s the closest thing that I could find to resemble Dr. Answer’s number nullity. This theory will make computing any number possible. If it works out, it will also prevent computers from failing when there is a division by zero. You can read up on the full article and watch the video at the link below.

Nullity

What’s behind door #3?

3 comments

Don’t know ask me how this discussion got started but it did. The topic at hand was the probability of choosing the right door that contained the prize. You’ve heard of that game show where the host gives the contestant a choice of three doors. They select a door and then the host shows them one of the door that does not contain the prize. The contestant now has the option of sticking with their first selection or changing their mind. This is where the probability factor start. It’s a bit tricky to understand, so I’ll try to explain it the way I understand. Of course, I may be wrong.

The problem goes a little something like this. You are given three choice of door to choose from. Behind one of those doors is a prize, say $1,000,000. Behind the other door is something that you don’t want, say a fruitcake. You are asked to select a door, say you pick Door #3. One of the other doors, Door #1 and Door #2, are opened. Usually, it’s the door with the fruitcake behind it, that is shown to you, say Door #1. Now, you given the option of sticking with your choice, Door #3 or switching to the other door, Door #2. Do you stay with your selection or do you switch?

From what I’ve read, the probability of picking the door with the $1,000,000 is higher if you make the switch rather than staying with your selection. The way I see it is like this. You start off with three doors. All three doors have the same probability of containing the $1,000,000 behind it, 33.3%. After selecting a door, one door is eliminated. Now, you have to choose from two doors. By staying with the door you selected, you odds are still 33.3% but by switching, your odds are higher because you’re selecting from two doors rather than three. So it makes sense to say that by switch you’ve increased your odds. By switching to the other door your odds are now 50%. It is a common intuition to belieive so, but it’s not quite right.

You have to try and understand this without numbers because according to the numbers, it makes sense. But the rule of probability states that the probability of A given B equals the probability of both A and B occurring, divided by the probability of B occurring.

= 1/2 x 1/2 / 1/2
= 1/4 / 1/2
= 1/4 x 2
= 2/4
= 1/2
= 50%

Using the numbers from the three doors, you get:

= Door #3 x (Door #1 + Door #2) / (Door #1 + Door #2)
= 1/3 x 2/3 / 2/3
= 2/9 / 2/3
= 2/9 x 3/2
= 6/18
= 1/3
= 33.3%

The probability of selecting a door with the prize are evenly distributed. So by staying with your selection, the calculations are as follows:

= 1/3 x 1/2 / 1/2
= 1/6 / 1/2
= 1/6 x 2
= 2/6
= 1/3
= 33.3%

If you switch, you get this:

= 2/3 x 1/2 / 1/2
= 2/6
= 2/6 x 2
= 4/6
= 2/3
= 66.6%

Understanding this problem depends on your interpretation of the situation. During the second stage, you’re picking between two doors, so you assume that probability is 50/50 but you have to include the probability of your first selection. The next time you get a offer to pick between three things, it’s best to make the switch after one option is eliminated. Your chances of making the right selection is higher. It can go both ways. After making the switch, you may have been right from the start.

But the idea is saying that if you switch, you will get it right more often because your initial odds were 33.3%, so by making the switch, you’re switching over to the 66.6% side because now you’re getting another chance to pick. The 33.3% from your first pick plus the 33.3% chance of your second pick equals 66.6%. If you don’t pick, you’re losing that extra 33.3% chance. It makes sense to choose the one that will give you a higher chance of winning, hence you switch.