75
GEK1505: Chapter 4 – Clocking Chapter 4 – Clocking 1 / 75

efweaf wer

Embed Size (px)

DESCRIPTION

mean

Citation preview

Page 1: efweaf wer

GEK1505: Chapter 4 – Clocking

Chapter 4 – Clocking 1 / 75

Page 2: efweaf wer

Overview

1 Parity of integers & Clock arithmetic

2 Periodic Movements

3 Congruence equations

4 Dates & days of the week

Chapter 4 – Clocking 2 / 75

Page 3: efweaf wer

Parity of integers

Integers (Z):

. . . ,−4,−3,−2,−1, 0, 1, 2, 3, 4, . . . .

Positive integers (Z+) :

1, 2, 3, 4, . . . .

Negative integers (Z−) :

. . . ,−4,−3,−2,−1

Chapter 4 – Clocking 3 / 75

Page 4: efweaf wer

Parity of integers

Even integers:

. . . ,−6,−4,−2, 0, 2, 4, 6 . . . .

Odd integers:

. . . ,−5,−3,−1, 1, 3, 5, . . . .

Chapter 4 – Clocking 4 / 75

Page 5: efweaf wer

Parity of integers

Mathematically, an even integer is defined to be an integer of the form

2n, where n ∈ Z.

An odd integer is defined to be an integer of the form

2n + 1, where n ∈ Z.

Chapter 4 – Clocking 5 / 75

Page 6: efweaf wer

Parity of integers

Parity

Two integers are said to be of the same parity if they are either both oddor both even.

Chapter 4 – Clocking 6 / 75

Page 7: efweaf wer

Parity of integers

Proposition

If two integers are of the same parity, then their difference is an eveninteger.

Proof:If they are both even, then they can be written as 2n and 2m, wherem, n ∈ Z. Their difference is then 2(m − n) which is again even.If they are both odd, then they can be written as 2n + 1 and 2m + 1.Their difference is then 2(m − n) which is even.

Chapter 4 – Clocking 7 / 75

Page 8: efweaf wer

Parity of integers

Example

A staircase has n steps. Suppose you walk down the staircase starting withyou right foot first. With which foot would you land at the n-th step –right or left?

Solution.

Step: 1 2 3 4 5 6 7 8 9 10 11 12 . . .Leg: R L R L R L R L R L R L

n odd: R

n even: L

Chapter 4 – Clocking 8 / 75

Page 9: efweaf wer

Clock arithmetic

Keeping track of time using the 24-hour clock.

Time in a day is denoted by

hh.mm.ss

where

hh (hours) is an integer from 00 to 23.

mm (minutes) is an integer from 00 to 59.

ss (seconds) is an integer from 00 to 59.

Chapter 4 – Clocking 9 / 75

Page 10: efweaf wer

Clock arithmetic

When the seconds are not involved, we often write

hh.mm or hhmm

Example: 09.00 is 9 am, 1400 is 2 pm etc.

Chapter 4 – Clocking 10 / 75

Page 11: efweaf wer

Clock arithmetic

Example

Left Singapore on a flight to London at 11 : 00 pm on 1 Jan 2001.

Reached London and made a phone call to Singapore 15 hours later.

What was the time and date in Singapore when the call was receivedin Singapore?

Chapter 4 – Clocking 11 / 75

Page 12: efweaf wer

Clock arithmetic

Solution.

The departure time is 2300 on 1 Jan 2001.

15 hours later, the time is

2300 + 1500 = 3800

Subtracting 24 hours from 3800, the time is

1400 on 2 Jan 2001.

Chapter 4 – Clocking 12 / 75

Page 13: efweaf wer

Clock arithmetic

Example

An expedition left base at 0800 on 5 April

Reached the summit of the peak 100 hours later

Find the time and date on reaching the summit.

Solution.08.00 + 100.00 = 108.00

Note that108 = 24× 4︸︷︷︸

days

+12.

Answer: 12.00 on 9 April.

Chapter 4 – Clocking 13 / 75

Page 14: efweaf wer

Clock arithmetic

Example

A 99-hour operation was finally completed at 1 pm on 10 August.

When was the operation begun?

Solution. Subtract 99 from 1300:

13.00− 99.00 = −86.00.

Note that−86 = 24× (−4)︸︷︷︸

days

+10.

Answer: 1000 on 6 August.

Chapter 4 – Clocking 14 / 75

Page 15: efweaf wer

Periodic movements

Example

A frog starts leaping from the left end of the following row of boulders.

The frog leaps to an adjacent boulder in an easterly direction every oneminute.

When it reaches the extreme right boulder, it reverses its direction andleaps westward to the adjacent boulder, also every one minute.

On which boulder will the frog be 38 minutes later?

On which boulder will the frog be n minutes later?

Chapter 4 – Clocking 15 / 75

Page 16: efweaf wer

Periodic movements

Solution.

Time (in min): 0 1 2 3 4 5 6 7 8 9 10Boulder: 0 1 2 3 4 5 4 3 2 1 0

Note that

38 = 10× 3 + 8.

Answer: On boulder 2.

Chapter 4 – Clocking 16 / 75

Page 17: efweaf wer

Periodic movements

Generally, let r be the reminder after dividing n by 10. That is

n = 10× q + r

for some integer q ≥ 0 and0 ≤ r ≤ 9.

Then, the frog will be on bolder{r if 0 ≤ r ≤ 5

10− r if 6 ≤ r ≤ 9

Time (in min): 0 1 2 3 4 5 6 7 8 9 10Boulder: 0 1 2 3 4 5 4 3 2 1 0

Chapter 4 – Clocking 17 / 75

Page 18: efweaf wer

Periodic movements

Example

Suppose in the previous example, there are exactly k boulders in a row,and that the movement of the frog is as before.

(a) What is the period of movement of the frog?

(b) If the frog starts at the left end, find a general expression for theposition of the frog at the n-th minute.

Chapter 4 – Clocking 18 / 75

Page 19: efweaf wer

Periodic movements

Solution.

(a) Period of movement is 2(k − 1) minutes.

(b) Let r be the remainder of n when divided by the period 2(k − 1).

If 0 ≤ r ≤ k − 1, the frog is on boulder r .

if k ≤ r ≤ 2(k − 1)− 1, the frog is on boulder 2(k − 1)− r .

Chapter 4 – Clocking 19 / 75

Page 20: efweaf wer

Periodic movements

Example

A flight of stairs has 5 steps (see figure on the next page). You comedown from the top of the stairs one step at a time starting with the rightfoot. When you reach the bottom, you turn round and go back up again;When you reach the top, you turn round and go down again.

Suppose every step is taken with the foot different from the previous step,

(a) Show you will be at the top of the stairs after 100 steps starting fromthe top.

(b) Where will you be after 39 steps?

Chapter 4 – Clocking 20 / 75

Page 21: efweaf wer

Periodic movements

Solution.

Steps: 0 1 2 3 4 5 6 7 8 9 10Landing 0 1 2 3 4 5 4 3 2 1 0

Chapter 4 – Clocking 21 / 75

Page 22: efweaf wer

Periodic movements

(a) Starting from the top (0), you will be at the top again after every10-th step.

Since 100 = 10× 10, you will be at the top at the 100-th step.

(b) Note that39 = 3× 10 + 9.

At the 39-th step, you will be on landing number 1 on your right foot.

Chapter 4 – Clocking 22 / 75

Page 23: efweaf wer

Periodic movements

Example

Starting from the corner A of a square ABCD, an insect moves at eachstep from one corner to an adjacent corner in the clockwise direction.

At which corner will the insect be after n steps?

Chapter 4 – Clocking 23 / 75

Page 24: efweaf wer

Periodic movements

Solution. Label the corners A, B, C , D by 0, 1, 2, 3 respectively.

Steps: 0 1 2 3 4 5 6 7 8 9 . . .Corner 0 1 2 3 0 1 2 3 0 1 . . .

Period of movement is 4.

Let r be the remainder of n when divided by 4.

At the n-th step, the insect will be at corner r .

Chapter 4 – Clocking 24 / 75

Page 25: efweaf wer

Periodic movements

Example

A rectangular grid has 9 vertices labelled by 0, 1, 2, 3, 4, 5, 6, 7, 8 (seefigure on the next page).

A particle moves from one vertex to another in the direction

0→ 1→ 2→ 3→ 4→ 5→ 6→ 7→ 8→ 3→ 4→ 5→ 0→ · · ·

and so on.

If it starts from vertex 0 and each movement of the particle takes onesecond, where will it be

(a) in 3 minutes?

(b) in t seconds?

Chapter 4 – Clocking 25 / 75

Page 26: efweaf wer

Periodic movements

Chapter 4 – Clocking 26 / 75

Page 27: efweaf wer

Periodic movements

Solution.

Time (seconds): 0 1 2 3 4 5 6 7 8 9 10 11Vertex 0 1 2 3 4 5 6 7 8 3 4 5

Period of movement is 12.

Let r be the remainder of t when divided by 12.

If 0 ≤ r ≤ 8, then its position is at vertex r .

If 9 ≤ r ≤ 11, then its position is at vertex r − 6.

Chapter 4 – Clocking 27 / 75

Page 28: efweaf wer

Periodic movements

Example

Refer to the previous example. Suppose now a second particle leavesvertex 0 three seconds after the first particle.

Assume that the particles move in the same pattern.

Will they ever collide?

Chapter 4 – Clocking 28 / 75

Page 29: efweaf wer

Periodic movements

Solution. The movement of the second particle is the same as the firstbut is 3 steps behind.

position of 1st particle 0 1 2 3 4 5 6 7 8 3 4 5

position of 2nd particle 3 4 5 0 1 2 3 4 5 6 7 8

They will never collide.

Chapter 4 – Clocking 29 / 75

Page 30: efweaf wer

Congruence

Modular arithmetic (clock arithmetic):

arithmetic to deal with periodic computations

first introduced by Gauss in the 19-th century

very much like ordinary arithmetic

Chapter 4 – Clocking 30 / 75

Page 31: efweaf wer

Congruence

Johann Carl Friedrich GaussBorn: 30 April 1777 Brunswick, GermanDied: 23 February 1855 (aged 77), Gottingen, Germany

Chapter 4 – Clocking 31 / 75

Page 32: efweaf wer

Congruence

Statue of Gauss at his birthplace, Brunswick

Chapter 4 – Clocking 32 / 75

Page 33: efweaf wer

Periodic movements

German 10-Deutsche Mark Banknote (1993; discontinued) featuring Gauss

Chapter 4 – Clocking 33 / 75

Page 34: efweaf wer

Congruence

Gauss (aged about 26) on East German stamp produced in 1977.Next to him: heptadecagon, compass and straightedge.

Chapter 4 – Clocking 34 / 75

Page 35: efweaf wer

Congruence

Definition

Suppose a and b are integers such that their difference is a multiple of apositive integer n. Then we write

a ≡ b (mod n).

“a is congruent to b.”

The above equation is called a congruence equation or simplycongruence. The integer n is called the modulus.

Chapter 4 – Clocking 35 / 75

Page 36: efweaf wer

Congruence

Example

If we use the 24 hour-clock, then n = 24.If

a ≡ b (mod n)

then a and b are the same time but may be on different days.

Example

If we use the 12 hour-clock, then n = 12.If

a ≡ b (mod n)

then a and b are the same time but may be on different halves of differentdays.

Chapter 4 – Clocking 36 / 75

Page 37: efweaf wer

Congruence

Caution. Numbers which are not integers (e.g. fractions) are notpermitted in any congruence equation.

Chapter 4 – Clocking 37 / 75

Page 38: efweaf wer

Congruence

Property 1

If the remainder of a when divided by n is r , then

a ≡ r (mod n).

This is true because a− r is a multiple of n.

Chapter 4 – Clocking 38 / 75

Page 39: efweaf wer

Congruence

Example

The remainder of 322 when divided by 3 is 1. Thus

322 ≡ 1 (mod 3).

Chapter 4 – Clocking 39 / 75

Page 40: efweaf wer

Congruence

Property 2

a ≡ b (mod n) iff a and b have the same remainder when divided by n.

Proof:Suppose the remainders of a and b when divided by n are r and srespectively. Then both a− r and b − s are multiples of n.Therefore their difference (a− r)− (b − s) = (a− b)− (r − s) is also amultiple of n.Thus a− b is a multiple of n iff r − s is a multiple of n.Since r and s both lie between 0 and n − 1, r − s is a multiple of n iffr − s = 0.Therefore a ≡ b (mod n) iff r = s.

Chapter 4 – Clocking 40 / 75

Page 41: efweaf wer

Congruence

Remark

If a ≡ b (mod n) and the remainder of b when divided by n is s, thena ≡ s (mod n).

In other words, you can replace a number in a congruence by its remainderwhen divided by n.This is very useful when you do calculations in congruences.

Chapter 4 – Clocking 41 / 75

Page 42: efweaf wer

Congruence

Example

Both 9 and 23 leave 2 as remainder when divided by 7, so

9 ≡ 23 (mod 7)

Chapter 4 – Clocking 42 / 75

Page 43: efweaf wer

Congruence

Property 3

If a ≡ b (mod n), then a ≡ b ± n (mod n)

This is certainly true since a− b is a multiple of n implies thata− (b ± n) = (a− b)∓ n is also a multiple of n.

Example

23 ≡ 38 (mod 5) ⇒ 23 ≡ 33 (mod 5)

Chapter 4 – Clocking 43 / 75

Page 44: efweaf wer

Congruence

Property 4

You may multiply a congruence by any integer.

Example

Multiplying 321 ≡ 123 (mod 9) by 5, we get

1605 ≡ 615 (mod 9).

Chapter 4 – Clocking 44 / 75

Page 45: efweaf wer

Congruence

Property 5

You may add any integer to both sides of a congruence.

Chapter 4 – Clocking 45 / 75

Page 46: efweaf wer

Congruence

Example

Add 7 to the congruence 321 ≡ 123 (mod 9) to get

328 ≡ 130 (mod 9).

Example

Subtract 7 from both sides of the congruence 321 ≡ 123 (mod 9) to get

314 ≡ 116 (mod 9).

Chapter 4 – Clocking 46 / 75

Page 47: efweaf wer

Congruence

Property 6

You may raise both sides of a congruence to the same positive exponent(power).

Caution. Negative exponents are not allowed.

Chapter 4 – Clocking 47 / 75

Page 48: efweaf wer

Congruence

Example

Square both sides of the congruence 321 ≡ 6 (mod 9) to get

103041 ≡ 36 (mod 9).

Example

Cube both sides of the congruence 321 ≡ 6 (mod 9) to get

33076161 ≡ 216 (mod 9).

Chapter 4 – Clocking 48 / 75

Page 49: efweaf wer

Congruence

Property 7

Congruences have the so-called transitive property:

If a ≡ b (mod n) and b ≡ c (mod n), then

a ≡ c (mod n).

Caution. The modulus must the same throughout.

Chapter 4 – Clocking 49 / 75

Page 50: efweaf wer

Congruence

Example

Since 103041 ≡ 36 (mod 9) and 36 ≡ 0 (mod n), it follows that

103041 ≡ 0 (mod 9).

Chapter 4 – Clocking 50 / 75

Page 51: efweaf wer

Congruence

Property 8

Two congruences with the same modulus may be added to each other ormultiplied one by the other:

If a ≡ b (mod n) and c ≡ d (mod n) then

a + c ≡ b + d (mod n)

ac ≡ bd (mod n)

Chapter 4 – Clocking 51 / 75

Page 52: efweaf wer

Congruence

Example

From the congruences 33 ≡ 6 (mod 7) and 53 ≡ 6 (mod 7), we obtain thecongruences

33 + 53 ≡ 6 + 6 (mod 7)

33 × 53 ≡ 6× 6 (mod 7)

Since 12 ≡ 5 (mod 7) and 36 ≡ 1 (mod 7), we deduce from the transitiveproperty that

33 + 53 ≡ 5 (mod 7)

33 × 53 ≡ 1 (mod 7)

Chapter 4 – Clocking 52 / 75

Page 53: efweaf wer

Congruence

Example

During a period of 50 days, you put the following amount of money intoyour piggy bank:

Day 1 Day 2 Day 3 Day 4 Day 5 · · · Day k

1 cent 2 cents 4 cents 8 cents 16 cents · · · 2k−1 cents

Finally, you exchange the total amount for dollar notes.

How many cents will be left over?

Chapter 4 – Clocking 53 / 75

Page 54: efweaf wer

Congruence

Solution. The total amount in cents is

1 + 2 + 22 + · · ·+ 249 = 250 − 1.

We need to find the remainder of 250 − 1 when divided by 100.

Note that250 = 25 × · · · × 25︸ ︷︷ ︸

10

= 1024× · · · × 1024︸ ︷︷ ︸5

Chapter 4 – Clocking 54 / 75

Page 55: efweaf wer

Congruence

Since 1024 ≡ 24 (mod 100), we have

250 ≡ 24× · · · × 24︸ ︷︷ ︸5

≡ 245 ≡ 24 (mod 100).

Therefore,

250 − 1 ≡ 24− 1 (mod 100)

≡ 23 (mod 100).

Hence, 23 cents are left over.

Chapter 4 – Clocking 55 / 75

Page 56: efweaf wer

Application: Congruence mod 9

Example

Is 12456 divisible by 9?

Solution:

12346 = 1×104+2×103+3×102+4×10+6 ≡ 1+2+3+4+6 ≡ 8 (mod 9).

Therefore the answer is no.

Chapter 4 – Clocking 56 / 75

Page 57: efweaf wer

Application: Congruence mod 9

Theorem (Congruence mod 9)

Let S be the sum of the digits of the decimal representation of the positiveinteger N. Then

(a) N ≡ S (mod 9)

(b) N is divisible by 9 if and only if S is divisible by 9.

Chapter 4 – Clocking 57 / 75

Page 58: efweaf wer

Application: Congruence mod 9

Example

Is 123456 divisible by 9? What about 12345678?

Solution.

N = 123456. Then

S = 1 + 2 + 3 + 4 + 5 + 6 = 21.

Since 21 is not divisible by 9, so 123456 is also not divisible by 9.

Chapter 4 – Clocking 58 / 75

Page 59: efweaf wer

Application: Congruence mod 9

N = 12345678. Then

S = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36.

Since 36 is divisible by 9, 12345678 is also divisible by 9.

Chapter 4 – Clocking 59 / 75

Page 60: efweaf wer

Application: Congruence mod 9

Checking product

Suppose A× B = C . Then

S × T ≡ U (mod 9)

where S , T and U are the sums of digits of A, B, C respectively.

Chapter 4 – Clocking 60 / 75

Page 61: efweaf wer

Application: Congruence mod 9

Example

Without evaluating the product, show that the following multiplicationcannot be correct:

5318× 11223344 = 596855292.

Solution. If the product is correct then

(5 + 3 + 1 + 8)× (1 + 1 + 2 + 2 + 3 + 3 + 4 + 4)

≡ (5 + 9 + 6 + 8 + 5 + 5 + 2 + 9 + 2) (mod 9)

Chapter 4 – Clocking 61 / 75

Page 62: efweaf wer

Application: Congruence mod 9

17× 20 ≡ 51 (mod 9)

8× 2 ≡ 6 (mod 9)

which is false!

Chapter 4 – Clocking 62 / 75

Page 63: efweaf wer

Application: Congruence mod 9

Example

Without evaluating the product, show that the following multiplicationcannot be correct:

12345678× 87654321 + 23456789× 98765432 = 11046314× 297634189.

Chapter 4 – Clocking 63 / 75

Page 64: efweaf wer

Application: Congruence mod 9

Solution. Replace the equation by congruence equation modulo 9:

12345678 ≡ 0 (mod 9)

87654321 ≡ 0 (mod 9)

23456789 ≡ 8 (mod 9)

98765432 ≡ 8 (mod 9)

11046314 ≡ 2 (mod 9)

297634189 ≡ 4 (mod 9)

Chapter 4 – Clocking 64 / 75

Page 65: efweaf wer

Application: Congruence mod 9

If the equation is correct, then

0× 0 + 8× 8 ≡ 2× 4 (mod 9)

64 ≡ 8 (mod 9)

1 ≡ 8 (mod 9)

which is false!

Chapter 4 – Clocking 65 / 75

Page 66: efweaf wer

Dates & Days of the Week

Calendrical Knowledge

January (31) July (31)February (28/29) August (31)March (31) September (30)April (30) October (31)May (31) November (30)June (30) December (31)

YYYY is a leap year if and only if

it is not a century year (YY00) and it is dividable by 4; or

it is a century year and is divisible by 400.

Chapter 4 – Clocking 66 / 75

Page 67: efweaf wer

Dates & Days of the Week

Question.

Suppose the dates D0 and D1 fall on Day r and s, respectively, of theweek.

Given that one of r , s is known, want to determine the other.

Chapter 4 – Clocking 67 / 75

Page 68: efweaf wer

Dates & Days of the Week

Let x denote the distance between date D1 and D0, i.e., x is the numberof days between the two dates.

Example: The distance between D0 = 1 January 2002 andD1 = 31 January 2002 is 30 days.

Chapter 4 – Clocking 68 / 75

Page 69: efweaf wer

Dates & Days of the Week

Label days modulo 7 as follows:

Sunday 0Monday 1Tuesday 2

Wednesday 3Thursday 4

Friday 5Saturday 6

Chapter 4 – Clocking 69 / 75

Page 70: efweaf wer

Dates & Days of the Week

Theorem (Day of the week)

Suppose the day of the week of D1 is s, the day of the week of D0 is r ,and the distance between these dates is x . Assuming that D0 falls beforeD1, then

r + x ≡ s (mod 7)

Chapter 4 – Clocking 70 / 75

Page 71: efweaf wer

Dates & Days of the Week

Example

Find the day of the week of 9 August 1965, given that 1-1-2014 isWednesday.

Solution. Let

Day of the week Date

D0 : r 9 August 1965D1 : s = 3 1 January 2014

First, find the distance x between these dates. Beware of leap years!

Chapter 4 – Clocking 71 / 75

Page 72: efweaf wer

Dates & Days of the Week

There are 48 years from 1966 to 2013.

There are 12 leaps years:

1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012︸ ︷︷ ︸12

After accounting for leap years:The number of days: 48× 365 + 12 ≡ 48 + 12 ≡ 4 (mod 7).

Chapter 4 – Clocking 72 / 75

Page 73: efweaf wer

Dates & Days of the Week

The number of days from 09.08.1965 to 31.12.1965 is

22 + 30 + 31 + 30 + 31 ≡ 4 (mod 7).

Thereforex ≡ 4 + 4 + 1 ≡ 2 (mod 7).

Thusr + x ≡ r + 2 ≡ 3 (mod 7).

So r = 1 and 9 August 1965 is a Monday.

Chapter 4 – Clocking 73 / 75

Page 74: efweaf wer

Dates & Days of the Week

Example

What is the day of the week of 20 July 1969? This is the first day manlanded on the moon.

Solution. Use the fact that D0 = 09 August 1965 is a Monday, so r = 1.

Chapter 4 – Clocking 74 / 75

Page 75: efweaf wer

Dates & Days of the Week

We break up into 3 periods: 9-8-65 to 31-12-65, years 1966 to 1968, and1-1-69 to 20-7-69:

x = (22+30+31+30+31)+(3×365+1)+(31+28+31+30+31+30+20)

≡ 4 + 4 + 5 ≡ 6 (mod 7)

Therefores ≡ r + x ≡ 1 + 6 ≡ 0 (mod 7).

Thus the answer is Sunday.

Chapter 4 – Clocking 75 / 75