1 / 44

Analyzing Series

Analyzing Series. CSC2110 Tutorial 9 Darek Yung. Outline. Continue on Cryptography Review on Series Examples Class Work 3. Repeated Squaring. Calculate 5795 73 (mod 21) by repeated squaring 72 = 64 + 8 + 1 5795  20 (mod 21) 5795 2  1 (mod 21)

hali
Download Presentation

Analyzing Series

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Analyzing Series CSC2110 Tutorial 9 Darek Yung

  2. Outline • Continue on Cryptography • Review on Series • Examples • Class Work 3

  3. Repeated Squaring • Calculate 579573 (mod 21) by repeated squaring • 72 = 64 + 8 + 1 • 5795  20 (mod 21) • 57952 1 (mod 21)  57954 57958 579516 1 (mod 21) 579532 579564 1 (mod 21) • 579572 579564 * 57958 * 57951  20 (mod 21) • Can we apply Fermat’s Little Theorem i.e. 579520 1 (mod 21) and thus 579573 579513(mod 21)??? • NO!!!! 21 is not prime!!!

  4. RSA • Under RSA, given p = 13, q = 37: • Calculate n = pq, T = (p-1)(q-1) • Given e =35, calculate d = e-1 (mod T) • Encrypt the message m = 37 into m’ • Decrypt the message m’ into m

  5. RSA • p = 13, q = 37: • Calculate n = pq, T = (p-1)(q-1) • N = (13)(37) = 481 • T = (p-1)(q-1) = 432

  6. RSA • p = 13, q = 37, n = 481, T = 432 • Given e =35, calculate d = e-1 (mod T) • 432 = 12(35) + 12  12 = 432 – 12(35) • 35 = 2(12) + 11  11 = 35 – 2(12) = -2(432) + 25(35) • 12 = 1(11) + 1  1 = 12 – 1(11) = 3(432) – 37(35) • 11 = 11(1) + 0 • d = -37 = 432 – 37 = 395

  7. RSA • p = 13, q = 37, n = 481, T = 432, e = 35 • Encrypt the message m = 37 into m’ • 371 37 (mod n) • 372 372 407(mod n) • 374 4072 185(mod n) • 378 1852 74(mod n) • 3716 742 185(mod n) • 3732 1852 74(mod n) • m’  3735 (3732) (372) (371)  (74) (407) (37)  370 (mod n)

  8. RSA • p = 13, q = 37, n = 481, T = 432, d = 395, m’ = 370 • Decrypt the message m’ into m • 3701 370 (mod n) • 3702 3702 296(mod n) • 3704 2962 74(mod n) • 3708 742 185(mod n) • 37016 1852 74(mod n) • 37032 742 185(mod n) • 37064 1852 74(mod n) • 370128 742 185(mod n) • 370256 1852 74(mod n) • m’  370395 (370256) (370128) (3708) (3702) (3701)  37 (mod n) • NO WORRY! If repeated squaring appears in next Wednesday’s class work, the numbers will be small~

  9. Another RSA • Under RSA, given p = 17, q = 41: • Calculate n = pq, T = (p-1)(q-1) • Given e =49, calculate d = e-1 (mod T) • Encrypt the message m = 21 into m’ • Decrypt the message m’ into m

  10. Another RSA • p = 17, q = 41: • Calculate n = pq, T = (p-1)(q-1) • N = (13)(37) = 697 • T = (p-1)(q-1) = 680

  11. Another RSA • p = 17, q = 41, n = 697, T = 680 • Given e =49, calculate d = e-1 (mod T) • 680= 13(49) + 43  43 = 680 – 13(49) • 49 = 1(43) + 6  6 = 49 – 43 = -680 + 14(49) • 43 = 7(6) + 1  1 = 43 – 7(6) = 8(680) – 111(49) • 6 = 6(1) + 0 • d = -111 = 680 – 111 = 569

  12. Another RSA • p = 17, q = 41, n = 697, T = 680, e = 49 • Encrypt the message m = 21 into m’ • 211 21 (mod n) • 212 212 441(mod n) • 214 4412 18(mod n) • 218 182 324(mod n) • 2116 3242 426(mod n) • 2132 4262 256(mod n) • m’  2149 (2132) (2116) (211)  (256) (426) (21)  531 (mod n)

  13. Another RSA • p = 17, q = 41, n = 697, T = 680, d = 569, m’ = 531 • Decrypt the message m’ into m • 5311 531 (mod n) • 5312 5312 373(mod n) • 5314 3732 426(mod n) • 5318 4262 256(mod n) • 53116 2562 18(mod n) • 53132 182 324(mod n) • 53164 3242 426(mod n) • 531128 4262 256(mod n) • 531256 2562 18(mod n) • 531512 182 324(mod n) • m’  531569 (531512) (53132) (53116) (5318) (5311)  21 (mod n)

  14. Review on Series • Geometric Series • Future and Current Value • Annuity • Related Sums (talk after Rental Problem) • Integral Method (talk after Rental Problem)

  15. Geometric Series • Gn: 1 + x + x2 +x3 + … + xn • Gn = (1 – xn+1) / (1 – x) • Gn = 1 / (1 – x) for n  infinity, |x| < 1

  16. Future and Current Value • With annual interest rate r • $m now = $m(1+r)n after n years Future Value • $m after n years = $m / (1+r)n now  Current / Present Value • E.g. With $1 next year • Current Value = $1 / (1+r) • Future Value = $1(1+r) for 2 years from now

  17. Annuity • Borrow $V from bank with annual interest rate r, and return $A annually for n years • Current Value of ith payment = A / (1+r)i  V = A / (1+r) * [1 – (1+r)-n] / [1 – (1+r)-1] (By Geometric sum, 1st term = A / (1+r) )  V = A * [(1+r)n – 1] / [r *(1+r)n]  A = V * [r * (1+r)n] / [(1+r)n – 1]

  18. Flat Rental Problem • Given • price of a flat is $1,000,000 • Interest rate is 10% • Inflation rate is 5% • Loan period is 20 years • Suppose John wants to borrow 100% of loan to buy the flat • What’s the annual payment? • What’s the value of the flat after 20 years? • Suppose he can rent the flat for $80,000 and invest the money saved to get 10% annual return, how much money will he have after 20 years?

  19. Flat Rental Problem • What’s the annual payment? • Recall • V = A / (1+r) * [1 – (1+r)-n] / [1 – (1+r)-1] • V = A * [(1+r)n – 1] / [r *(1+r)n] • A = V * [r * (1+r)n] / [(1+r)n – 1] • Substitute V = 1,000,000, r = 10%, n = 20, • A = $117,460

  20. Flat Rental Problem • What’s the value of the flat after 20 years? • Value after 20 years • = 1,000,000 * (1+5%)20 • = $2,653,298

  21. Flat Rental Problem • How much money will John have if he rent the flat? • Money saved annually m • = 117,460 – 80,000 = $37,460 • After 20 years, Investment make at ith year will contribute $ [ m * (1+r)20-i ] • Therefore, total money after 20 years M is

  22. Flat Rental Problem • How much money will John have if he rent the flat? • By closed form of Geometric Sum, • Substitute m = $37,460, r = 10%, M = $2,145,521

  23. Another Flat Rental Problem • Given • price of a flat is $2,000,000 • Interest rate is 12% • Inflation rate is 5% • Loan period is 20 years • Suppose John wants to borrow 70% of loan to buy the flat • What’s the annual payment? • What’s the value of the flat after 20 years? • Suppose he can rent the flat for $180,000 and invest the money saved to get 12% annual return, how much money will he have after 20 years?

  24. Another Flat Rental Problem • What’s the annual payment? • Again, recall • V = A / (1+r) * [1 – (1+r)-n] / [1 – (1+r)-1] • V = A * [(1+r)n – 1] / [r *(1+r)n] • A = V * [r * (1+r)n] / [(1+r)n – 1] • Substitute V = 1,400,000, r = 12%, n = 20, • A = $187,430

  25. Another Flat Rental Problem • What’s the value of the flat after 20 years? • Value after 20 years • = 2,000,000 * (1+5%)20 • = $5,306,595

  26. Another Flat Rental Problem • How much money will John have if he rent the flat? • Money saved annually m • = 187430 – 180,000 = $7,430 • After 20 years, Investment make at ith year will contribute $ [ m * (1+r)20-i ] • Therefore, total money after 20 years M is

  27. Another Flat Rental Problem • How much money will John have if he rent the flat? • By closed form of Geometric Sum, • Substitute m = $7,430, r = 12%, M = $535,350

  28. Another Flat Rental Problem • How much money will John have if he rent the flat? • M = $535,350 • On another hand, the 30% down payment contribute 2,000,000 * 30% * (1+12%)20 • = $5,787,776 after 20 years • Therefore, total amount of money = $6,323,126

  29. y = f(x+1) f(6) f(5) y = f(x) f(4) f(3) f(2) f(1) f(0) 0 1 2 3 4 5 6 Integral Method

  30. Integral Method • When f(x) is increasing, summation of 1 to n terms have • Upper bound = integration on f(x+1) from 0 to n • Lower bound = integration on f(x) from 0 to n

  31. f(0) y = f(x) f(1) f(2) y = f(x+1) f(3) f(4) f(5) f(6) 0 1 2 3 4 5 6 Integral Method

  32. Integral Method • When f(x) is decreasing, summation of 1 to n terms have • Upper bound = integration on f(x) from 0 to n • Lower bound = integration on f(x+1) from 0 to n

  33. Example on Integral Method • Use Integral Method to find upper and lower bounds for Summation of i3 from i = 1 to n • i3 is increasing function • Upper bounded by integration on (i+1)3 • Lower bounded by integration on i3

  34. Related Sums • Sn: x + 2x2 + 3x3 + … + nxn • Sn = [x – (n+1)xn+1 + nxn+2] / (1 – x)2 • Sn = x / (1 – x)2 for n  infinity, |x| < 1

  35. Example on Closed form • Express 3 + 3(33) + 5(35) + … + (2n-1)(32n-1) in closed form • 3 + 3(33) + 5(35) + … + (2n-1)(32n-1) • = [3 + 2(32) + 3(33) + … + (2n)(32n)] - 2 [(32) + 2((32)2) + 3((32)3) + … + (n)((32)n)] • = [3 – (2n+1)32n+1 + (2n)32n+2]/(1-3)2 - 2 * [32 – (n+1)32n+1 + (n)32n+4]/(1-32)2 (By Sn = [x – (n+1)xn+1 + nxn+2] / (1 – x)2, take x = 3, and 32) • = [-(n)32n+4 – (17n+1)32n+2 + (16n+8)32n+1 + 15] / 4

  36. Class Work 3 • On 14 Nov, Wednesday • For more than 80% of the class work • Straight Forward, not tricky • No proof is needed (but may include express summation in closed form) • Numbers are selected that calculations (like GCD Algorithm) will not take too many iterations • Make sure understand sample class work

  37. Check List for Number Theory • Include but may not limit to: • Concepts • Applications • Interesting Examples

  38. Concept • Properties on Divisibility • Properties on GCD • Linear Combination & GCD = SPC

  39. Concept • Properties of Prime • Properties of Modular Arithmetic • Multiplicative Inverse & Fermat’s Little Theorem

  40. Concept • Closed Form of Sums • Future and Current Value • Annuity

  41. Application • (Extended) GCD Algorithm (e.g. Q43) • Die Hard Problem (e.g. Q44)

  42. Application • Calculating Date (e.g. Q48) • Evaluating divisibility of 9 and 11 (e.g. Q61) • Calculating Multiplicative Inverse • SPC (GCD) Method (e.g. Q52) • Repeated Squaring (e.g. Q51) • Turing’s Code (Version 1 & 2) (e.g. Q58,59) • RSA (e.g. Q60)

  43. Application • Express in closed form (e.g. Q53) • Annuity (e.g. Q63) • Integral Method (e.g. Q57) • Calculating Future / Current Value (e.g. Q64)

  44. Interesting Example • Examples Discussed during Lectures~

More Related