Академический Документы
Профессиональный Документы
Культура Документы
by
Joshua Boone
Bachelor of Science in Mathematics, Southern Illinois University, 2006
A Research Report
Submitted in Partial Fulfillment of the Requirements for the
Master of Science Degree
Department of Mathematics
in the Graduate School
Southern Illinois University Carbondale
July, 2008
By
Joshua Boone
Approved by:
Dr. Robert Fitzgerald, Chair
Dr. Jerzy Kocik
Dr. David W. Kammler
Graduate School
Southern Illinois University Carbondale
June 30, 2008
ii
TABLE OF CONTENTS
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ii
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iv
1 Prerequisites
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1
Elementary Cryptography . . . . . . . . . . . . . . . . . . . . . . .
1.2
1.3
2.1
The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2
3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
19
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
Vita . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
iii
LIST OF FIGURES
3.1
12
3.2
13
3.3
The partitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
3.4
15
3.5
16
3.6
The partitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
3.7
18
iv
CHAPTER 1
PREREQUISITES
1.1
ELEMENTARY CRYPTOGRAPHY
In simplest terms, cryptography can be thought of as the study of hiding
information from unwanted viewers. One of the most ancient applications of cryptography is transmission of secret messages. A cryptogram is an example of this
application.
Definition. A substitution cryptogram is a message in which each letter is replaced
by another in a one-to-one manner. The method by which this is done is called the
substitution cipher. Whitespace and punctuation are removed entirely.
Definition. A shift cipher is a substitution cipher Cs in which each letter is mapped
to another letter by a constant shift 1 s 26. If we assign a number to each
letter, beginning with 1 for A, 2 for B, all the way to 26 for Z, then we can write
Cs () = + s (mod 26), where 1 26 corresponds to a letter in our alphabet.
Example 1.1.1. Austin wants to send Bob the message Kenny is great using
the C2 shift cipher. Notice that the letter Y will be mapped to A. The encrypted
message would be MGPPAKUITGCV. To decrypt, Bob would simply use the
inverse (here, C24 ) cipher on the message.
1.2
vv
U1 AW1
1 x
,
=S=
0 B
(1.1)
1
1
1
12 + x x = (12 + x x)1/2
,
0 B
x
x
2
(1.2)
which implies kSk2 (12 + x x)1/2 . Since U1 and W1 are unitary, we can see that
kSk2 = kAk2 = 1 , so x = 0.
0
1 0 1 0 1
W1
A = U1
0 W2
0 2
0 U2
(1.3)
is an SVD of A.
An important piece of information is the rank of the matrix A, which can be
determined as follows:
Theorem 1.2.2. The rank of A is r, the number of nonzero singular values.
Proof. The rank of a diagonal matrix is the number of nonzero entries. Since, in
A = U W , U and W are of full rank, the rank of A is the rank of , which is
r.
For the sake of this particular paper, it is more useful to consider the SVD as
a sum of rank-one matrices, as follows:
Theorem 1.2.3. The matrix A Cmn can be written as the sum of r rank-one
matrices, where r is the rank of A. In other words,
A=
r
X
j uj wj .
j=1
(1.4)
1.3
Perron-Frobenius theorem gives us all the information we need. We will assume the
following topological fact in order to prove this theorem. This material is taken
from [3].
Theorem 1.3.1. (Brouwers Fixed Point Theorem). Let S be a nonempty, closed,
bounded, convex set in Rn . Let f : S S be a continuous map. Then there exists
an x S such that f (x) = x.
The following theorem is one of the most important theorems in matrix theory. There are many versions of this theorem, but the following simple version is
sufficient. Here, the notation A > 0 means the matrix A has only positive entries.
Theorem 1.3.2. (Perron-Frobenius Theorem). Let A > 0 be an n n matrix.
Then:
(i) Ay = 0 y for some 0 > 0, y > 0
(ii) The eigenvalue 0 is maximal in modulus among all the eigenvalues of A. In
other words, for any eigenvaue e of A, |e| 0 .
(iii) The eigenvalue 0 is geometrically simple, so that any two eigenvectors corresponding to 0 are linearly dependent.
(iv) Any positive eigenvector of A (of any eigenvalue) is a scalar multiple of y.
Proof.
(i) Let
(
S=
(x1 , x2 , ..., xn )T :
Here (Ax)i is the i-th coordinate of Ax. Since A > 0, x S implies that
the vector Ax is nonzero and the map f is well-defined. It is easy to check
that f is continuous and maps S into S. By Brouwers Fixed Point Theorem,
f (y) = y for some y S. Thus
(
X
)1
(Ay)i
Ay = y.
If we set
i (Ay)i
that y > 0.
(ii) If we apply (i) to AT , we see that AT z = 1 z for some 1 > 0, z > 0. Now
1 y T z = y T AT z = 0 y T z,
and since y T z > 0, we have 0 = 1 . Thus AT z = 0 z. Let Au = eu for
some eigenvalue e C. Let u+ be defined by u+ = (|u1 |, |u2 |, ..., |un |)T , where
u = (u1 , u2 , ..., un )T . Without loss of generality, let u+ be a probability vector.
We have
X
j
X
aij |uj |
aij uj = |eui | = |e||ui |.
j
(iii) Suppose Av = 0 v for some real, nonzero vector v. We want to show that v is
a scalar multiple of y. If v and y are linearly independent, then R such
that y v is a nonnegative, nonzero vector with at least one zero coordinate.
Since
A(y v) = 0 (y v),
we see that y v is an eigenvector of A. However, since A > 0, any nonnegative eigenvector must be postive. This is a contradiction. Thus, v is a
scalar multiple of y. By considering the real and imaginary part separately,
we can show that any complex eigenvector of A corresponding to 0 is a scalar
multiple of y.
(iv) Suppose Au = eu for u > 0. Then ez T u = z T Au = z T u. Since z T u > 0, we
have e = 0 . The rest follows from (iii).
CHAPTER 2
CONSONANT/VOWEL PARTITIONING VIA SINGULAR VALUE
ANALYSIS
2.1
THE PROBLEM
Now we are ready to discuss the problem of breaking a given cryptogram. The
idea that follows is from [4]. Our entire scheme relies on the fact that, in the English
language, vowels usually follow consonants and vice versa. This is why English is
referred to as a vfc language. Formally, if
number of consonant-vowel pairs
number of vowel-vowel pairs
<
number of vowels
number of consonants
(2.1)
(2.2)
So, our problem is simply this: Given A, find a v and c so that (2.2) holds.
8
2.2
r
X
j uj wjT .
j=1
Since we are considering only real matrices, the hermitian conjugate is simply
the transpose, as shown above. By the normalization of uj and wj , we see that the
matrices uj wjT have the same norm. In other words, if the j decrease rather rapidly,
we can find a decent approximation to A by taking only a few terms. A truncation
after 1 term is a rank-one approximation, after 2 is a rank-two approximation, et
cetera. The rank-two approximation is the first approximation that has information
about corresponding pairs of letters (rank-one assumes A is symmetric). We will
take this approximation:
A A2 = 1 u1 w1T + 2 u2 w2T
(2.3)
and attempt to solve our problem assuming A = A2 , that is, that A has rank equal
to 2. In an attempt to solve this problem, it is necessary to create a third partition,
that we will refer as neuter, which holds letters that are neither vowels or consonants.
Although there are no neuter letters in the English alphabet, consonants like h that
follow consonants regularly in normal language would fall into this category (as a
consonant exhibiting vowel-like behavior).
We will use the partitions on the following page, where the ui2 and wi2 are
the entries of the u2 and w2 , respectively. Theorem 2.2.1 will show that these
partitions are the solution to our problem.
vi =
ci =
ni =
otherwise
otherwise
1 if sign(ui2 ) = sign(wi2 )
otherwise
Theorem 2.2.1. (Moler and Morrison, 1983). Let A = A2 be a nonnegative ranktwo matrix with SVD expansion as in (2.3). Let v and c be defined as above. Then
10
In the next chapter, two examples of the process are shown. Since hand
calculation would be tedious, two computer programs were written to calculate the
adjacency matrix A, the SVD of A, and the resulting partitions. The code can be
found in Chapter 4. The text from the two examples can be found in the Appendix.
11
CHAPTER 3
EXAMPLES
Rather than encrypt our first example, we will do the analysis on the verbatim
text.
Example 3.0.1. For our first example, we will use George W. Bushs 9/11 Address
after the September 11, 2001 attacks, a 2765-character piece of text taken from [5].
Using the Java program written for this purpose, we see that the adjacency matrix
A has the form:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
1
0
20
21
33
5
4
22
6
0
0
9
7
11
1
1
0
12
18
17
2
2
11
0
5
0
B
1
0
0
2
6
0
0
2
3
0
1
4
1
2
3
0
0
4
7
3
0
0
0
0
0
0
C
16
0
0
1
13
1
0
0
16
0
1
0
1
9
4
0
0
6
4
2
3
0
1
0
4
0
D
7
0
0
4
27
2
0
1
0
0
0
13
0
52
10
0
0
2
1
1
1
0
0
0
0
0
E
0
18
10
19
15
10
13
47
12
0
7
13
27
17
1
8
0
45
24
29
3
23
15
0
4
2
F
1
0
0
5
14
3
2
0
3
0
1
2
2
5
27
0
0
7
5
1
0
0
0
0
3
0
G
5
0
0
0
1
0
1
0
9
0
0
0
0
23
4
0
0
7
1
0
4
0
0
0
0
0
H
1
0
6
1
3
1
12
1
0
0
0
0
0
0
5
0
0
0
8
72
0
0
13
0
2
0
I
5
1
6
10
9
7
3
12
1
0
3
11
5
12
2
3
0
30
10
25
3
5
17
0
7
0
J
0
0
0
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
1
0
0
0
0
0
0
0
K
3
0
6
0
0
0
0
0
0
0
0
3
0
1
1
0
0
4
1
0
0
0
0
0
0
0
L
17
4
0
3
13
4
1
1
18
0
0
22
0
1
5
6
0
6
0
1
3
0
0
0
0
0
M
12
0
0
1
12
1
0
1
4
0
0
2
3
4
14
0
0
1
4
0
1
0
0
0
1
0
N
56
0
0
4
42
0
0
0
50
0
0
0
1
5
30
0
0
6
0
1
11
0
1
0
0
0
O
1
3
12
13
8
27
6
21
11
2
1
5
3
11
6
7
0
17
19
31
0
0
13
0
8
0
P
3
0
0
1
4
0
0
0
1
0
0
4
1
2
7
2
0
3
7
3
1
0
0
0
1
0
12
Q
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
R
17
2
1
2
56
9
5
3
8
0
0
2
0
1
39
7
0
10
1
7
33
0
0
0
1
0
S
11
0
0
8
48
1
2
0
16
0
3
0
4
17
10
2
0
13
13
10
11
0
0
0
0
0
T
28
0
14
16
15
4
7
12
23
0
2
6
2
24
6
3
0
12
33
16
6
0
0
0
4
0
U
2
9
5
1
2
6
0
2
0
4
0
0
3
1
36
0
1
2
2
6
0
0
0
0
0
0
V
6
0
0
0
14
0
0
0
3
0
0
2
0
0
4
0
0
1
0
0
0
0
0
0
0
0
W
4
0
0
7
20
0
0
0
1
0
0
2
0
4
9
1
0
5
10
2
0
0
0
0
7
0
X
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Y
10
2
2
0
6
0
0
0
0
0
0
5
1
4
0
0
0
10
0
6
0
0
1
0
1
0
Z
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
By summing rows (or columns), we can see from the matrix that the letter X
does not occur, the letter Q occurs exactly once, and the letter Z occurs twice.
Also, the two-letter combination (or digraph) TH is the most common, occuring
72 times. Furthermore, since nearly half of the occurences of U in this document
exist in the OU digraph, there is a good chance that U will be seen as a neuter
element.
In order to determine the vowel/consonant partitions, we will take the SVD of
A and compare signs of the second singular vectors (second columns of U and W ).
This is consistent with Theorem 2.2.1, which assumes A is rank-two.
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
-0.36724192219341
0.07486813752176
0.13608384875342
0.12471268293278
-0.37151887148156
0.10065093619693
0.10415482681094
0.31538079432540
-0.22966398618755
0.00335511305787
0.03463788608883
0.06254095871470
0.13116502453518
0.02321115037834
-0.31529595108696
0.03145633741803
-0.00050067671627
0.22679560289022
0.19701568282605
0.47316940903535
-0.15515208162008
0.11554777987678
0.19052577389345
-0.00000000000000
0.05506079683650
0.00881517222704
0.15759583437214
0.00746555169787
-0.10964210237106
-0.10735461932021
0.48243204003143
-0.09033451147643
-0.03411358646954
0.34516586763380
0.24722916881021
-0.00105138892359
0.00652792414376
-0.11266008969954
-0.11083096452985
-0.51206052989804
0.29321990869506
-0.00941252098165
-0.00335518842500
-0.33980484123968
-0.16237591061664
0.02949728921350
-0.05480153612514
-0.08225315918080
-0.05854831435437
0.00000000000000
0.00374259054637
-0.00419650318511
13
The letter X is absent in the cryptogram, but due to roundoff, the values in
the X row are nonzero. This problem (which would cause us to accidently consider
X a vowel at first glance) can be avoided by using rounding. Five decimal places
is sufficient. Comparing signs, we see that the following partitions are created.
Vowels: A E I O
Consonants: C D F G J L M N P R S V W Z
Neuter Elements: B H K Q T U X Y
14
15
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
1
0
21
7
3
4
7
4
0
2
0
0
0
7
5
4
4
0
0
16
3
22
0
1
2
0
B
0
0
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
C
5
0
0
14
30
30
86
19
15
70
12
2
3
36
27
34
9
8
0
27
36
32
8
7
10
1
D
3
0
17
0
0
11
8
4
0
0
3
0
2
19
2
3
14
0
0
3
4
7
3
0
1
0
E
3
0
25
0
0
2
36
7
2
0
43
0
0
2
0
11
10
0
0
10
13
1
1
0
2
0
F
2
0
24
0
0
2
80
4
2
0
7
0
0
10
1
79
19
0
0
7
5
3
2
0
0
0
G
7
4
0
42
29
35
46
6
23
162
23
2
8
50
52
58
2
15
0
106
28
56
6
56
36
0
H
3
0
0
0
1
3
18
12
12
1
11
0
0
8
0
1
100
1
0
5
14
21
4
0
0
0
I
0
0
14
0
0
5
30
8
3
0
24
0
2
2
0
53
10
0
0
8
2
1
4
0
0
0
K
7
0
23
2
13
20
25
18
18
52
0
0
4
42
21
21
8
10
0
53
37
88
7
8
47
1
L
0
0
2
0
0
1
2
4
0
0
0
0
0
2
0
4
3
0
0
0
0
0
0
0
0
0
M
0
0
6
0
17
0
1
0
0
0
2
0
0
3
0
4
3
0
0
7
3
0
0
0
0
0
N
2
0
54
17
3
4
26
4
5
2
55
0
1
66
3
6
21
12
0
4
16
9
13
0
0
0
O
8
0
33
0
1
1
28
4
1
0
10
0
2
4
2
2
62
0
0
9
4
3
3
0
2
0
P
3
0
102
0
0
2
71
4
5
0
111
0
2
5
4
12
74
0
0
15
11
6
27
0
4
0
Q
27
0
1
5
29
32
27
25
17
24
33
3
3
26
13
46
13
8
0
59
62
102
0
4
10
0
J
4
0
3
0
21
3
20
4
20
2
8
0
0
3
0
3
3
3
0
4
21
202
4
0
29
0
R
1
0
7
0
0
1
13
4
1
2
10
0
0
2
3
1
15
12
0
2
11
2
7
0
0
0
S
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
2
0
0
0
1
0
0
0
0
0
0
T
1
0
29
8
9
26
100
48
25
2
15
0
1
2
11
1
45
15
0
4
1
23
29
0
2
0
U
8
0
35
0
2
26
70
3
1
3
78
0
2
12
5
31
19
3
0
21
28
14
36
0
1
0
V
18
0
93
0
4
19
89
24
6
24
64
0
12
16
19
63
50
4
0
20
73
21
18
0
3
2
W
0
0
5
8
5
7
4
8
5
4
0
11
0
2
10
4
55
2
6
11
11
14
0
0
0
1
X
2
0
25
1
0
0
26
0
0
0
11
0
0
2
0
1
4
0
0
2
0
2
0
0
0
0
Y
8
0
2
0
1
13
33
2
5
7
0
0
4
2
1
14
26
1
0
3
15
12
0
0
1
0
Z
0
0
0
0
0
0
3
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
If we find the SVD of this matrix, we will get the following second singular
vectors (second columns of U and W ).
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
Y
U
V
W
X
Y
Z
0.00630771169603
0.00668519833513
-0.40400561554923
0.06541054530923
0.11678821960198
0.04843764908191
-0.29588468069332
-0.02559213553157
0.06227384136410
0.34438456003104
-0.34789041641652
0.00559967974476
-0.00129449686530
0.07284166722039
0.08602639860957
-0.02057750604381
-0.33313521273343
0.02266626545267
-0.00068397986930
0.20964621203852
0.02801489859255
0.51821656473647
-0.10836633438194
0.10856300934520
0.15248129307646
-0.00090887719170
0.02238194455629
-0.00535406661745
0.10366270317444
-0.03388032866720
-0.13807465649987
-0.15338425321626
0.43438317055276
-0.11129465254638
-0.09664453130702
0.39961406173167
0.27531989983701
-0.00919459618040
-0.00285456237121
-0.16666612273773
-0.16014004482120
-0.46345133351373
0.23507363726993
-0.04919654544566
-0.00276699614581
-0.17813573010846
-0.21673111412097
-0.29278897939887
-0.02962857438459
-0.08192771022439
-0.03225975525502
-0.00517072875066
16
17
18
CHAPTER 4
JAVA AND MATLAB CODE USED FOR COMPUTATION
This chapter includes all of the code used to create the adjacency matrix,
compute the SVD, and compare signs of the second left and right singular vectors
to give the resulting partitions. This Java program creates the adjacency matrix A.
package readmatrix;
import java.io.*;
//******************************************************************************
// ReadMatrix.java
// Author: Josh Boone
// Department of Mathematics
// Southern Illinois University Carbondale
//******************************************************************************
// This program creates a 26x26 adjacency matrix for a given input file. The
// matrix is printed in an easy-to read format, as well as Matlab/Maple form, to
// .txt files that are saved in the same location as the input file. The
// formatted matrix can then be directly pasted into Matlab/Maple for SVD
// analysis. This program works for raw data (plaintext files) as well as
// formatted cryptograms, due to the robustness of the removeSpace method.
//******************************************************************************
public class readMatrix {
public static void main(String[] args) {
BufferedReader input = null;
BufferedReader input2 = null;
PrintWriter output = null;
PrintWriter output_matlab = null;
PrintWriter output_maple = null;
PrintWriter fixed = null;
String s = null;
String s2 = null;
boolean spacer = false;
int[][] matrix = new int[27][27];
try {
input = new BufferedReader(new FileReader("in.txt"));
fixed = new PrintWriter(new FileWriter("fixed.txt"));
output_maple = new PrintWriter(new FileWriter("out_maple.txt"));
output_matlab = new PrintWriter(new FileWriter("out_matlab.txt"));
output = new PrintWriter(new FileWriter("out.txt"));
}
catch (IOException e) {
e.printStackTrace();
}
// This block of code removes the non-letter characters from the input
// file and saves the resulting string as "fixed.txt" in the same
// directory as the input file.
try{
String str = null;
while((str = input.readLine()) != null){
s = removeSpace(str); // see method at bottom of file.
s2 = encrypt(s, 0); // to encrypt a plaintext with a shift
19
r1 = 15;
} else if (s.charAt(i) == P) {
r1 = 16;
} else if (s.charAt(i) == Q) {
r1 = 17;
} else if (s.charAt(i) == R) {
r1 = 18;
} else if (s.charAt(i) == S) {
r1 = 19;
} else if (s.charAt(i) == T) {
r1 = 20;
} else if (s.charAt(i) == U) {
r1 = 21;
} else if (s.charAt(i) == V) {
r1 = 22;
} else if (s.charAt(i) == W) {
r1 = 23;
} else if (s.charAt(i) == X) {
r1 = 24;
} else if (s.charAt(i) == Y) {
r1 = 25;
} else if (s.charAt(i) == Z) {
r1 = 26;
}
if (s.charAt(i + 1) == A) {
r2 = 1;
} else if (s.charAt(i + 1) == B)
r2 = 2;
} else if (s.charAt(i + 1) == C)
r2 = 3;
} else if (s.charAt(i + 1) == D)
r2 = 4;
} else if (s.charAt(i + 1) == E)
r2 = 5;
} else if (s.charAt(i + 1) == F)
r2 = 6;
} else if (s.charAt(i + 1) == G)
r2 = 7;
} else if (s.charAt(i + 1) == H)
r2 = 8;
} else if (s.charAt(i + 1) == I)
r2 = 9;
} else if (s.charAt(i + 1) == J)
r2 = 10;
} else if (s.charAt(i + 1) == K)
r2 = 11;
} else if (s.charAt(i + 1) == L)
r2 = 12;
} else if (s.charAt(i + 1) == M)
r2 = 13;
} else if (s.charAt(i + 1) == N)
r2 = 14;
} else if (s.charAt(i + 1) == O)
r2 = 15;
} else if (s.charAt(i + 1) == P)
r2 = 16;
} else if (s.charAt(i + 1) == Q)
r2 = 17;
} else if (s.charAt(i + 1) == R)
r2 = 18;
} else if (s.charAt(i + 1) == S)
r2 = 19;
21
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
} else if (s.charAt(i + 1) == T) {
r2 = 20;
} else if (s.charAt(i + 1) == U) {
r2 = 21;
} else if (s.charAt(i + 1) == V) {
r2 = 22;
} else if (s.charAt(i + 1) == W) {
r2 = 23;
} else if (s.charAt(i + 1) == X) {
r2 = 24;
} else if (s.charAt(i + 1) == Y) {
r2 = 25;
} else if (s.charAt(i + 1) == Z) {
r2 = 26;
}
matrix[r1][r2] = matrix[r1][r2] + 1; // increment matrix
}
}
// This prints to the out_matlab.txt file in Matlab matrix form.
output_matlab.print([);
for (int j = 1; j <= 26; j++) {
for (int k = 1; k <= 26; k++) {
output_matlab.print(matrix[j][k]);
if (k != 26) {
output_matlab.print( );
}
}
if (j != 26) {
output_matlab.print(;);
}
}
output_matlab.print(]);
// This prints to the out_maple.txt file in Maple matrix form.
output_maple.print([);
for (int j = 1; j <= 26; j++) {
for (int k = 1; k <= 26; k++) {
if (k == 1) {
output_maple.print([);
}
output_maple.print(matrix[j][k]);
if (k != 26) {
output_maple.print(,);
} else {
output_maple.print(]);
if (j != 26)
output_maple.print(,);
}
}
}
output_maple.print(]);
// This prints to the out.txt file, putting in "easy-to-read" form.
// First, we will determine how we need to format the matrix (with
// either two or three spaces between single-digit values).
for (int j = 1; j <= 26; j++) {
for (int k = 1; k <= 26; k++) {
if (matrix[j][k] > 99)
22
spacer = true;
}
}
// If any value of the matrix is greater than 99, we use the
// following block of code.
if (spacer == true) {
// First, we print the labels for the columns:
output.println(" A
B
C
D
E
F
G
H
I
J
K
"
+ "L
M
N
O
P
Q
R
S
T
U
V
"
+ "W
X
Y
Z");
for (int j = 1; j <= 26; j++) {
output.print((char) (j + 64)); // print labels for rows,
output.print(" ");
// using ASCII codes
for (int k = 1; k <= 26; k++) {
output.print(matrix[j][k]);
if (matrix[j][k] <= 9) {
output.print("
");
} else if (matrix[j][k] <= 99){
output.print(" ");
} else{
output.print( );
}
}
output.println();
output.println();
}
}
// Otherwise, we use the following piece of code.
if (spacer == false) {
// First, we print the labels for the columns:
output.println(" A B C D E F G H I J K L M N O "
+ "P Q R S T U V W X Y Z");
for (int j = 1; j <= 26; j++) {
output.print((char) (j + 64)); // print labels for rows,
output.print(" "); // using ASCII codes for the letters
for (int k = 1; k <= 26; k++) {
output.print(matrix[j][k]);
if (matrix[j][k] <= 9) {
output.print(" ");
} else
output.print( );
}
output.println();
}
}
output_matlab.close(); // close matlab output stream
output_maple.close(); // close maple output stream
output.close(); // close regular output stream
input2.close(); // close input stream (from fixed text)
}
catch (IOException e) {
e.printStackTrace();
}
23
}
// This method removes all non-letter characters from a raw text file and
// returns a new string containing only capital letters. For a cryptogram,
// it simply removes the spaces.
public static String removeSpace(String s) {
String str = "";
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if ((ch >= A && ch <= Z) || (ch >= a && ch <= z))
str = str + Character.toUpperCase(ch);
}
return str;
}
// This method is only used as an accessory method to provide shift-cipher
// encryption for examples.
public static String encrypt(String s, int i) {
String str = "";
if (i < 0)
System.err.print("Please input a value between 0 and 25.");
for (int j = 0; j < s.length(); j++) {
if ( (int)s.charAt(j) + i <= Z ){
int char_int = (int) s.charAt(j) + i;
char c = (char) char_int;
str = str + c;
}
else{
int char_int = (int) s.charAt(j) + i - 26;
char c = (char) char_int;
str = str + c;
}
}
return str;
}
}
24
This MATLAB program returns the singular values, second left and right
singular vectors, the frequency vector, and the partitions of the letters into vowels,
consonants, and neuter elements.
%thesis.m
%Josh Boone, Department of Mathematics
%Southern Illinois University Carbondale
%Coded for use in MATLAB, Mathworks Inc.
%
%Returns the singular values, the second right singular vector, the
%second left singular vector, the vowel, consonant, and neuter
%elements of the cryptogram, and the letter frequency vector
function thesis(A);
[U, S, W] = svd(A);
singular_values = diag(S)
second_left_singular_vector = U(:,2)
second_right_singular_vector = W(:,2)
letter_frequency_vector = sum(A)
l = roundn(second_left_singular_vector, -5);
r = roundn(second_right_singular_vector, -5);
k = max(size(A));
alpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ;
disp(Vowels:);
for i=1:k
if sign(r(i)) ~= sign(l(i))
if r(i) > 0
disp(alpha(i));
end;
end;
end;
disp(Consonants:);
for i=1:k
if sign(r(i)) ~= sign(l(i))
if r(i) < 0
disp(alpha(i));
end;
end;
end;
disp(Neuter Elements:);
for i=1:k
if sign(r(i)) == sign(l(i))
disp(alpha(i));
end;
end;
Java is a trademark of Sun Microsystems, Inc.
MATLAB is a trademark of The MathWorks, Inc.
Maple is a trademark of Maplesoft, Inc.
25
REFERENCES
[1] Bapat, R.B. and Raghavan, T.E.S., Nonnegative Matrices and Applications,
Cambridge University Press, 1997.
[2] Bau, D. and Trefethen, L., Numerical Linear Algebra, Society for Industrial and
Applied Mathematics, Philadelphia, PA, 1997.
[3] Gaines, H.F., Cryptanalysis, Dover, New York, 1956.
[4] Moler, C. and Morrison, D., Singular Value Analysis of Cryptograms, The
American Mathematical Monthly, Vol. 90, No. 2, (Feb., 1983), pp. 78-87.
[5] Famous
Martin
Speeches
Luther
by
King.
Presidents,
Famous
Prime
Quotes.
Ministers
May-June
and
2008
<http://www.famousquotes.me.uk/speeches/index.htm>.
[6] Sinkov, A., Elementary Cryptanalysis, A Mathematical Approach, New Mathematical Library, vol 22, Mathematical Association of America, Washington,
D.C., 1968.
[7] Frequency
Analysis.
Wikipedia.
29
Apr.
2008.
May-June
26
2008
APPENDIX
27
motels of the highways and the hotels of the cities. We cannot be satisfied as long
as the Negros basic mobility is from a smaller ghetto to a larger one. We can
never be satisfied as long as a Negro in Mississippi cannot vote and a Negro in New
York believes he has nothing for which to vote. No, no, we are not satisfied, and
we will not be satisfied until justice rolls down like waters and righteousness like a
mighty stream. I am not unmindful that some of you have come here out of great
trials and tribulations. Some of you have come fresh from narrow cells. Some of
you have come from areas where your quest for freedom left you battered by the
storms of persecution and staggered by the winds of police brutality. You have been
the veterans of creative suffering. Continue to work with the faith that unearned
suffering is redemptive. Go back to Mississippi, go back to Alabama, go back to
Georgia, go back to Louisiana, go back to the slums and ghettos of our northern
cities, knowing that somehow this situation can and will be changed. Let us not
wallow in the valley of despair. I say to you today, my friends, that in spite of
the difficulties and frustrations of the moment, I still have a dream. It is a dream
deeply rooted in the American dream. I have a dream that one day this nation
will rise up and live out the true meaning of its creed: We hold these truths to be
self-evident: that all men are created equal. I have a dream that one day on the
red hills of Georgia the sons of former slaves and the sons of former slave-owners
will be able to sit down together at a table of brotherhood. I have a dream that one
day even the state of Mississippi, a desert state, sweltering with the heat of injustice
and oppression, will be transformed into an oasis of freedom and justice. I have a
dream that my four children will one day live in a nation where they will not be
judged by the colour of their skin but by the content of their character. I have a
dream today. I have a dream that one day the state of Alabama, whose governors
lips are presently dripping with the words of interposition and nullification, will be
transformed into a situation where little black boys and black girls will be able to
join hands with little white boys and white girls and walk together as sisters and
brothers. I have a dream today. I have a dream that one day every valley shall be
exalted, every hill and mountain shall be made low, the rough places will be made
plain, and the crooked places will be made straight, and the glory of the Lord shall
be revealed, and all flesh shall see it together. This is our hope. This is the faith
with which I return to the South. With this faith we will be able to hew out of the
mountain of despair a stone of hope. With this faith we will be able to transform the
jangling discords of our nation into a beautiful symphony of brotherhood. With this
faith we will be able to work together, to pray together, to struggle together, to go
to jail together, to stand up for freedom together, knowing that we will be free one
day. This will be the day when all of Gods children will be able to sing with a new
meaning, My country, tis of thee, sweet land of liberty, of thee I sing. Land where
my fathers died, land of the pilgrims pride, from every mountainside, let freedom
ring. And if America is to be a great nation this must become true. So let freedom
ring from the prodigious hilltops of New Hampshire. Let freedom ring from the
mighty mountains of New York. Let freedom ring from the heightening Alleghenies
of Pennsylvania! Let freedom ring from the snow-capped Rockies of Colorado! Let
freedom ring from the curvaceous peaks of California! But not only that; let freedom
ring from Stone Mountain of Georgia! Let freedom ring from Lookout Mountain of
Tennessee! Let freedom ring from every hill and every molehill of Mississippi. From
every mountainside, let freedom ring. When we let freedom ring, when we let it ring
from every village and every hamlet, from every state and every city, we will be able
to speed up that day when all of Gods children, black men and white men, Jews
and Gentiles, Protestants and Catholics, will be able to join hands and sing in the
words of the old Negro spiritual,Free at last! free at last! thank God Almighty, we
are free at last!
29
VITA
Graduate School
Southern Illinois University
JOSHUA BOONE
30