• No results found

ENCODING and DECODING

N/A
N/A
Protected

Academic year: 2021

Share "ENCODING and DECODING"

Copied!
53
0
0

Loading.... (view fulltext now)

Full text

(1)

ENCODING and DECODING

Math 1

Mathematics for General Education

Institute of Mathematics University of the Philippines Diliman

(2)

Modular Systems

Recall:

congruence modulo 12 (≡

12

)

a ≡

12

b ⇐⇒ (a − b) is divisible by 12

⇐⇒ a and b have the same remainder when divided by 12

Modulo 12 Addition ⊕

12

a ⊕

12

b = (a + b) mod 12

Modulo 12 Multiplication

12

a

12

b = (a · b) mod 12

(3)

Modular Systems

Recall:

congruence modulo 12 (≡

12

)

a ≡

12

b ⇐⇒ (a − b) is divisible by 12

⇐⇒ a and b have the same remainder when divided by 12

Modulo 12 Addition ⊕

12

a ⊕

12

b = (a + b) mod 12

Modulo 12 Multiplication

12

a

12

b = (a · b) mod 12

(4)

Modular Systems

Recall:

congruence modulo 12 (≡

12

)

a ≡

12

b ⇐⇒ (a − b) is divisible by 12

⇐⇒ a and b have the same remainder when divided by 12

Modulo 12 Addition ⊕

12

a ⊕

12

b = (a + b) mod 12

Modulo 12 Multiplication

12

a

12

b = (a · b) mod 12

(5)

Modular Systems

Recall:

congruence modulo 12 (≡

12

)

a ≡

12

b ⇐⇒ (a − b) is divisible by 12

⇐⇒ a and b have the same remainder when divided by 12

Modulo 12 Addition ⊕

12

a ⊕

12

b = (a + b) mod 12

Modulo 12 Multiplication

12

a

12

b = (a · b) mod 12

(6)

Modular Systems

Recall:

congruence modulo 12 (≡

12

)

a ≡

12

b ⇐⇒ (a − b) is divisible by 12

⇐⇒ a and b have the same remainder when divided by 12

Modulo 12 Addition ⊕

12

a ⊕

12

b = (a + b) mod 12

Modulo 12 Multiplication

12

a

12

b = (a · b) mod 12

(7)

Modular Systems

Recall:

congruence modulo 12 (≡

12

)

a ≡

12

b ⇐⇒ (a − b) is divisible by 12

⇐⇒ a and b have the same remainder when divided by 12

Modulo 12 Addition ⊕

12

a ⊕

12

b = (a + b) mod 12

(8)

Modular Systems

congruence modulo n (≡

n

)

a ≡

n

b ⇐⇒ (a − b) is divisible by n

⇐⇒ a and b have the same remainder when divided by n

Modulo n Addition ⊕

n

a ⊕

n

b = (a + b) mod n

Modulo n Multiplication

n

a

n

b = (a · b) mod n

(9)

Modular Systems

congruence modulo n (≡

n

)

a ≡

n

b ⇐⇒ (a − b) is divisible by n

⇐⇒ a and b have the same remainder when divided by n

Modulo n Addition ⊕

n

a ⊕

n

b = (a + b) mod n

Modulo n Multiplication

n

a

n

b = (a · b) mod n

(10)

Modular Systems

congruence modulo n (≡

n

)

a ≡

n

b ⇐⇒ (a − b) is divisible by n

⇐⇒ a and b have the same remainder when divided by n

Modulo n Addition ⊕

n

a ⊕

n

b = (a + b) mod n

Modulo n Multiplication

n

a

n

b = (a · b) mod n

(11)

Modular Systems

congruence modulo n (≡

n

)

a ≡

n

b ⇐⇒ (a − b) is divisible by n

⇐⇒ a and b have the same remainder when divided by n

Modulo n Addition ⊕

n

a ⊕

n

b = (a + b) mod n

Modulo n Multiplication

n

a

n

b = (a · b) mod n

(12)

Modular Systems

congruence modulo n (≡

n

)

a ≡

n

b ⇐⇒ (a − b) is divisible by n

⇐⇒ a and b have the same remainder when divided by n

Modulo n Addition ⊕

n

a ⊕

n

b = (a + b) mod n

(13)

Modulo 2

a ≡

2

b ⇐⇒ (a − b) is divisible by 2

⇐⇒ a and b have the same remainder when divided by 2

The only possible remainders when we divide an integer by 2 are 0

and 1.

(14)

Modulo 2

a ≡

2

b ⇐⇒ (a − b) is divisible by 2

⇐⇒ a and b have the same remainder when divided by 2

The only possible remainders when we divide an integer by 2 are 0

and 1.

(15)

Modulo 2

a ≡

2

b ⇐⇒ (a − b) is divisible by 2

⇐⇒ a and b have the same remainder when divided by 2

The only possible remainders when we divide an integer by 2 are 0

and 1.

(16)

Modulo 2

a ≡

2

b ⇐⇒ (a − b) is divisible by 2

⇐⇒ a and b have the same remainder when divided by 2

The only possible remainders when we divide an integer by 2 are 0

and 1.

(17)

Modulo 2

Example 4 ≡

2

2 7 ≡

2

3 2 6≡ 5

We let

Z

2

= {0, 1}. Note:

0 represents all even integers

1 represents all odd integers

(18)

Modulo 2

Example 4 ≡

2

2 7 ≡

2

3 2 6≡ 5 We let

Z

2

= {0, 1}.

Note:

0 represents all even integers

1 represents all odd integers

(19)

Modulo 2

Example 4 ≡

2

2 7 ≡

2

3 2 6≡ 5 We let

Z

2

= {0, 1}.

Note:

0 represents all even integers

1 represents all odd integers

(20)

Addition and Multiplication Modulo 2

(21)

Addition and Multiplication Modulo 3

Z

3

= {0, 1, 2}

Note that the possible remainders when we divide a whole number by

3 are 0, 1, and 2.

(22)

Addition and Multiplication Modulo 3

Z

3

= {0, 1, 2}

Note that the possible remainders when we divide a whole number by

3 are 0, 1, and 2.

(23)

Addition and Multiplication Modulo 3

Z

3

= {0, 1, 2}

Note that the possible remainders when we divide a whole number by

3 are 0, 1, and 2.

(24)

Addition and Multiplication Modulo 4

Z

4

= {0, 1, 2, 3}

(25)

Addition and Multiplication Modulo 4

Z

4

= {0, 1, 2, 3}

(26)

Addition and Multiplication Modulo 5

Z

5

= {0, 1, 2, 3, 4}

(27)

Addition and Multiplication Modulo 5

Z

5

= {0, 1, 2, 3, 4}

(28)

Consider Z

26

= {0, 1, · · · , 24, 25}.

Assign to each letter an element of Z

26

.

(29)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10

M = 13

A = 1

T = 20

H = 8

(30)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10

M = 13

A = 1

T = 20

H = 8

(31)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10

To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(32)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 =

W

To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(33)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W

To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(34)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 =

K

To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(35)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K

To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(36)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(37)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 =

D To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(38)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D

To encode H: Let x = 8.

=⇒ y = 8 ⊕ 10 = 18 = R

(39)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D To encode H: Let x = 8.

R

(40)

Encode: MATH

ENCODING FORMULA: y = x ⊕ 10 To encode M: Let x = 13.

=⇒ y = 13 ⊕ 10 = 23 = W To encode A: Let x = 1.

=⇒ y = 1 ⊕ 10 = 11 = K To encode T: Let x = 20.

=⇒ 20 ⊕ 10 = 30 ≡

26

4 = D

To encode H: Let x = 8.

(41)

Encoding Formula: y = x ⊕ 10

Table:Encoding

Encode M A T H

x 13 1 20 8

y 23 11 4 18

Encoded W K D R

(42)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =A D: 4 ⊕ 16 = 20 =T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(43)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x

DECODING FORMULA: x = y ⊕ 16. W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =A D: 4 ⊕ 16 = 20 =T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(44)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =

M K: 11 ⊕ 16 = 27 ≡

26

1 =A D: 4 ⊕ 16 = 20 =T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(45)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M

K: 11 ⊕ 16 = 27 ≡

26

1 =A D: 4 ⊕ 16 = 20 =T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(46)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =

A D: 4 ⊕ 16 = 20 =T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(47)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =A

D: 4 ⊕ 16 = 20 =T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(48)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =A

T

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(49)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =A

R: 18 ⊕ 16 = 34 ≡

26

8 =H

(50)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M K: 11 ⊕ 16 = 27 ≡

26

1 =A

H

(51)

Decode: WKDR

W= 23 K= 11 D= 4 R= 18

To obtain DECODING FORMULA:

Encoding Formula: y = x ⊕ 10

=⇒ y ⊕ 16 = x ⊕ 10 ⊕ 16

=⇒ y ⊕ 16 = x DECODING FORMULA: x = y ⊕ 16.

W: 23 ⊕ 16 = 39 ≡

26

13 =M

K: 11 ⊕ 16 = 27 ≡

26

1 =A

(52)

Decoding Formula: x = x ⊕ 16

Table: Decoding

Decode W K D R

y 23 11 4 18

x 13 1 20 8

Encoded M A T H

(53)

Exercise:

Encoding Formula: y = x ⊕ 20

1

Encode: LOVE

2

Find the Decoding Formula.

3

Decode: U W Y

References

Related documents

If, after the BCD but prior to the conclusion of the applicable Service term, the Service or this Agreement is terminated either by CenturyLink for cause or by the Customer for

• Gas exchange takes place only in the alveoli... The Anatomy of the Respiratory

Only in recent years, after the cable network operators invested heavily in network expansion, were they able, at a high cost for sales and marketing, to bring the

Arsenic, cadmium, lead, selenium, pesticides and other elements were analysed in biological samples from individuals with CKDu and compared with age- and sex-matched controls in

: Effect of ferric carboxymaltose on serum phosphate and C-terminal FGF23 levels in non-dialysis chronic kidney disease patients: post-hoc analysis of a prospective study.

AL: axial length; ETDR: Early treatment of diabetic retinopathy; FAZ: Fovea avascular zone; ICC: Intraclass correlation coefficient; ICC adj : Adjusted ICC; OCTA: Optical