Download - Analyzing Series
![Page 1: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/1.jpg)
Analyzing Series
CSC2110 Tutorial 9
Darek Yung
![Page 2: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/2.jpg)
Outline
Continue on Cryptography Review on Series Examples Class Work 3
![Page 3: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/3.jpg)
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!!!
![Page 4: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/4.jpg)
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
![Page 5: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/5.jpg)
RSA
p = 13, q = 37: Calculate n = pq, T = (p-1)(q-1)
N = (13)(37) = 481 T = (p-1)(q-1) = 432
![Page 6: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/6.jpg)
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
![Page 7: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/7.jpg)
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)
![Page 8: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/8.jpg)
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 nu
mbers will be small~
![Page 9: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/9.jpg)
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
![Page 10: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/10.jpg)
Another RSA
p = 17, q = 41: Calculate n = pq, T = (p-1)(q-1)
N = (13)(37) = 697 T = (p-1)(q-1) = 680
![Page 11: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/11.jpg)
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
![Page 12: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/12.jpg)
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)
![Page 13: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/13.jpg)
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)
![Page 14: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/14.jpg)
Review on Series
Geometric Series Future and Current Value Annuity Related Sums (talk after Rental Problem) Integral Method (talk after Rental Problem)
![Page 15: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/15.jpg)
Geometric Series
Gn: 1 + x + x2 +x3 + … + xn
Gn = (1 – xn+1) / (1 – x)
Gn = 1 / (1 – x) for n infinity, |x| < 1
![Page 16: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/16.jpg)
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
![Page 17: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/17.jpg)
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]
![Page 18: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/18.jpg)
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?
![Page 19: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/19.jpg)
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
![Page 20: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/20.jpg)
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
![Page 21: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/21.jpg)
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 con
tribute $ [ m * (1+r)20-i ] Therefore, total money after 20 years M is
![Page 22: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/22.jpg)
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
![Page 23: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/23.jpg)
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?
![Page 24: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/24.jpg)
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
![Page 25: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/25.jpg)
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
![Page 26: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/26.jpg)
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 con
tribute $ [ m * (1+r)20-i ] Therefore, total money after 20 years M is
![Page 27: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/27.jpg)
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
![Page 28: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/28.jpg)
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 contribu
te 2,000,000 * 30% * (1+12%)20
= $5,787,776 after 20 years Therefore, total amount of money = $6,323,126
![Page 29: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/29.jpg)
Integral Method
f(1)
f(2)
f(3)f(4)
f(5) f(6)
0 1 2 3 4 5 6
f(0)
y = f(x)
y = f(x+1)
![Page 30: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/30.jpg)
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
![Page 31: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/31.jpg)
f(5)f(4)f(3)
f(2)f(1)
f(0)
0 1 2 3 4 5 6
f(6)
Integral Method
y = f(x)
y = f(x+1)
![Page 32: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/32.jpg)
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
![Page 33: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/33.jpg)
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
![Page 34: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/34.jpg)
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
![Page 35: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/35.jpg)
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
![Page 36: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/36.jpg)
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
![Page 37: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/37.jpg)
Check List for Number Theory
Include but may not limit to: Concepts Applications Interesting Examples
![Page 38: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/38.jpg)
Concept
Properties on Divisibility Properties on GCD Linear Combination & GCD = SPC
![Page 39: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/39.jpg)
Concept
Properties of Prime Properties of Modular Arithmetic Multiplicative Inverse & Fermat’s Little
Theorem
![Page 40: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/40.jpg)
Concept
Closed Form of Sums Future and Current Value Annuity
![Page 41: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/41.jpg)
Application
(Extended) GCD Algorithm (e.g. Q43) Die Hard Problem (e.g. Q44)
![Page 42: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/42.jpg)
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)
![Page 43: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/43.jpg)
Application
Express in closed form (e.g. Q53) Annuity (e.g. Q63) Integral Method (e.g. Q57) Calculating Future / Current Value (e.g.
Q64)
![Page 44: Analyzing Series](https://reader035.vdocuments.net/reader035/viewer/2022062722/568139c0550346895da164ca/html5/thumbnails/44.jpg)
Interesting Example
Examples Discussed during Lectures~