You are on page 1of 13

Chapter 11

APPLICATIONS OF LINEAR ALGEBRA

Contents
11.1 Cryptography.......................................................................................................................1
11.2 Graph Theory.......................................................................................................................6
______________________________________________________________________________

11.1 Cryptography
Cryptography is a study of encoding and decoding secret messages.

Definition
Ciphers: codes
Plaintext: uncoded messages
Cipher text: coded
- Substitution
ciphersmessages
replacing each letter of the alphabet by a different letter.
Enciphering:
Process
of converting from plaintext to cipher text
Hill Ciphers
Deciphering: Reverse process from cipher text to plaintext

- Sets of n plaintext letters are replaced by sets of n ciphers letters. Each letter is assigned a
numerical value as in Table 1.

A B C D E F G H I J

1 2 3 4 5 6 7 8 9 1
0

11

1
2

1
3

1
4

1
5

1
6

1
7

1
8

1
9

2
0

2
1

2
2

2
3

2
4

2
5

Table 1

In the simplest Hill ciphers, successive pairs of plaintext are transformed into ciphertext by the
following procedure:
Step 1: Choose a 2x2 matrix A to perform the encoding.
Step 2: Group successive plaintext letters into pairs and replace each plaintext letter by its
numerical value.
Step 3: Successively convert each plaintext letter pair into a column vector P and form the
product AP.
Step 4: Convert each cipher-text vector C = AP into its alphabetic equivalent using a modular
arithmetic.

Example 1
4 3

Obtain the Hill cipher of the message DARK NIGHT using the enciphering matrix 1 2 .
Solution
4 3

Let a matrix A is 1 2
DA RK NI GH TT
Thus,
4
1

4
1

3
2
3
2

corresponds to

4 19
1

6
18 105

11
40

4 3 14
1 2 9


4 3 7
1 2 8


4 3 20
1 2 20

83
32

4
1

18
11

14
9

7
8

20
20

1
or
14
5
or
6

52 0
23 or 23

140


60

10
or
8
2

These correspond to the cipher text pairs SF AN EF ZW JH.


The entire cipher text message is SFANEFZWJH as a single string without spaces.

Modular Arithmetic
Modular arithmetic is a technique of working with remainders.
Eg: mod (26): integers greater than 25 will be replaced by their remainders after division by 26.

Definition:
If m (modulus) is a positive integer and a and b are any integers, then a is equivalent to b
modulo m, written
a = b (mod m)
Finding
and Bases
for Eigenspaces
if a - b Eigenvectors
is an integer multiple
of m.

Remark
For any modulus 26, every integer a is equivalent to exactly one of the integers
zm {0,1, 2,..., 25} . This is called the set of residues modulo 26.

Theorem 11.16.1
For any integer a and modulus m, let
|a|
R = remainder of m . Then the residue r of a modulo m is given by

if a 0

r m R if a p 0 and R 0
0
if a p 0 and R 0

Definition:
If m (modulus) is a positive integer and a and b are any integers, then a is equivalent to b
modulo m, written
3
a = b (mod m)
if a - b is an integer multiple of m.

Example 2
Find the residue modulo 26 of

(a) 87

(b) -38

(c) -26

Solution
(a) Dividing |87| = 87 by 26 yields R=9, so r = 9.
Thus, 87 = 9 (mod 26)
(b) Dividing |-38| = 38 by 26 yields R=12, so r = 26 12 = 14.
Thus, -38 = 14 (mod 26)
(c)

Dividing |-26| = 26 by 26 yields R=0.


Thus, --26 = 0 (mod 26)

Definition:
If a is a number in Zm, then a number a-1 in Zm is called a reciprocal or multiplicative
inverse of a modulo m if
aa 1 a 1a 1(mod m)

Example 3
15(7) = 105 = 1 (mod 26)
Table 2 lists the reciprocals modulo 26 for the reference.
a
a-1

1
1

3
9

5
21

7
15

9
3

11
15
19
7
Table 2

17
23

19
11

21
5

23
17

25
25

Deciphering
-

Decipherment uses the inverse (mod 26) of the enciphering matrix in a Hill cipher.
If m is a positive integer, then a square matrix A with entries in Zm is said to be invertible

modulo m if there is a matrix B with entries in Zm such that AB = BA= I (mod m)


In a Hill 2-cipher, successive pairs of plaintext vectors can be recovered from the corresponding
cipher text vectors by the following illustration.

Let

a11
a21

p1
p
2

If p =
p = A-1c.

a12
a22

be invertible modulo 26 and be used in a Hill 2-cipher.

is a plaintext vector, then c = Ap is the corresponding cipher text vector and

Theorem 11.16.2
A square Matrix A with entries in Zm is invertible modulo m iff the residue of det(A)
modulo m has a reciprocal modulo m.

Corollary 11.16.3
A square matrix A with entries in Zm is invertible modulo m iff m and the residue of det(A)
modulo m have no common prime factors.

Corollary 11.6.4
A square matrix A with entries in Z26 is invertible modulo 26 iff the residue of det(A)
modulo 26 is not divisible by 2 or 13.

Remark:

If

a b

c d has entries in Z26, then the inverse of A (mod 26) is given by


d b
A1 (ad bc) 1
(mod 26)
c a

where (ad bc )1 is the reciprocal of the residue of ad bc (mod 26)


Example 5
1 2

Decipher the following Hill 2-cipher, which was enciphered by the matrix 3 5
KRWMBKYL
Solution
1 2

3 5 , det (A) = (1)(5) - (2)(3) = -1 = 25 ( mod 26)


5 2
5 2 125 50 21 2
25


(mod 26)
A 1 (25) 1
3 1
3 1 75 25 3 25

Let A

Deciphering K R W M B K Y L:
21 2

3 25
21 2

3 25

11

18
23


13

267

483
509

394

15
15

G
O
O
D

21 2


3 25
21 2


3 25

2

11
25

12

64

281
549

375

12

21
3

11

L
U
C
K

The message is GOOD LUCK

11.2 Graph Theory


Definition: DIRECTED GRAPHS
A directed graph is a finite set of elements { P 1 , P2 , ,Pn } together with a finite
collection of ordered pairs (Pi , Pj ) of distinct elements of this set, with no ordered pair
being repeated.

Terms in directed graphs:


1. Vertices elements of the set
2. Directed edges ordered pairs (Pi , Pj )
6

3. Pi Pj Pi is connected to Pj
Directed graphs can be presented as a line connecting Pi to Pj.
-

Pi Pj is denoted if Pi Pj and Pj Pi
Directed graphs may have separate component of vertices that are connected only among
themselves or maybe not connected to any other vertex.
Directed graph having n vertices can be represented by n x n matrix called vertex matrix
denoted by M=[mij] is defined for i, j = 1,2,,n as
1 if Pi Pj
0 otherwise

mij

Example 6
P2

[ ]
0 1 0
0 0 1
0 1 0

(1)
P1

P3

(2)

[ ]
0 1 0
0 0 1 1 1
0 0 0
1
0 0
0
1 0

(3)

P2

P3

Example 7: Draw the directed graph

(1)

0
1

0
0
1
0

1
0
0
1

1
1
0

(2)

0
1

1
0

1
0
0
1
0

0
0
0
0
1

1
1
0
0
1

0
0
1

1
0

Theorem 11.7.1:
Let M be the vertex of a directed graph and let m ij(r) be the (i,j)-th element of Mr . Then
mij(r) is equal to the number of r-step connections from Pi to Pj.

The number of 1step connections is mij (either 0 or 1). The number of 2step
connections is calculated from the square of the vertex matrix M2.

By listing the r th- step connections:


1 step connection as Pi Pj
2 step connection as Pi Pj Pm
3 step connection as Pi Pj Pm Pn

M2 =

2 ways of 2- step connections

2
1 0
0 0 0
3
0 0
0
1 0

1 way of 2- step connections


3 ways of 2- step connections

Example 8

[ ]
0
1
1
0

Consider M =

1
0
0
1

1
1
0
1

0
0
1
0

. Find 2-step connections from P3 to P2 and 3 step

connections from P4 to P2 .
Solution

M2 =

M3 =

[ ][ ] [ ]
[ ][ ] [ ]
0
1
1
0

1
0
0
1

1
1
0
1

0
0
1
0

2
1
0
2

0
1
2
0

1
1
2
1

1
1
0
1

M 32 2 2,

0
1
1
0

0
1
1
0

1
0
0
1

1
0
0
1

1
1
0
1

1
1
0
1

0
0
1
0

0
0
1
0

1
2
4
1

2
1
0
2

0
1
2
0

1
1
2
1

3
2
0
3

3
3
2
3

1
1
2
1

1
1
0
1

M 42 3 3

CLIQUES
Definition
A subset S of a directed graph is called a clique if it satisfies the following three
conditions:
The subset S contains at least three vertices
For each pair of vertices Pi and Pj in S, both Pi Pj and Pj Pi
are true (Pi Pj )
There is no larger subset of the vertices that satisfies condition (ii) and contains S.
(The subset is a maximal set satisfying condition (ii))

Example 9

Cliques
{P1 , P3 , P4 }

P2

P3

DOMINANCE-DIRECTED GRAPHS (TOURNAMENTS)

Definition
A dominance-directed graph is a directed graph such that for any distinct pair of
vertices Pi and Pj , either Pi Pj or Pj Pi but not both. (One way directed)

Theorem
In any dominance-directed graph, there is at least one vertex from which there is a 1-step
Definition
or 2-step connection to any other vertex.
The power of a vertex Pi is the sum of the entries of the ith row of the matrix A = M + M2,
where M is the vertex matrix of the dominance directed graph.

10

Example 10

[ ]
0 0 1 1 0
1 0 1 0 1

Consider M =

0 0 0 1 0
0 1 0 0 0
1 0 1 1 0

. Find the power of all vertices Pi.

Solution

0
1

M 2= 1
0 1 0
1 0 2

0 1 0

1 0 1
0 1 1

0 1 1 0
0 1 0 1
0 0 1 0

1 0 0 0
0 1 1 0
1
3
0
0
2

[ ]
0 0 1 1 0
1 0 1 0 1
0 0 0 1 0

0 1 0 0 0
1 0 1 1 0

0
1

0
1

0 1 1 0
0 1 0 1
0 0 1 0

1 0 0 0
0 1 1 0

[ ]
0 0 1 1 0
1 0 1 0 1
0 0 0 1 0

0 1 0 0 0
1 0 1 1 0

0
0
0

1
0

11

[ ]
0 0
1 0
0 0

A=M+M

0
1

1 1 0
0
1 0 1

0
0 1 0 +
1
0 0 0
1 1 0

0 1
1 0

0
0
0
1
0

0
1
0

0
0 +

0
1

1
0

1
1
0
0
1

1
0
1
0
1

1
0
1
0
1

0
2
0
1
1

2
3
1
0
3

0
1
0

1
0 0+1+0+1+0 = 2

1
3
0
0
2

0
0
0

1
0

0 0
0
0

0
0 0

0 0
0
0

0
2

1
1

1
0
1
1
1

1
3
0
1
2

0 0

Power of P1 is 4
Power of P2 is 9
Power of P3 is 2
Exercise:
1.

Power of P4 is 4
Power of P5 is 7

Let

0 1 1 1

1 0 0 0
M
0 1 0 1

0 1 1 0

12

(i)

Draw the directed graph D

(ii) Find the number of 1-step and 2-step connections from P1 P2 .


2.

(sem2, 06/07)

Construct a vertex-matrix of the dominance-directed graph shown and find the power of the
vertex P1 and P5.
(sem1, 04/05)

3.

(i)
(ii)
(iii)

Let M =

0
1
1
1
0

1
0
1
1
1

0
0
0
0
0

1
1
0
0
1

0
0
0
0
0

be the vertex matrix of a directed graph D.

Draw the directed graph D.


Find the number of 2-step connections from P4 to P1.
Determine all clique(s) of D.

(sem1,04/05)

13