Early Computers

 The definition of a Ones and Zeros computer is “a device that computes, …”  The abacus could be considered the first Chapter 12 computer.  Its effectiveness has withstood the test of time and it is still used in some parts of the world.

Lewinter & Widulski The Saga of Mathematics 1 Lewinter & Widulski The Saga of Mathematics 2

John Napier (1550 - 1617) Napier’s Bones

 In 1617, Scottish  Napier's Bones were mathematician John multiplication tables Napier invented a inscribed on strips of technique of using wood or bone. numbering rods for  Napier’s idea led to the multiplication. invention of the slide rule  The rods became known in the mid 1600s by as "Napier's Bones." William Oughtred.

Lewinter & Widulski The Saga of Mathematics 3 Lewinter & Widulski The Saga of Mathematics 4

The Pascaline The Pascaline

In 1642, Blaise Pascal As they agonized over the columns of figures, Pascal invented his "Pascaline" decided to build a machine that would do the job much faster and more accurately. calculator. His machine could add and subtract. Pascal, a mathematician The machine used a series of toothed wheels, which and philosopher, and his were turned by hand and which could handle numbers father, a tax official, were up to 999,999.999. compiling tax reports for Pascal’s device was also called the “numerical the French government in calculator” and was one of the world’s first mechanical adding machines. Paris.

Lewinter & Widulski The Saga of Mathematics 5 Lewinter & Widulski The Saga of Mathematics 6

1 Gottfried Wilhelm von Leibniz The Step Reckoner

In 1671, Gottfried von  This machine could add, subtract, multiply, divide and figure Leibniz invented the square roots through a series of stepped additions. "Stepped Reckoner"  Although the machine did not become widely used, almost every which used a special type mechanical calculator build during the next 150 years was based of gear named the on it. stepped drum, also known as, the Leibniz Wheel. His device was not built until about 1694.

Lewinter & Widulski The Saga of Mathematics 7 Lewinter & Widulski The Saga of Mathematics 8

Jacquard’s Loom Jacquard’s Loom

In 1805, Joseph-Marie Jacquard built a loom controlled Jacquard’s loom emphasized three concepts by punched cards. important in computer theory. Heavy paper cards linked in a series passed over a set of rods on a loom. First, the information could be coded on punched The pattern of holes in the cards determined which rods cards. were engaged, thereby adjusting the color and pattern of the product. Second, the cards could be linked in a series of instructions – essentially a program – allowing a Prior to Jacquard’s invention, a loom operator adjusted the loom settings by hand before each glide of the machine to do work without human intervention. shuttle, a tedious and time-consuming job. Third, the programs could automate jobs.

Lewinter & Widulski The Saga of Mathematics 9 Lewinter & Widulski The Saga of Mathematics 10

The Stored Program Charles Babbage (1791 - 1871)

 A program is a sequence of instructions for the Charles Babbage was computer to follow born in London, England.  Also called “software” He entered Trinity College, Cambridge in  Hardware: the chips, wires, switches, etc. on which the October 1810, and was software instructions are executed. recognized for his  Primitive example: the Jacquard Loom exceptional mathematical  The loom was the hardware abilities.  The weaving pattern cards was the software Babbage is considered to  The “program” was “stored” on punched cards be the “Father of Computing”

Lewinter & Widulski The Saga of Mathematics 11 Lewinter & Widulski The Saga of Mathematics 12

2 Charles Babbage (1791 - 1871) Charles Babbage (1791 - 1871)

In 1827 Babbage became Lucasian Professor of On 13 July 1823 Babbage received a gold medal from Mathematics at Cambridge, a position he held for 12 the Astronomical Society for his development of the years, although he never taught. difference engine. He had become engrossed in the main passion of his life – the development of a mechanical computer. By 1834 Babbage had completed the first drawings of Babbage began to construct a small difference engine in the analytical engine, the forerunner of the modern 1819 and had completed it by 1822. electronic computer. Babbage illustrated what his small engine was capable Babbage discussed the concept of using punched cards of doing by calculating successive terms of the sequence n2 + n + 41. to control the operation of his calculating machine, but he was never able to build a full working model.

Lewinter & Widulski The Saga of Mathematics 13 Lewinter & Widulski The Saga of Mathematics 14

Charles Babbage (1791 - 1871) Charles Babbage (1791 - 1871)

 Babbage’s ideas embodied five key concepts of Although Babbage died before he could construct modern computers: his machine, such a computer has been built 1. Input device following Babbage's own design criteria. 2. Processor or number calculator In 1834 Babbage published his most influential 3. Control unit to direct the task to be performed and the sequence of calculations. work On the Economy of Machinery and 4. Storage place to hold number waiting to be Manufactures, in which he proposed an early processed form of what today we call operations research. 5. Output device

Lewinter & Widulski The Saga of Mathematics 15 Lewinter & Widulski The Saga of Mathematics 16

Lady Augusta Ada (1815 - 1852) Lady Augusta Ada (1815 - 1852)

Augusta Ada was the Ada Byron was fascinated by a demonstration of daughter of the poet, Lord Babbage's Difference Engine. Byron. Babbage found that Ada understood and could explain Her mother encouraged the workings of his machine better than anyone else. her to study mathematics Babbage later toured Europe giving lectures on his more and music. advanced concept, the Analytical Engine, a machine She was a bright which he never fully constructed. mathematician who was Extensive notes were taken of some of these lectures in introduced to Charles French. Babbage in 1833.

Lewinter & Widulski The Saga of Mathematics 17 Lewinter & Widulski The Saga of Mathematics 18

3 Lady Augusta Ada (1815 - 1852) Lady Augusta Ada (1815 - 1852)

Ada translated the French notes into English and When Augusta was 19, she married the wealthy Lord added a lengthy addendum. King, Baron of Lovelace. At Babbage's request, she published her notes. Her husband had some knowledge of mathematics, but it She had a unique grasp of the concepts of was Ada who urged him to provide funding to Babbage programming subroutines, loops and jumps. when his government funding ceased. Ada also had an interest in gambling, and attempted to She is often referred to as the first programmer. apply some of Babbage's technology to that end, but She was instrumental in clarifying and preserving without great success. information on Charles Babbage and his work.

Lewinter & Widulski The Saga of Mathematics 19 Lewinter & Widulski The Saga of Mathematics 20

Lady Augusta Ada (1815 - 1852) Mechanical Computers

In recognition of her contributions to the field of  Mechanical calculators built from cogs and gears programming theory, the U.S. Department of Defense named their programming language for reducing  Difference Engine software development and maintenance costs, known  Analytical Engine (General Purpose) only as DoD-1 up to that point, "Ada" in her honor in May of 1979.  The "Difference Engine" was massive steam powered Ada is one of the main characters in the “alternate mechanical calculator designed to print astronomical history” novel The Difference Engine by Bruce Sterling tables. and William Gibson, which imagines a world in which Babbage's machines were mass produced and the  The Analytical Engine was a mechanical computer computer age started a century early. designed to run using punch cards.

Lewinter & Widulski The Saga of Mathematics 21 Lewinter & Widulski The Saga of Mathematics 22

The Difference Engine The Analytical Engine

 Designed to solve accuracy problem  First true ancestor of the modern computer  would have computed tables and output results directly onto printing plates  key idea: automatically feed results back into the difference engine  store numbers and intermediate results for any kind of function at all  1822: partial working model  Gear-based  2 orders of difference   6-figure numbers Basic components  store (memory)  only computing machine Babbage ever completed  mill (arithmetic unit)  Government research grant (1823)  control barrel (primitive program control unit)  abandoned support in 1842  cycle time: around 3 seconds per operation  The Scheutz difference engine (Sweden, 1854)  program stored on punched cards  idea came from Jacquard loom  irony: British government bought one  planned: steam power

Lewinter & Widulski The Saga of Mathematics 23 Lewinter & Widulski The Saga of Mathematics 24

4 Electromechanical Computers Electromechanical Computers

Herman Hollerith Alan Turing Developed a punched card tabulating machine Computer theorist Used for the 1890 census Worked on the Colossus, used to decrypt German military messages, WW2 His company was one of several which began IBM Grace Hopper – worked as a coder on the Konrad Zuse Harvard Mark I Proposed use of vacuum tubes for switching of binary It used electrical relays circuits Sponsored by US Navy to compute navigational Hitler refused to fund his design tables

Lewinter & Widulski The Saga of Mathematics 25 Lewinter & Widulski The Saga of Mathematics 26

Early Electronic Computers Early Electronic Computers

The ABC computer  The ENIAC The Atanasoff-Berry Computer was the world's first electronic  In 1946, John Mauchly and J Presper Eckert developed the digital computer. ENIAC I (Electrical Numerical Integrator And Calculator). It was built by John Vincent Atanasoff and Clifford Berry at  The ENIAC computer was intended to be a general purpose Iowa State University to do math & physics calculations. one, but it was also designed for a very specific task, namely It incorporated several major innovations in computing compiling tables for the trajectories of bombs and shells. including the use of binary arithmetic, regenerative memory,  Used 18,000 vacuum tubes, caused lights to dim in parallel processing, and separation of memory and computing Philadelphia neighborhoods when turned on. functions.  Programmed by rewiring panels.

Lewinter & Widulski The Saga of Mathematics 27 Lewinter & Widulski The Saga of Mathematics 28

Early Electronic Computers The von Neumann Architecture

 The UNIVAC (UNIversal Automatic Computer) John von Neumann  Built by John Mauchly and J Presper Eckert Inventor the concept of a stored-program computer (a computer whose program was stored in computer memory).  Used by the Census Bureau in 1950s The von Neumann architecture is the basis of the digital  This was the first computer to be produced commercially in computer as we know it today. the United States with 46 UNIVACs being built. A von Neumann Architecture computer has five parts:  The UNIVAC computer was used to predict the results of the  an arithmetic-logic unit (ALU) Eisenhower-Stevenson presidential race. The computer had correctly  a control unit (CU) predicted that Eisenhower would win, and it was considered amazing  memory that a computer could do what political forecasters could not. The UNIVAC quickly became a household name.  some form of input/output (I/O) and  a bus that provides a data path between these parts.

Lewinter & Widulski The Saga of Mathematics 29 Lewinter & Widulski The Saga of Mathematics 30

5 The von Neumann Architecture Computers

 A von Neumann Architecture computer performs the following Computers are built on two key principles steps: 1. Fetch the next instruction from memory at the address in the program Both instructions and data are represented by counter. numbers 2. Add the length of the instruction to the program counter. Instructions and data are stored in memory and are 3. Decode the instruction using the control unit. The control unit commands the rest of the computer to perform some operation. The instruction may read and written as numbers change the address in the program counter, permitting repetitive operations. The instruction may also change the program counter only if All computers use the binary number system some arithmetic condition is true, giving the effect of a decision, which (base-2) can be calculated to any degree of complexity by the preceding arithmetic and logic. basic nature of electronic circuits ON/OFF, current 4. Go back to step 1. flow/does not flow, 1 is +5V and 0 is 0V.

Lewinter & Widulski The Saga of Mathematics 31 Lewinter & Widulski The Saga of Mathematics 32

Number Systems Number Systems

Let’s review our decimal system (or base 10). Numbers can be represented in any base B (not We use 10 symbols (the digits), 0, 1, 2, 3, 4, 5, 6, just base 10). 7, 8, and 9, to represent all numbers. Using B symbols, 0, 1, 2, 3, 4, …, B – 1, to Each digit in a number has a precise place value represent all numbers. which is a power of 10. Each digit in a number has a precise place value Place values are powers of 10 starting on the which is a power of B. right with 100 and increasing toward the left, 101, Place values are powers of B starting on the right 102, 103, etc. with B0 and increasing toward the left, B1, B2, etc.

Lewinter & Widulski The Saga of Mathematics 33 Lewinter & Widulski The Saga of Mathematics 34

Number Systems The Decimal Number System

The most common number systems associated Base 10 with computers are: Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 747510 3 2 1 0 Decimal Base = 10 10 10 10 10 Binary Base = 2 7 4 7 5 Octal Base = 8 The place value of each digit is determine by its position within the number. Hexadecimal (Hex) Base = 16 The digit 7 in the left-most position of 7475 counts for Let’s look at each one in more detail. 7000 and the digit 7 in the second position from the right counts for 70.

Lewinter & Widulski The Saga of Mathematics 35 Lewinter & Widulski The Saga of Mathematics 36

6 The Binary Number System The Octal Number System

Base 2 Base 8 Digits: 0, 1 Place Values Digits: 0, 1, 2, 3, 4, 5, 6, 7 Place Values Example: 1574 Example: 10112 8 4 2 1 8 512 64 8 1 23 22 21 20 83 82 81 80 1 0 1 1 1 5 7 4

The digit 1 in the second position from the right The digit 7 in the second position from the right represents the value 2 and the digit 1 in the fourth represents the value 7×8 = 56 and the digit 1 in the position from the right represents the value 8. fourth position from the right represents the value 512.

Lewinter & Widulski The Saga of Mathematics 37 Lewinter & Widulski The Saga of Mathematics 38

The Hexadecimal Number System The Binary Number System

Place Values Base 16 Computers use the binary number system or Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F base-2 to represent everything (numbers, letters, and instructions). Example: 1BAD16 4096 256 16 1 163 162 161 160 Although, Atanasoff was the first to build a 1 B A D modern computer that used this idea, he was not the first to think of it. The digit B in the third position from the right represents the value 11×256 = 2816 and the digit D in the first In fact the Egyptians used the powers of 2 in their position from the right represents the value 13. multiplication and division.

Lewinter & Widulski The Saga of Mathematics 39 Lewinter & Widulski The Saga of Mathematics 40

Leibniz and Leibniz and The Binary Number System The Binary Number System Gottfried Wilhelm von Leibniz (co-father of Calculus) first Binary numbers had been known in India and in formally described the binary number system and its China 1500 years earlier. operations in writing in 1679. In India they were used in music to classify meter. Leibniz also philosophized about a computer based on a Leibniz believed that binary numbers represented binary numerical system. Creation In 1679 he wrote, "Despite its length, the binary system, The number 1 portraying God and 0 depicting in other words counting with 0 and 1, is scientifically the voidness. most fundamental system, and leads to new discoveries. He considered the binary 111 as an symbol of When numbers are reduced to 0 and 1, a beautiful order prevails everywhere." trinity.

Lewinter & Widulski The Saga of Mathematics 41 Lewinter & Widulski The Saga of Mathematics 42

7 Bits and Bytes Bits and Bytes

What is a bit? What is a byte?  A bit is a number (a place) in a set of binary numbers.  A byte is 8 bits or 2 nibbles (4 bits).  The bigger the number, the more bits there will be  A byte is the amount of storage required to store a single A bit or binary digit is the smallest element a computer character, such as Q. can deal with and is either 1 or 0.  It is the smallest data item in the microprocessor. A binary number consists of several bits.  Written using variables, we have The right-most bit is called the LSB (least significant bit). b7 b6 b5 b4 b3 b2 b1 b0 The left-most bit is called the MSB (most significant bit)  b7 is the MSB and also called the high order bit. or the HOB (high order bit).  b0 is the LSB and also called the low order bit.

Lewinter & Widulski The Saga of Mathematics 43 Lewinter & Widulski The Saga of Mathematics 44

The Binary Number System Converting Binary to Decimal

Simplest number system is base 2, or binary Example: Convert 1011.1012 to decimal Uses the 2 digits (“bits”) 0 and 1 Solution: 1011.1012 Used exclusively in computers (ON/OFF switches, = (1×23) + (0×22) + (1×21) + (1×20) magnetized/demagnetized memory elements) + (1×2–1) + (0×2–2) + (1×2–3) A typical binary number is 1011.101 2 = 8 + 2 + 1 + 0.5 + 0.125 The subscript 2 denotes the base – the base should be included if it is not 10 = 11.625 Exercise: Convert 110001.0112 to decimal

Lewinter & Widulski The Saga of Mathematics 45 Lewinter & Widulski The Saga of Mathematics 46

Converting Decimal to Binary Decimal to Binary - A Better Way

We’ll begin by converting integers Previous method is awkward for large numbers. Example: Convert 183 to binary A better method is to repeatedly divide by 2, writing down the quotient and remainder at each step, until the Solution: Note that the powers of 2 are 1, 2, 4, 8, 16, 32, quotient is zero. 64, 128, 256, 512, …. Now write down the remainders in reverse order – this is Now write 183 using just these powers. the binary form of the integer Thus 183 = 128 + 55 Example: Convert 91 to binary = 128 + 32 + 23 = 128 + 32 + 16 + 7 Exercise: Convert 212 to binary

= 128 + 32 + 16 + 4 + 2 + 1 = 101101112 Answer: 212 = 110101002

Lewinter & Widulski The Saga of Mathematics 47 Lewinter & Widulski The Saga of Mathematics 48

8 Decimal to Binary - A Better Way Addition in Base 2

Operation Quotient Remainder The addition table 91 ÷ 2 = 45 1 appears at the right. + 0 1 45 ÷ 2 = 22 1 Basically, it is pretty 22 ÷ 2 = 11 0 simple: 11 ÷ 2 = 5 1 0 + 0 = 0 and 0 0 1 5 ÷ 2 = 2 1 1 + 0 = 0 + 1 = 1 2 ÷ 2 = 1 0 It is important to remember that 1 + 1 = 0 1 ÷ 2 = 0 1 1 1 10 with a 1 carry. 91 = 10110112

Lewinter & Widulski The Saga of Mathematics 49 Lewinter & Widulski The Saga of Mathematics 50

Binary Addition Addition of Binary Numbers

(a)0 (b) 0 Start at the least significant digit and add digits + 0 + 1 (bits) in the same column and carry anything over 0 1 1 (the largest binary digit) to be added to the column of the next most significant bits. (c)1 (d) 1 For example: 111 + 0 + 1 1011 1 1 0 + 1001 Carry Bit 10100

Lewinter & Widulski The Saga of Mathematics 51 Lewinter & Widulski The Saga of Mathematics 52

Binary Addition Examples Binary Complements (a)1011 (b)1010 (c) 1011 There are two kinds of complements one’s + 1100 + 100 + 101 complement and two’s complement. 10111 1110 10000 One’s complement is simply done by changing the 1’s to 0’s and the 0’s to 1’s. (d)101 (e) 10011001 Examples: + 1001 + 101100  0 1 0 1 1 0 0 1 becomes 1 0 1 0 0 1 1 0 1110 11000101  1 1 1 0 0 1 0 1 becomes 0 0 0 1 1 0 1 0

Lewinter & Widulski The Saga of Mathematics 53 Lewinter & Widulski The Saga of Mathematics 54

9 Two’s Complement Binary Subtraction

The two’s complement of a binary number is Binary subtraction is implemented by adding the two’s obtained by first complementing the number and complement of the number to be subtracted. then adding 1 to the result. Example: 1001110 1101 two’s 1101 – 1001 complement + 0111 0110001 One’s Complement of 1001 10100 + 1 If there is a carry in the HOB then it is ignored. Thus, the 0110010 Two’s Complement answer is 0100.

Lewinter & Widulski The Saga of Mathematics 55 Lewinter & Widulski The Saga of Mathematics 56

Multiplication in Base 2 Binary Multiplication Examples (a) (c) The multiplication table 1011 1001 appears at the right. × 0 1 × 11 × 101 (b) 110 Basically, it is pretty 1011 1001 simple, 0 times anything × 101 10110 0 is 0 and 1 times anything 110 is the anything. 0 0 0 100001 100100 0 That is, 101101 1 × 1 = 1 and 11000 1 0 1 0 × 0 = 0 × 1 = 1 × 0 = 0 11110

Lewinter & Widulski The Saga of Mathematics 57 Lewinter & Widulski The Saga of Mathematics 58

Cryptology Cryptography Terminology

Cryptography : convert plaintext message into a that looks like gibberish The art of making codes. MEET ME AT THE LIBRARY becomes Using encryption to conceal text. iQA/AwUBO8RZysYL3oijlaCiEQI3OwCgm7Uzwx  UW26KR/emgIBs+FavKAdgAoN4F The art of breaking codes. Decryption: convert ciphertext back into the original The breaking of secret writing. plaintext iQA/AwUBO8RZysYL3oijlaCiEQI3OwCgm7Uzwx Cryptology UW26KR/emgIBs+FavKAdgAoN4F becomes The study of encryption and decryption. MEET ME AT THE LIBRARY

Lewinter & Widulski The Saga of Mathematics 59 Lewinter & Widulski The Saga of Mathematics 60

10 Cryptography Terminology Example

Encryption and decryption are based on an algorithm What’s the message? and a key I have been asked to speak to you today about sometimes two keys, one for encryption and one for cryptology. I will be brief because we do not have a decryption tremendous amount of time. You will be able to follow The algorithm is assumed to be public knowledge, but this lecture, I assure you. At the very least, you will the key is secret learn something about cryptology. From Caesar’s to Lewis Carrol’s Vigenère cipher, we will look Cryptanalysis is deciphering a text without knowing the at them all. key Specialty of GCHQ, NSA, etc

Lewinter & Widulski The Saga of Mathematics 61 Lewinter & Widulski The Saga of Mathematics 62

Null Cipher Types of

A null-cipher is a type of hidden message where the real Transposition Ciphers message is camouflaged in an innocent sounding message. The Rail Fence, The Twisted Path, and Scrambling with a Key Word. A famous example of a null cipher sent by a German spy in WWII: Monoalphabetic Substitution Ciphers Apparently neutral’s protest is Caesar, Key Word, The , Random thoroughly discounted and ignored. Isman hard hit. Blockade issue affects Polyalphabetic Substitution Ciphers pretext for embargo on by products, ejecting suets and vegetable oils. Date Shift, Porta’s Digraphic, Playfair, and Vigenère

Lewinter & Widulski The Saga of Mathematics 63 Lewinter & Widulski The Saga of Mathematics 64

Simple Machines Transposition Ciphers

Typewriter Codes A is one that does not A Telephone Dial Code change any letters of the original message (the “plaintext”). The It rearranges the letters according to a secret The Alberti Disk system. Thomas Jefferson’s Wheel Cipher The simplest transposition cipher is made by just Grilles writing the message backward. The Triangle Code

Lewinter & Widulski The Saga of Mathematics 65 Lewinter & Widulski The Saga of Mathematics 66

11 Transposition Ciphers The

Example: Count the number of letters. THE EAGLE HAS LANDED If the number is not a multiple of 4, add enough Encoded: dummy letters (nulls) at the end to make it a DEDNAL SAH ELGAE EHT multiple of 4. Easy to decode, harder if the original word order Example: is kept, but reverse the letters of each word. MEET ME AFTER THE TOGA PARTY EHT ELGAE SAH DEDNAL Add a Z to make it 24 letters long.

Lewinter & Widulski The Saga of Mathematics 67 Lewinter & Widulski The Saga of Mathematics 68

The Rail Fence Cipher The Rail Fence Cipher

Write the message by printing every other letter a Encoding and decoding is simpler and more trifle lower on the page. accurate if you divide the cipher text into groups MEET ME AFTER THE TOGA PARTY Z of 4. That is why we added the nulls Z at the end.

M E M A T R H T G P R Y Variations include copying the two rows in reverse order or copying one row forward and the E T E F E T E O A A T Z other backward. Other varieties involve using more than two rows. MEMA TRHT GPRY ETEF ETEO AATZ

Lewinter & Widulski The Saga of Mathematics 69 Lewinter & Widulski The Saga of Mathematics 70

3-Line Rail Cipher The Twisted Path Cipher

Variation by writing the letters in a zigzag. Uses a rectangular grid or matrix which is a MEET ME AFTER THE TOGA PARTY Z checkerboard of empty squares. The message is written in the cells from left to M M T H G R right, taking the rows from top to bottom E T E F E T E O A A T Z M E E T M E E A R T P Y A F T E R T H E T O G A MMTH GRET EFET EOAA TZEA RTPY P A R T Y Z

Lewinter & Widulski The Saga of Mathematics 71 Lewinter & Widulski The Saga of Mathematics 72

12 The Twisted Path Cipher The Twisted Path Cipher

Then trace on the matrix a particular path agreed Copy the letters along the path starting at the upon in advance by everyone who will be using beginning and going forward or at the end and the code. working backward. M E E T M E M E E T M E A F T E R T A F T E R T H E T O G A H E T O G A P A R T Y Z P A R T Y Z ETAZ YGRM TEOT RTTE EFEA PHAM ETAZ YGRM TEOT RTTE EFEA PHAM

Lewinter & Widulski The Saga of Mathematics 73 Lewinter & Widulski The Saga of Mathematics 74

The Twisted Path Cipher Scrambling with a Key Word

You can use a spiral starting at any corner cell This is a variation on the twisted path cipher. and whirl inward, clockwise or counterclockwise, Instead of using regular paths, broken or or you can begin at one of the central cells and continuous, a key word is used for mixing up the spiral outward. columns of the matrix in a completely haphazard M E E T M E way. A F T E R T First the message is written in the cells according H E T O G A to an agreed upon plan. P A R T Y Z

Lewinter & Widulski The Saga of Mathematics 75 Lewinter & Widulski The Saga of Mathematics 76

Scrambling with a Key Word Scrambling with a Key Word

To scramble the columns, number them 1 to 6, The number corresponds to its position in the but mix up the digits. alphabet. Our key word would be: 546132 Write the six digits above the columns. Since numbers are not easy to remember, we 5 4 6 1 3 2 use a key word. M E E T M E Any word, with no two letters alike, can be the O G A P A A key. T Z Y T R F We will use the word: MIRAGE E H T R E T

Lewinter & Widulski The Saga of Mathematics 77 Lewinter & Widulski The Saga of Mathematics 78

13 Monoalphabetic Scrambling with a Key Word Substitution Ciphers The digits tell us the order to follow in copying the The order of the letters stays the same but for columns from top down. each letter a different letter, or some kind of symbol, is used. Copy the first column headed 1, then the column headed 2, and so on to column 6. Something is substituted for every letter of the message. The ciphered text will be: Monoalphabetic (or single alphabet) means that TPTR EAFT MARE EGZH MOTE EAYT for every letter, one and only one letter or symbol is substituted.

Lewinter & Widulski The Saga of Mathematics 79 Lewinter & Widulski The Saga of Mathematics 80

Monoalphabetic Substitution Ciphers One of the simplest and oldest substitution Also known as shift ciphers. ciphers is created by writing the alphabet forward, A key number tells you how far to shift a second the underneath, the alphabet backward: alphabet when it is written underneath the first ABCDEFGHIJKLMNOPQRSTUVWXYZ one. ZYXWVUTSRQPONMLKJIHGFEDCBA Suppose the key number is 3. Each letter stands for the letter directly below(or Write the alphabet in a row, put your pencil on A above) it. and count 3 letters to the right, starting on B and Example: GSRH RH ZM VCZNKOV ending on D.

Lewinter & Widulski The Saga of Mathematics 81 Lewinter & Widulski The Saga of Mathematics 82

Caesar Cipher Caesar Cipher

Put D below A and continue to the right with E, F, G, .. To encode a message, find the letter in the top Until you reach Z, then go back to A and finish the row and substitute for it the letter immediately alphabet. below. A=0, B=1, C=2, …, Y=24, Z=25. To decode, find the letter in the bottom row and Encrypt: C = (P + 3) mod 26 write the letter above it. Decrypt: P = (C – 3) mod 26 Note: Sometimes a word becomes another word COLD in a 3-shift Plaintext Letter A B C D E F G H … PECAN in a 4-shift Ciphered text Letter D E F G H I J K … SLEEP in a 9-shift

Lewinter & Widulski The Saga of Mathematics 83 Lewinter & Widulski The Saga of Mathematics 84

14 Caesar Cipher Example General Caesar Cipher

ATTACK AT DAWN DWWDFN DW GDZQ Mathematically, the encryption and decryption functions can be described as follows: Breaking the Caesar Cipher can simply be done by The sender encodes each plain letter P using the testing all possible shifts. key b as follows: Since we used an alphabet of length 26 we have to test 26 shifts. C = (P + b) mod 26.  and decryptions should be performed by a The recipient decodes each cipher letter C using computer. again the key b as follows: For that purpose, we number each letter a=0, b=1, c=2, ..., y=24, z=25. P = (C – b) mod 26.

Lewinter & Widulski The Saga of Mathematics 85 Lewinter & Widulski The Saga of Mathematics 86

Key Word Ciphers Multiplication Cipher

A simple using the keyword Similar to a shift cipher but instead of adding the JUPITER key we multiply by it. Write the alphabet in a row, then underneath, The number we multiply by is our key a. write JUPITER, followed by all the other letters in alphabetical order. Thus, our encryption function may be written as ABCDEFGHIJKLMNOPQRSTUVWXYZ C = a * P mod 26 JUPITERABCDFGHKLMNOQSVWXYZ where P denotes the value of the plaintext letter Note: Key words can not have duplicate letters. and C denotes the value of the ciphertext letter.

Lewinter & Widulski The Saga of Mathematics 87 Lewinter & Widulski The Saga of Mathematics 88

Multiplication Cipher Multiplication Cipher Example

You can't just multiply by any key a; multiplying Let’s use a = 3, so our formula is by some numbers won't result in a usable cipher. C = (3 * P) mod 26 The key a must have an inverse modulo 26. A=0, B=1, C=2, D=3, E=4,…, Y=24, Z=25. The only numbers that work are those that are Multiply by 3 and modulo 26 yields “relatively prime” to 26. A=0, B=3, C=6, D=9, E=12,…, Y=20, Z=23.  Which means they don't have any prime factors in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 common with 26. 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 Thus, you can use any odd number except 13. A D G J M P S V Y B E H K N Q T W Z C F I L O R U X

Lewinter & Widulski The Saga of Mathematics 89 Lewinter & Widulski The Saga of Mathematics 90

15 Affine (Linear) Cipher Linear Cipher Example

Affine means linear, so this cipher takes on the Let’s use a = 5 and b = 13, so our formula is same form as a line: C = (5 * P + 13) mod 26 C = (a * P + b) mod 26 A=0, B=1, C=2, D=3, E=4,…, Y=24, Z8. Note that when a = 1 you have a shift cipher, and Multiply by 5 and add 13 and modulo 26 yields when b = 0 we have a multiplication cipher. A=13, B=18, C=23, D=2, E=7,…, Y=3, Z=8.

Again here the greatest common factor for a and 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 has to be 1. 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 N S X C H M R W B G L Q V A F K P U Z E J O T Y D I

Lewinter & Widulski The Saga of Mathematics 91 Lewinter & Widulski The Saga of Mathematics 92

The Pigpen Cipher The Pigpen Cipher

The Pigpen Cipher was used by Freemasons in The alphabet is written in the grids shown, and then the 18th Century to keep their records private. each letter is enciphered by replacing it with a symbol that corresponds to the portion of the pigpen grid that It was also reportedly used by the Confederate contains the letter. States in the Civil War. The cipher does not substitute one letter for another but rather it substitutes each letter for a symbol.

Lewinter & Widulski The Saga of Mathematics 93 Lewinter & Widulski The Saga of Mathematics 94

Pigpen Cipher Example The Polybius Checkerboard

Decode the following message: Polybius was an ancient 1 2 3 4 5 Greek writer who devised a method of substituting 1 A B C D E 2-digit numbers for each letter. 2 F G H I J Using the matrix at the 3 K L M N O Answer: This cipher was once used by right, substitute for each freemasons. letter the numbers 4 P Q R S T marking the row and column. 5 U V W X Y/Z

Lewinter & Widulski The Saga of Mathematics 95 Lewinter & Widulski The Saga of Mathematics 96

16 The Polybius Checkerboard Random Substitution Ciphers

Always put the row number first. A random substitution cipher is one that is For example, the number for K is 31. constructed without a plan. The word PUMPKIN would become Merely write the alphabet, and next to each letter 14 - 51 – 33 – 41 – 31 – 24 – 34. you put any letter, number or symbol. Note that both Y and Z are written in the last cell Popular Examples: to divide the letters evenly. Arthur Conan Doyle’s “The Adventure of the Dancing Men” The context of the message should make it clear which of the two letters is intended. Edgar Allen Poe’s “The Gold Bug”

Lewinter & Widulski The Saga of Mathematics 97 Lewinter & Widulski The Saga of Mathematics 98

Breaking Substitution Ciphers Breaking Substitution Ciphers

Are monoalphabetic ciphers secure? Monoalphabetic ciphers can all be broken. At First Glance: The reason why such ciphers can be broken is 26! possible encryptions. that although letters are changed the underlying At one decipherment per microsecond it would letter frequencies are not! take 1000 years to test all 26! decipherments by If the plain letter “a” occurs 10 times, its cipher brute force. letter will do so 10 times. Answer – No! Therefore, any monoalphabetic cipher can be In a long message, letter frequencies betray the text. broken with the aid of letter .

Lewinter & Widulski The Saga of Mathematics 99 Lewinter & Widulski The Saga of Mathematics 100

Breaking Substitution Ciphers Polyalphabetic Ciphers

Cryptanalyst's Tools: Monoalphabetic ciphers – one symbol for each Letter frequency data letter. Prefix/suffix lists Polyalphabetic ciphers are more difficult to break. ant-, inter-, post-, -ate, -ing Poly means many. Letter pair/triple lists That is, throughout the ciphertext different -re-, -th-, -en-, -de-, -ion-, -ive-, -ble- symbols can stand for the same letter and the Common pattern lists same symbol can stand for different letters. -eek-, -oot-, -our-

Lewinter & Widulski The Saga of Mathematics 101 Lewinter & Widulski The Saga of Mathematics 102

17 Polyalphabetic Ciphers Simple Example

The Reason Create two ciphers using a multiplication and a To make substitution ciphers more secure. shift cipher. The reason behind using polyalphabetic ciphers is to Alternate ciphers while encrypting or decrypting flatten frequency distributions! the text. Advantages of polyalphabetic ciphers: For example: Flattens letter frequencies. Double letter pairs not so obvious. Odd positions use C = (3 * P) mod 26 Prefix tables become more complicated. Even positions use: C = (5 * P + 13) mod 26

Lewinter & Widulski The Saga of Mathematics 103 Lewinter & Widulski The Saga of Mathematics 104

Porta’s Digraphic Cipher Porta’s Digraphic Cipher

Invented by Giovanni Battista Porta in 1563. The formula for each letter pair L1-L2 is A digraphic cipher is one in which pairs of letters, C = L1 * 26 + L2 instead of individual letters, provide the basis of Assuming A = 0, B = 1, …, Z = 15. We get the cipher text.  In the Porta Cipher, a single symbol is substituted AA = 0, AB = 1, AC = 2, …, ZZ = 675 for every pair of letters in the message. Example: Help me! To use this cipher you need an enormous 26×26 becomes HE-LP-ME which is 186-301-316. matrix.

Lewinter & Widulski The Saga of Mathematics 105 Lewinter & Widulski The Saga of Mathematics 106

The The Playfair Cipher

Invented by Charles Wheatstone, famous for The cipher replaces each pair of letters in the musical instruments and one of the pioneers of plaintext with another pair of letters, so it is a type the telegraph. of digraph cipher. Named for his friend Baron Lyon Playfair. The matrix is smaller than that used in the Porta Wheatstone created the cipher for sending secret cipher. messages by standard telegraph codes. To construct the matrix, pick a keyword and write It was used for many years by the British Army it into a 5×5 square, omitting repeated letters and and Australia used it in World War II. combining I and J in one cell.

Lewinter & Widulski The Saga of Mathematics 107 Lewinter & Widulski The Saga of Mathematics 108

18 The Playfair Cipher The Playfair Cipher

In this example, we use B O X E R Follow the keyword with the rest of the alphabet’s the keyword BOXER and letters in alphabetical order. write it into the square by rows. A C D F G Encryption depends on the type of digraph (letter pair). Any other pattern will do H I/J K L M including writing it by The digraphs fall into one of three categories: columns or writing it in a both letters are in the same row spiral starting at one N P Q S T both letters are in the same column corner and ending in the center. U V W Y Z the letters share neither a row nor a column

Lewinter & Widulski The Saga of Mathematics 109 Lewinter & Widulski The Saga of Mathematics 110

The Playfair Cipher The Playfair Cipher

If the two letters are in If both letters are in the same row B O X E R different rows and in they are replaced by the letters immediately to the different columns right of each one. If a letter is at the end of a row, it is A C D F G each letter is replaced by replaced by the letter at the beginning. the letter in the same row that is also in the column H I/J K L M If both letters are in the same column occupied by the other they are replaced by the letter immediately beneath letter. N P Q S T each one. If a is at the bottom of a column, it is For example, AT replaced by the letter at the top. becomes GN. U V W Y Z

Lewinter & Widulski The Saga of Mathematics 111 Lewinter & Widulski The Saga of Mathematics 112

The Playfair Cipher Example The Playfair Cipher

Encrypt: B O X E R “MEET ME AT ONE AM.” ME ET ME AT ON EA MX A C D F G First, break it up into two-letter groups. ME ET ME AT ON EA MX H I/J K L M If both letters in a pair are the same, insert an X between them. LR RS LR GN BP BF KR N P Q S T If there is only one letter in the last group, add an X to it. Now we encrypt each two-letter group. U V W Y Z

Lewinter & Widulski The Saga of Mathematics 113 Lewinter & Widulski The Saga of Mathematics 114

19 The Playfair Cipher The Vigenere Cipher

To decrypt the message, simply reverse the Named for Blaise de Vigenere a 16th century process: Frenchman. If the two letters are in different rows and columns, The Vigenere cipher is a take the letters in the opposite corners of their based on using successively shifted alphabets, a rectangle. different shifted alphabet for each of the 26 If they are in the same row, take the letters to the left. English letters. If they are in the same column, take the letters above The procedure is based on the table shown on each of them. the next slide and the use of a keyword.

Lewinter & Widulski The Saga of Mathematics 115 Lewinter & Widulski The Saga of Mathematics 116

The Vigenere Cipher The Vigenere Cipher

Note that each row of the One Method of Using the Vigenere Table: matrix corresponds to a 1. Choose a key. Caesar Cipher. 2. Break text into groups of five characters. The first row is a shift of 0 3. Write the key in repeating fashion. the second is a shift of 1 and 4. Use letter of key to establish column. the last is a shift of 25. 5. Use plaintext to establish row. For a better matrix click 6. Encrypt by using intersection of row and column. here.

Lewinter & Widulski The Saga of Mathematics 117 Lewinter & Widulski The Saga of Mathematics 118

The Vigenere Cipher Example The Vigenere Cipher

The keyword is CIPHER. A computer program would implement the The message is MEET ME AT ONE AM. following algorithm: C I P H E R C I P H E R C Code the letters as numbers (A=0, B=1, etc.) The key is keyword M E E T M E A T O N E A M To Encrypt: Add the keyword to the plaintext (letter by O M T A Q V C B D U I R O letter) Encrypted becomes OMTA QVCB DDUI RO. To Decrypt: Subtract keyword from the ciphertext

Lewinter & Widulski The Saga of Mathematics 119 Lewinter & Widulski The Saga of Mathematics 120

20 The Date Shift Cipher Operations Research

This is a variation on the Vigenere cipher Operations Research (OR) is the use of the scientific sometimes called a Gronsfeld cipher. methodology in studying systems whose design or operation require human decision making. It uses the digits of a key number instead of a the OR provides the means for making the most effective letters of keyword. decisions - some of which are mainly concerned with The easiest key number to use is the date. design, while others are mainly operational in nature. Everything else is essentially the same as the OR is interdisciplinary, drawing on (and contributing to) Vigenere cipher. the techniques from many fields, including mathematics, engineering, economics and the physical sciences.

Lewinter & Widulski The Saga of Mathematics 121 Lewinter & Widulski The Saga of Mathematics 122

Operations Research Operations Research Topics

OR practitioners have successfully solved a wide variety Linear Algebra Decision Making Under of real world problems. Linear Programming and Uncertainty Most importantly, new applications are continually Duality Decision Trees arising, most notably in computer and telecommunication Game Theory Multi-criteria Decision technology, in the financial and economic community, in Dynamic Programming Making medicine, in education, to name just a few. Critical Path Method Sensitivity Analysis Many of these new applications originate from relatively Graph Theory Inventory Theory and recent societal problems, such as food and energy Production production and distribution, health maintenance, Goal Programming environmental pollution control, and software production. Branch and Bound

Lewinter & Widulski The Saga of Mathematics 123 Lewinter & Widulski The Saga of Mathematics 124

References References

 Binary Numbers, John Rieman, September 28th, 2001, 11:12pm, D. Kahn, The Codebreakers, Macmillan Publishing http://www.cs.colorado.edu/~l3d/courses/CSCI1200- 96/binary.html Company, 1976.  Binary Number System, Erik Ostergaard, September 28th, 2001, A. Menezes, P. van Oorschot, and S. Vanstone, 11:14pm, http://www.danbbs.dk/~erikoest/binary.htm Handbook of Applied Cryptography, CRC Press, 1997.  “Bit (computer)”, Microsoft® Encarta® Online Encyclopedia 2001, ©1997-2000 Microsoft Corporation, September 28th, 2001, M. Gardner, Codes, Ciphers, and Secret Writing, Dover 11:17pm, Publications, Inc., 1972. http://encarta.msn.com/find/Concise.asp?z=1&pg=2&ti=76155185 L. Smith, Cryptography the Science of Secret Writing, 1 Dover Publications, Inc., 1943.

Lewinter & Widulski The Saga of Mathematics 125 Lewinter & Widulski The Saga of Mathematics 126

21 Web Sites

Check out Computer History web site. The Black Chamber web site. The GCHQ web site. The Crypto Tutorial web site. A Cryptographic Compendium The SSH website Check out Operations Research Tutor web site.

Lewinter & Widulski The Saga of Mathematics 127

22