H_HW#2answers

advertisement
Math 5248 Lec 2 Homework #2 Due 2/14/2013
2.3.1 PROB(10 no “e”) = (1─0.1167)10=(0.8833)10=0.2891 (approx).
Prob(100 no “e”)=(0.8833)100= 0.00000408153 (approx)
Your answer must be correct to at least two significant digits to get full credit. An answer of
zero for the second part is not acceptable and gets no credit. There is a big difference between an
impossible event and an extremely unlikely event.
2.4.2 It looks like e is encoded as b and perhaps t is encoded as k. Rather than find the encoding
function and then find its inverse (as done in the book), let’s find the decoding function directly.
If D is the decoder, then D(b) =e and D(k)=t. Numerically, this is D(1)=4 and D(10) =19. So if
the decoder is D(x) =ax+b then a+b=4 and 10a+b=19. Subtracting, we get 9a=15. The Mult Inv
of 9 is 3, so from 9a=15 we get a =45=19 (always working mod 26). Then if a = 19, from a+b=4
we get b=11. So our guess for the decoder is D(x)= 19x+11. Applying this to the encoded
message, we get the same answer as the last line on page 37.
4.4.10. Let’s be clear what we mean by “distance”. If we have the stream “exe”, for example, is
the distance one or two? I am going to say it is one, because it makes my calculations easier. (If
you said that this distance is two, then your answer will be one more than my answer.)
The question in the exercise is the same as this question: Starting from the beginning, what is
the expected value of the number of letters before the first e (not counting the e, according to my
definition). Let p be the probability of NOT getting an e; we will plug in the value p=0.89 later.
What is the probability that the number of letters before the first e will be k, where k =0, 1 ,2
,3,…? It is (p)k(1─p). To check that this is correct, you should make sure that
∞
∑(𝑝)𝑘 (1 − 𝑝) = 1
𝑘=0
Then the expected value is
∞
𝐸 = ∑ 𝑘(𝑝
𝑘=0
∞
𝑘 )(1
∞
𝑘
− 𝑝) = ∑ 𝑘𝑝 − ∑ 𝑘𝑝
𝑘=0
𝑘=0
∞
𝑘+1
∞
𝑘
∞
= ∑(𝑘)𝑝 − ∑(𝑘 − 1)𝑝 = ∑ 𝑝𝑘 =
𝑘=1
𝑘
𝑘=1
𝑘=1
𝑝
1−𝑝
Now p = 0.89, so E=.89/.11=89/11=8.0909090909….
I realize there might be other, more direct ways, of getting this answer.
If you got the sum as ∑ 𝑘(.89)𝑘 (.11) and then found a numerical approximation (rather than
evaluating the sum analytically, which can be done in a variety of ways), you lose 2 pts if your
answer is correct to 2 decimal places, but you lose 5 pts if your answer is off by more than that.
4.5.2 In either case, the expected value is Pr(letter from 1st steam is 0)•Pr(letter from 2nd stream
is 0)+ Pr(letter from 1st steam is 1)•Pr(letter from 2nd stream is 1).
For random streams, this is (1/2)(1/2)+(1/2)(1/2)=1/2.
For streams from the language, this is (2/3)(2/3)+(1/3)(1/3)=5/9.
4.5: Also find the key length of the Vig cipher on the web.
I have posted a spreadsheet on the web showing what happens if you shift the original ciphertext
by 1, 2, 3, ….15. The numbers at the top of the 15 columns Q, R, S, …AE show the index times
100 for shifts of 1, 2, 3,...,15. It is fairly clear that the length of the key is 5.
6.2.6: 32561= (3)(10201)+1958
10201=(5)(1958)+411
1958=(4)(411)+314
411=314+97
314=(3)(97)+23
97=(4)(23)+5
23=(4)(5)+3
5=3+2
3=2+1
Now 1=3─2
=3─(5─3)
=(2)(3)─5
=(2)[(23─(4)(5)]─5
=(2)(23)─(9)(5)
=(2)(23)─(9)[97─(4)(23)]
=(38)(23)─(9)(97)
=(38)[314─(3)(97)]─(9)(97)
=(38)(314)─(123)(97)
=(38)(314)─(123)(411─314)
=(161)(314)─(123)(411)
=(161)([1958─(4)(411)]─(123)(411)
=(161)(1958)─(767)(411)
=(161)(1958)─(767)[10201─(5)(1958)]
=(3996)(1958)─(767)(10201)
=(3996)[32561─(3)(10201)]─(767)(10201)
=(3996)(32561)─(12755)(10201)
and gcd =1.
6.2.8: Using the Euclidean Algorithm process to find the gcd, we have
n3+n2+n+1=(n)(n2+n+1)+1, showing that the gcd =1. In a little more detail, suppose d is a
common divisor of n3+n2+n+1 and (n2+n+1). Then n3+n2+n+1=bd and n2+n+1 = cd. Hence the
equation n3+n2+n+1=(n)(n2+n+1)+1 becomes bd=cd+1, or (b─c)d=1. Thus d divides 1, so d
=±1. So the only possible common divisors of n3+n2+n+1 and (n2+n+1) are ±1; hence the
gcd=1.
7.2.8: 12091=(107)(113). We want the mult inverse of 3 mod (106)(112); that is, the mult
inverse of 3 mod 11872. An easy calculation shows that the mult inv of 3 is 7915. Then we need
to calculate 98127915%12091 (yuk!). You should be able to do this by hand, but I have posted a
fast exponentiation spreadsheet on the web which implements the procedure in section 9.5. (I
realize that from a programming point of view this spreadsheet method is quite primitive.) The
answer is 142.
We can check this: 1423%12091=9812%12091. Yes, it works.
7.5.3: From the header br=98, we compute cr %103=9847 %103.
Then we decrypt 79 by multiplying 79 by the mult inverse of 9847mod 103. Now
9847%103=59%103, and using the EA we get that the MI of 59 is 7. [TRICK: By Fermat,
98102%103=1. Hence the MI of 9847 is 9855, and 9855%103 is 7.] So the decryption of 79 is
38.
(79)(7)%103=
Check: c=58, b=2, 2r=98 and so we can find (by hunting) that r=29. Then cr=5829=59 and so
E(38)=(38)(59)=79. All these calculations are mod 103.
Download