Math 235 Homefun Exercises

Dr. G Fall 2017

1: WTF is Discrete Math?

It’s time to get you set up with LATEX, a typesetting language that does a much better job of creating professional-looking documents than standard word processors like Microsoft Word. The King’s College Math and Computer Science departments both require their students to become proficient in LATEX. Now is the time to get started! Go to the computer lab, find and run the application TeXstudio, and open the document Welcome to LaTeX.tex that I emailed to you. Compile it by pressing the F5 key. Read the whole thing!

2: Fundamentals

1. Draw a graph with five vertices v1, v2, v3, v4, and v5 such that the degree of v1 is 3, v2 has odd degree, v3 has degree 2, and v4 and v5 are adjacent. 2. For all the graphs you’ve seen so far, go back and count the number of edges in each. Then, add up the degrees of all the vertices. You should see a connection between the number of edges and the sum of all degrees. State that connection clearly and succinctly. 3. If a has an even degree (2, 4, 6, etc.), then we call it an even vertex. Likewise, a vertex having an odd degree is called an odd vertex. Use what you found in the previous exercise to prove that in any graph, the number of odd vertices must be even. 4. Consider a graph with seven vertices. Five vertices have degree 4 and two vertices have degree 2. How many edges does this graph have? 5. Consider a graph whose degree sequence is 5, 5, 4, 4, 3, 3, 3, 3. How many edges does this graph have?

6. What is the degree sequence of the complete graph Kn?

7. How many edges does the complete graph Kn have? Experiment for specific small values of n, and then give the general answer in terms of n. 8. Draw graphs having the following degree sequence, or else explain why no such graph can exist.

1 (a) 1, 1, 1, 1 (b) 1, 1, 1, 1, 1 (c) 2, 2, 2, 2, 2 (d) 4, 4, 3, 2, 2, 0 (e) 3, 3, 3, 3, 2, 2, 2 (f) 3, 3, 3, 3, 3, 3 (g) 6, 6, 4, 2, 2, 2, 1, 1

9. Try to draw a graph where the degrees of the vertices are all different. Can you do it? If so, show me. If not, try to prove why you believe it’s impossible.

10. Imagine the complete graph K6 where each edge has been colored either red or blue. Prove that this graph contains either a red triangle or a blue triangle.

11. Show that K5 can have its edges colored red and blue with no red nor blue triangles. 12. Suppose all vertices in a graph have the same odd degree k. Show that the number of edges is a multiple of k.

13. Show by example that if the vertices in a graph all have the same even degree k, the number of edges may or may not be a multiple of k.

3: Cycles

1.A cut vertex is any vertex in a connected graph that, if deleted, would disconnect the graph.

(a) Draw a graph with 5 vertices, one of which is a cut vertex. (b) Draw a graph with 5 vertices such that every vertex is a cut vertex. (c) Explain why no graph having a cut vertex can be Hamiltonian.

2. Suppose that if G is a connected graph and C is a within G. Prove that if one of the edges of C is deleted, G remains connected.

3. A graph G with n vertices is called pancyclic if it contains cycles of every length 3, 4, ..., n. For each of n = 4, 5, and 6, draw a pancyclic graph with n vertices. To make it more interesting, use as few edges as possible.

4. Determine whether the following graphs are Hamiltonian: 5. Prove that any graph with degree sequence 4, 4, 4, 4, 4, 4 is Hamiltonian.

6. The Wn consists of a cycle graph Cn together with one extra vertex that is adjacent to all other vertices (so actually, the wheel graph Wn has n + 1 vertices). For example, here is W6:

(a) What is the degree sequence of Wn?

(b) Prove that Wn is Hamiltonian for all n ≥ 3.

7. Solve the Traveling Salesperson Problem for the weighted graph below two ways: first using the Nearest Neighbor algorithm (start at the top vertex), then using Cheapest Link.

7 1

6 3 4 10 8 2 5

9 8. There are 8 different binary strings of length 3:

000, 100, 010, 001, 110, 101, 011, 111

Draw a graph where each vertex represents one of these strings. Draw an edge between two vertices if and only if the strings differ only in one digit. For example, the strings 100 and 110 differ only in the second digit, so you should draw an edge between these two vertices. Find a Hamilton cycle in this graph.

9. The girth of a graph is the length of its shortest cycle. What is the girth of the complete graph Kn? What is the girth of the cycle graph Cn? 10. Find the girth of the following graph:

Note: this graph is famous. It’s called the Petersen Graph. You’ll be seeing it a lot.

4: Circuits

1. Use Fleury’s algorithm to find an Euler circuit in the graph below:

2. Find an Euler circuit in each of the graphs below: G

A F

B E

C D

3. Consider the graph below:

(a) Explain why this graph does not possess an Euler circuit. (b) Label the vertices, and then give an Euler path in this graph.

4. For which values of n does the complete graph Kn have an Euler circuit? 5.A bridge is any edge in a connected graph that, if deleted, would disconnect the graph.

(a) Draw a graph with 6 vertices having exactly one bridge. (b) Draw a graph with 6 vertices such that every edge is a bridge. (c) Explain why no graph having a bridge can have an Euler circuit. (d) Show by examples that a graph having a bridge may or may not have an Euler path.

6. List all bridges in the following graph: A

B G

C G

D F

E

Hint: This is actually kinda tricky because of the way the edges are crossing each other. If you try redrawing the graph without any edges crossing, finding the bridges becomes much easier. 7. We saw one practical application of Euler circuits: the Trash Collector Problem. Find at least two other “real world” situations that amount to finding an Euler circuit in some graph. 8. A graph is randomly traceable from a vertex v if, whenever we start from v and traverse the graph in an arbitrary way never retracing any edge, we eventually obtain an Euler circuit.

(a) Show that the graph below is randomly traceable from the marked vertex v.

v

(b) Show that this graph is not randomly traceable from any other vertex.

5: Trees

1. If T is a with n vertices, what is the maximum degree any one vertex can have? 2. If T is a tree with n vertices, what is the maximum number of leaves (i.e. vertices of degree 1) T can have? 3. Prove that if T is a tree, then adding any new edge creates a cycle.

4. I’m very bad at chess, so I’ve decided that the next time I play, I will quit after winning a game or after five games have been played. Make a tree showing all possible outcomes. How many outcomes are there? In how many of these outcomes do I win a game?

5. It’s the weekend and I have several ways to spend my Friday and Saturday evenings. I could do some cleaning, watch cat videos on Youtube, or go out with my friends. Make a tree showing all the possible ways I can spend my Friday and Saturday evenings.

6. Draw some trees and count how many edges they have. Then finish this conjecture: If a tree has n vertices, then it has edges. Try to prove your conjecture.

7. Solve the minimal connector problem for this edge-weighted graph. What is the total weight of the spanning tree you found?

3 5 A B C

2 5 5 7 1

9 1 D E F

1 3 6 8 3

G H I 7 4

8. Application to Chemistry: One of the earliest uses of graphs was to enumerate chemical molecules. If we have a molecule consisting only of carbon and hydrogen atoms, then we can represent it as a graph in which each carbon atom appears as a vertex of degree 4 and each hydrogen atom appears as a vertex of degree 1.

The graphs of n-butane and 2-methyl propane are shown below. Although they have the same chemical formula C4H10, they are different molecules because the atoms are arranged differently within the molecule. These two molecules form part of a general class of molecules known as the alkanes, or paraffins, with chemical formula CnH2n+2. It is natural to ask how many different molecules there are with this formula. H

H C H

H H H H H H

H C C C C H H C C C H

H H H H H H H

To find all possible molecules with the formula CnH2n+2, note that the molecule is completely determined by how the carbon atoms are arranged; once the carbon atoms are set, the hydrogen atoms just fill in to bring the degree of each carbon vertex to 4. So forget the hydrogen atoms, and the problem is reduced to finding the number of distinct trees with 4 vertices.

C

C C C C C C C

It turns out, these two are the only trees with 4 vertices (up to isomorphism), so n-butane and 2-methyl propane are the only molecules with formula CnH2n+2.

Now it’s your turn! Draw all possible chemical molecules for C5H12 and C6H14. 9. Application to Computer Science: It’s very easy for us to find Hamilton cycles in this simple graph:

A C

B D

In fact, there are exactly two Hamilton cycles: ABDCA and its reverse ACDBA. This is easy for us, because we have eyes and a brain. But increasingly, computers are tasked with solving graph theory problems, so the more interesting problem here is “How can we program a computer to find a Hamilton cycle in a graph?”

In general, this is a very expensive problem, meaning it can take a lot of processing time for a computer to search a graph for a Hamilton cycle. The programmer has to instruct the computer to search the graph in an orderly, algorithmic way. Say we start at vertex A. Then we could first travel to either B or C. If we go to B, then we can go to either C or D next. And so on, and so on, . . . These and all other possible paths are stored in the following search tree: A

B C

C D B D

D C D B

A A

Our original graph was very simple, so the search tree is small. Starting from vertex A, there are only four ways the computer could blindly stumble through the graph, represented by the four downward branches of the tree. Two of those branches are dead ends (ABCD and ACBD), and the other two branches reveal the two Hamilton cycles noted earlier.

So how do we tell the computer how to investigate the search tree? The standard approach to this type of problem is to perform a depth-first search. Number the vertices if they aren’t already, so the computer knows which vertex to try first when a choice arises. Our vertices are already labeled A, B, C, and D, so we’ll just use alphabetical order. Starting from vertex A, the computer must choose whether to travel to B or C. Alphabetical order says try B first. From B, the computer must choose either C or D (the only remaining vertices we haven’t visited yet). Alphabetical order says go to C. From here we must go to D, and we hit a dead end.

From the dead end, we climb back up the tree until we reach a branch we haven’t explored yet. Keep doing this until you discover a Hamilton cycle. Here’s our original graph again, and the search tree with the steps described above illustrated. Try to follow the search process both in the original graph and its search tree. A

B C

D B A C C D

C D B D D B

A A

The depth-first search follows the walk ABCDCBDCA, eventually finding the Hamil- ton cycle ABDCA. If the task is just to determine whether a given graph is Hamilto- nian, the algorithm would stop here. If our task were to find all the Hamilton cycles in the graph, we would have to instruct the computer to search the entire tree, keeping track of all cycles found along the way.

Now it’s your turn! Here’s a pretty graph:

A

B C

E D

(a) Draw the search tree for this graph, using the alphabetical ordering of the vertices. (b) Starting at vertex A, perform a depth-first search for a Hamilton cycle. List the vertices in the order they are visited during the search. (c) What Hamilton cycle does the search algorithm eventually find? (d) How many times does the algorithm have to backtrack through the tree before it finds a solution? 6: Coloring Graphs

1. Find χ(G) for the Petersen Graph (on the left) and the Grotzsch Graph (on the right):

2. Find χ(G) for the Cube Graph:

3. Recall that the wheel graph Wn consists of a cycle graph Cn together with another vertex that is adjacent to all other vertices. What is the chromatic number of the wheel graph?

4. Prove or give a counterexample: for any n ∈ N, there exists a graph G with χ(G) = n. 5. Determine which of the following graphs are bipartite. 6. The six students of a super fancy preschool are going on a field trip. The problem is, many of these students don’t get along with one another and will have to travel in separate cars. The x’s in the chart below show which pairs of kids are in conflict. (for example, the x in row 1, column 2 says that Amy and Bob can’t ride in the same car.) Use graph coloring to determine how many cars will be needed for the field trip.

Amy Bob Carl Doug Eva Fran Amy x x x Bob x x x Carl x x x x Doug x x x Eva Fran x x x

7. The complete Km,n is the bipartite graph with m “red” vertices and n “blue” vertices such that every red vertex is adjacent to every blue vertex. Draw K2,2, K4,2, K3,3, K6,1, and Kn,1. 8. Suppose G is a bipartite graph with an odd number of vertices. Explain why G can not possibly be Hamiltonian. 9. Use the previous problem to prove the following graph is not Hamiltonian. 7: Planar Graphs and Euler’s Polyhedron Formula

1. Find a planar drawing of K3,2:

2. Prove that K5 is not planar.

3. Prove that K3,3 is not planar.

4. Explain why K2,n is planar for any n ∈ N. In any planar drawing of K2,n, how many faces are there?

5. If a graph G has 10 vertices and is planar, what is the maximum number of edges it can have?

6. If a graph G has 50 edges and is planar, what is the minimum number of vertices it can have?

7. Use Euler’s formula to prove that if G is connected, planar, and bipartite, then E ≤ 2V − 4.

8. Prove that if G is a , then G must have a vertex of degree 5 or less. Hint: Suppose every vertex has degree six or more. Show that this leads to a contradiction.

9. A cube has eight vertices, twelve edges, and six faces. Sure enough, V − E + F = 2. Fill in the chart below (you can use Google!), and verify Euler’s formula for the other four platonic solids.

Tetrahedron Cube Octahedron Icosahedron Dodecahedron Vertices 8 Edges 12 Faces 6 V − E + F ? 2

10. Is every tree planar? Explain your reasoning. 11. When presented with the following graph, a student says “That graph is not planar, because two of the edges are crossing.”

What is wrong with this student’s reasoning?

12. Application to Geometry: One of the most surprising formulas for computing areas seems more like a magic trick than real math. But it works! It’s called Pick’s Theorem, and it can find the area of any polygon whose vertices are all integer points (i.e points (x, y) where both x, y ∈ Z). For example, here’s a triangle:

y

x

There are 14 integer points on the boundary of this polygon, and 9 integer points inside the polygon (please confirm this now!). Pick’s Theorem says: to find the area, divide the number of integer points on the boundary by 2, then add the number of interior points, then subtract one: 14 A = + 9 − 1 = 7 + 9 − 1 = 15. 2 1 You can confirm this is correct using the traditional A = 2 bh formula. More generally, the theorem says that a polygon with vertices at integer points having B integer points on the boundary and I interior integer points has area 1 A = B + I − 1. 2 Let’s see why Pick’s Theorem works. In other words, let’s prove it! (a) An elementary triangle is a triangle whose vertices are integer points but has no other integer points inside or on the boundary. Every elementary triangle has the same area. What is it? (b) Given a polygon with vertices at integer points, the first step is to triangulate it into a bunch of elementary triangles. For example:

triangulate! −−−−−−−→

The polygon, the integer points inside and on the boundary, and the new edges created by the triangulation now form a planar graph with V vertices, E edges, and F faces. Let VB and VI denote the number of vertices on the boundary and interior, respectively (so V = VB + VI ). Likewise, let EB and EI denote the number of edges on the boundary and interior (so E = EB + EI ). Explain why VB = EB. 1 (c) Use the two previous parts to explain why the polygon’s area is A = 2 (F − 1). (d) Now we count edges. Each elementary triangle is bordered by 3 edges. Use this to prove that 3(F − 1) + EB = 2E. (e) Combine the results of the two previous parts to obtain the formula 1 E = F − 1 + A + E . 2 B

(f) Plug in for E in Euler’s polyhedron formula to get 1 A = V − E − 1. 2 B

(g) Finally, use the earlier facts that V = VB + VI and EB = VB to finish the proof of Pick’s Theorem. (h) Why does Pick’s Theorem require the polygon to have its vertices at integer points? Specifically, which part(s) of our proof would fail if the polygon’s vertices were not necessarily at integer points? 8: Graph Theory in terms of Set Theory

1. Draw the graph G = (V,E) with V = {a, b, c, d, e, f} and

E = {{a, b}, {a, c}, {a, d}, {a, e}, {b, d}, {b, f}, {c, d}}.

2. If I asked you to draw the graph G = (V,E) with

E = {{a, b}, {a, c}, {a, d}, {a, e}, {b, d}, {b, f}, {c, d}},

do you have enough information to draw the graph?

3. List the vertex set and edge set for the graph

3 2

4 1

5 6

4. Draw the graph complements of the cycle graphs C3, C4, C5, and C6. 5. Draw the graph complement of the cube graph.

6. If G has 7 vertices and 12 edges, how many vertices edges does its graph complement G have?

7. If G has n vertices and m edges, how many vertices and edges does its graph comple- ment G have?

8. Recall that the Km,n is the bipartite graph with vertex sets V1 of size m and V2 of size n. How many edges does Km,n have?

9. What is the graph complement of Km,n? 10. Several times so far, we talked informally about deleting edges and vertices in graphs. Here are the formal, set-theoretic definitions. If G = (V,E) is a graph and e ∈ E, the graph G − e is the graph obtained by removing e from the edge set. If v ∈ V , the graph G − v is the graph obtained by removing v from the vertex set and removing any edge e such that v ∈ e.

For each of the graphs G shown below, with vertex v and edge e marked, draw G − e and G − v. e

v e v e

v

11. Directed graphs, or digraphs for short, are just like graphs except the edges are ordered pairs of vertices, rather than 2-subsets of vertices. If (v, w) is an edge of a G, we draw an arrow from v to w when drawing the graph. Draw the directed graph G = (V,E) with V = {1, 2, 3, 4} and

E = {(1, 2), (1, 3), (2, 1), (2, 3), (2, 4), (4, 2), (4, 3)}.

12. For the digraph below, list the vertex set V and the edge set E.

3 2

4 1

5 6

13. For an undirected graph G = (V,E), we defined edges to be 2-element subsets of V . And of course we all remember that in a set, order doesn’t matter. That is, the edge {v, w} is the same as the edge {w, v}. Also, with sets we never list the same element more than once; i.e. the set {v, v} is just the set {v}, which is not a 2-subset. So for undirected graphs, every edge joins two distinct vertices.

Directed graphs are different, because the edges are ordered pairs. And in ordered pairs, you can list the same element twice. So directed graphs can have edges joining vertices to themselves! We call them loops (can you guess why?).

Draw the directed graph G = (V,E) with V = {1, 2, 3, 4} and

E = {(1, 1), (1, 2), (2, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 1)}. 9: Sets and Relations

1. Let A = {1, 2, 3} and B = {x, y}. List all the elements of the Cartesian product A×B.

2. If set A has m elements and set B has n elements, how many elements does A × B have?

3. Suppose set A has 17 elements. ∅, of course, is the empty set. How many elements does A × ∅ have? 4. Let A = {1, 2, 3, 4, 5, 6, 7, 8} and let B = {2, 4, 6, 8, 10}. Define a relation R : A → B by the rule “(a, b) ∈ R if and only if a > b.” List all the ordered pairs of this relation, and draw its digraph.

5. Let A be the set of students taking Math 235 this semester. Let B be the set of all courses being offered at King’s College this semester. Define a relation R : A → B by the rule “aRb if and only if student a is currently enrolled in course b.” List all the pairs of this relation that involve you.

6. Let A = {a, b, c, . . . , x, y, z} be the set of all letters in the English alphabet, and let B = {discrete, mathematics, boring, painful}. Define a relation R : A → B as follows: “(α, β) ∈ R if and only if letter α appears at least once in word β”. How many pairs does this relation have? Also, why do you think I used α and β in this exercise instead of a and b?

7. Let A = {1, 2, 3, 4}. List the ordered pairs of the relation R : A → A whose digraph is

1 2

4 3

8. Let A = {1, 2, 3, 4, 5} and let R : A → A be defined by

R = { (1,2), (3,1), (3,3), (4,4), (4,5)}

(a) Which new pairs must be added to make R reflexive? (b) Which new pairs must be added (besides the ones you already added in part (a)) to make R symmetric? (c) Which new pairs must be added (besides the ones you already added in parts (a) and (b)) to make R transitive?

9. Determine whether the following relations are reflexive, symmetric, antisymmetric, and/or transitive. (a) R : Z → Z defined by the rule xRy if and only if x − y ≥ 0. (b) R : Z → Z defined by the rule (x, y) ∈ R if and only if y = x2. (c) R : R → R defined by the rule xRy if and only if xy = 1.

10. Let A = {1, 2, 3, 4}. List the pairs in the relation R : A → A whose adjacency matrix is  1 0 0 1   1 1 0 0     0 1 1 1  1 1 1 0

11. Let A = {1, 2, 3, 4, 5}. Define a relation R : A → A by the rule (x, y) ∈ R if and only if xy > 9. List the pairs, draw the digraph, and give the adjacency matrix for R.

12. Application to Data Security: Imagine you’re a breaking into a safe (or, if you’ve done this before, just think back to the last time you did it). This safe requires you to enter a four-digit PIN. Curiously, unlike more secure locks that require the thief to enter a PIN and then press an ENTER button, this lock has no ENTER button and will accept whichever digits were entered last. You’ve got lots of time, so you figure “If I type all possible PINS, from 0000 to 9999, eventually I’ll stumble upon the right one. But how long might that take?”

Well, that depends on how cleverly you try potential PINS. If you type 0000, and then type 0001, and then 0002, and so on, you’re being very inefficient. Since the lock accepts the last four digits entered, you can let the potential PINS overlap. For example, typing 123456 actually tests three possible PINS, 1234, 2345, and 3456.

So now we’re ready to get to the real mathematics of this problem. We are looking for the shortest possible string of digits that contains all possible substrings of length 4. This type of problem (finding the shortest sequence containing all possible subsequences of some length) is applicable not just to hacking PIN-based locks, but also to DNA sequencing, robotics, and the design of neurological and psychological experiments. (thanks, Wikipedia!)

(a) There are 10000 potential PINS. Assuming they can be arranged so that each PIN has three digits overlapping with the one before it and the one after it, how many buttons do you have to push to test all of them? (b) A more secure system would require you to press an ENTER button after each attempted PIN. How many buttons would you have to push to test all potential PINS under this more secure system?

This problem has a graph-theoretic solution. However, if we use the digits 0 through 9, the graphs are very large. To keep things small, we’ll focus on the binary version of the problem. I think that once you know how to solve the binary version, you will see how to easily extend the solution to the ten-digit version. Let A be the set of all 4-digit binary strings:

A = {0000, 0001, 0010, 0100, 1000, 0011, 0101, 0110, 1001, 1010, 1100, 0111, 1011, 1101, 1110, 1111}

Define a relation R on A by the rule xRy if and only if the last three digits of string x equal the first three digits of the string y.

(c) Draw the digraph for this relation. (d) Find a Hamilton cycle in the graph, and use that cycle to construct a string of length 19 containing all 4-digit binary strings.

10: Equivalence Relations

1. Let A = {1, 2, 3, 4, 5, 6}, and let R : A → A be the relation

R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (3, 4), (4, 4), (4, 5), (5, 5)}.

Explain why R is not an equivalence relation. Specifically, which of the properties reflexive, symmetric, and/or transitive are violated?

2. Start with the relation R : A → A from the previous exercise. Add all necessary pairs to make R an equivalence relation on A. Then draw the directed graph and the adjacency matrix of the resulting equivalence relation.

3. Let ∼ be a relation on Z defined by a ∼ b if and only if a − b is a multiple of 4.

(a) Prove ∼ is an equivalence relation. (b) What are the equivalence classes of Z under ∼?

4. Let ∼ be a relation on Z defined by a ∼ b if and only if a − b is a multiple of 5.

(a) Prove ∼ is an equivalence relation. (b) What are the equivalence classes of Z under ∼?

5. Fix an integer n ≥ 2, and let ∼ be a relation on Z defined by a ∼ b if and only if a − b is a multiple of n.

(a) Prove ∼ is an equivalence relation. (b) What are the equivalence classes of Z under ∼?

a c 6. Two fractions b and d are equivalent if and only if ad = bc. Prove that the equivalence of fractions is indeed an equivalence relation.

7. Let A = Z − {0} be the set of all nonzero integers. Define a relation ∼: A → A by the rule a ∼ b if and only if ab > 0. (a) Prove ∼ is an equivalence relation. (b) What are the equivalence classes of A under ∼? (c) Why did we exclude zero? Would this relation ∼ still be an equivalence relation on Z? 8. Consider the partition {{2, 5}, {1, 3}, {4, 6, 7}} of the set A = {1, 2, 3, 4, 5, 6, 7}. Draw the graph and the adjacency matrix of the equivalence relation implied by this partition.

9. The idea of an “equivalence relation” is a generalization of the more familiar idea of “equality”. Define a relation ∼: N → N by the rule a ∼ b if and only if a = b. (a) “Prove” that this relation (which we simply call equality) is indeed an equivalence relation. (b) Since N contains infinitely many elements, we can’t actually draw the whole di- graph or adjacency matrix for the equality relation. But try your best to describe them verbally.

10. Application to Voting Theory: Here’s a scenario: four entrepreneurs start a com- pany. Each founder provides some startup money, and is thereby granted a proportional amount of decision-making votes. Amy provides $4000 and is given 4 votes. Bob pro- vides $3000 and is given 3 votes. Carol provides $3000 and is also given 3 votes. Dave provides $1000 and is given 1 vote. Whenever an important decision – i.e. a motion – arises, the founders vote on what to do. They agree that a simple majority (6 votes) will suffice to carry a motion.

This arrangement is an example of a weighted voting system, or WVS. A WVS consists of a set of players P1,P2,...,Pn who collectively vote on motions. Each player Pk has a certain weight, or number of votes, denoted wk. For simplicity the weights are always non-negative integers, and by convention

w1 ≥ w2 ≥ · · · ≥ wn. There is also a quota, or minimum number of votes needed for a motion to pass. The quota q must be at least a majority of the total number of votes, but no greater than the total number of votes. That is,

n n 1 X X w < q ≤ w . 2 k k k=1 k=1 Any WVS can be completely described by a compact array

[ q : w1, w2, . . . , wn ]. The example we started with was [ 6 : 4, 3, 3, 1 ].

Here’s the reason we’re talking about WVS now: the actual numbers involved in a WVS (the quota and the weights) can be extremely deceptive. For example, in the system [ 6 : 4, 3, 3, 1 ], the fact that P1 has 4 votes does not make P1 any more “powerful” than P2 or P3. To reach the quota, it is only necessary that two of the players P1, P2, and P3 want to pass the motion, and it doesn’t matter which two. Also, P4 with his one vote is absolutely powerless; there is no scenario where that one vote makes or breaks a motion. So I repeat: the actual numbers involved in a WVS can be extremely deceptive.

What really matters in a WVS is which coalitions – i.e. subsets of players – have enough weight to meet or exceed the quota. In the system [ 6 : 4, 3, 3, 1 ], the winning coalitions are {P1,P2}{P1,P2,P3}{P1,P2,P3,P4} {P1,P3}{P1,P2,P4} {P2,P3}{P1,P3,P4} {P2,P3,P4} Now look at this much simpler WVS: [ 2 : 1, 1, 1, 0 ]. It has the same number of players as our original example, and you should quickly check that it has precisely the same winning coalitions. So even though [ 2 : 1, 1, 1, 0 ] is not the same WVS as [ 6 : 4, 3, 3, 1 ], it is effectively no different.

Two WVS are equivalent if they have the same number of players and precisely the same winning coalitions. There are infinitely many possible WVS with n players, but they all sort themselves into a finite number of equivalence classes. Now it’s your turn!

(a) Prove that equivalence of WVS is indeed an equivalence relation. (b) For the WVS [ q : 5, 4, 3, 2, 1 ], what are the possible values for the quota q? For each “legal” value of q, find all the winning coalitions. (c) Determine whether the following WVS are equivalent:

[ 4 : 2, 2, 1, 1, 1 ] and [ 4 : 2, 1, 1, 1, 1 ]

(d) How many inequivalent WVS with n = 3 players can you find? That is, of the infinitely many WVS with 3 players, how many equivalence classes do they sort themselves into?

11: Ordered Sets

1. Let A = {a, b, c, d, e}. Answer the following by either listing pairs, graphing, or pro- viding an adjacency matrix. Better yet, list, graph, and provide a matrix!

(a) Give an example of a relation on A that is antisymmetric and transitive but is not a partial order. (b) Give an example of a relation on A that is reflexive and transitive but is not a partial order. (c) Give an example of a relation on A that is antisymmetric and transitive but is not a partial order.

2. Here are the Hasse diagram of three different partial orders on the set {a, b, c, d, e, f}. List all the pairs of each partial order.

f

c c f e f b b e d b c d e

a a d a

3. Let A = {1, 2} Draw the Hasse diagram of the poset (P(A), ⊆).

4. Let B = {1, 2, 3, 4}. Draw the Hasse diagram of the poset (P(B), ⊆).

5. If x and y are elements of a poset, we say that y covers x if x ≺ y but there is no intermediate z with x ≺ z ≺ y. In other words, we draw an edge in a Hasse diagram from x up to y if and only if y covers x.

(a) In the poset (Z, ≤), which element(s) cover 7? (b) Let A = {1, 2, 3, 4, 5, 6}. In the poset (P(A), ⊆), which element(s) cover {1, 2}? (c) Let A = {1, 2, 3,..., 99, 100}. In the poset (P(A), ⊆), how many elements cover {1, 2}?

6. Let A = {1, 2, 3,..., 20}. Define a relation R : A → A by the rule (x, y) ∈ R if and only if y is an integer multiple of x. For example, (2, 10) ∈ R because 10 is an integer multiple of 2, but (3, 10) ∈/ R because 10 is not an integer multiple of 3.

(a) Prove R is a partial order on A. (b) Draw the Hasse diagram for this poset.

7. Application to Voting Theory: Recall some ideas about weighted voting from before: a WVS consists of a set of players, each with some non-negative weight (number of votes), and a quota. Also – and this is very important here – we always list the players P1,...,Pn in decreasing order by weight. So P1 always has at least as many votes as P2, P2 has at least as many votes as P3, and so on. Subsets of players are called coalitions. A winning coalition is any coalition whose total weight meets or exceeds the quota. WVS are completely determined by their winning coalitions, because any two WVS with the same number of players and same winning coalitions are equivalent. So let’s focus on the coalitions.

We say coalition A dominates coalition B if, no matter how the player weights are assigned, the total weight of A is always at least as big as the total weight of B. For example, the coalition {P1,P2} dominates the coalition {P2,P3}, because P1 always has at least as many votes as P3 (remember: we list players in decreasing order by weight). So without even knowing what the weights are or what the quota is, we can say definitively that {P1,P2} is always a “stronger” coalition than {P2,P3}.

(a) Prove that domination is a partial order on the set of all possible coalitions. (b) Draw Hasse diagrams for this partial order, first for n = 2, then n = 3, and finally n = 4. Remember: if a set has n elements, it has 2n subsets, so your diagrams should have 4, 8, and 16 coalitions, respectively. (c) If you find this exercise fun, you are welcome to draw the Hasse diagram for n = 5 (I think that one is very pretty).

12: Functions

1. Let A be the set of all King’s College students. Determine whether each of the following relations is a function.

(a) The relation that pairs each student with his or her student ID number. (b) The relation that pairs each student with each course that student is currently taking. (c) The relation that pairs each student with any math courses that student is cur- rently taking. (d) The relation that pairs each student with his or her age. (e) The relation that pairs each student with the college dormitory in which he or she lives.

2. Let A = {1, 2, 3, 4}. Below are the directed graphs of six different relations on A.

(a) Determine which of these relations are functions. For those that aren’t functions, give at least one reason why not. (b) Redraw each graph in a bipartite fashion, with two copies of the vertex set, and edges going from the first copy (the domain) to the second copy (the codomain). (a) 1 2 (b) 1 2 (c) 1 2

4 3 4 3 4 3

(d) 1 2 (e) 1 2 (f) 1 2

4 3 4 3 4 3

3. Suppose A and B are nonempty sets. Can the Cartesian product A × B ever be a function from A to B? Explain.

4. Let A = {1, 2, 3, 4, 5, 6} and B = {a, b, c}. Consider the function f : A → B defined by f = {(1, b), (2, c), (3, a), (4, c), (5, b), (6, b)}.

(a) Draw the directed graph of this function. (b) What is the image of 2? (c) What is the image of 4? (d) What are the preimages of a? (e) What are the preimages of b?

5. Let f : Z → Z be the function defined by the rule f(x) = x2.

(a) What is the image of 4? (b) What is the image of 7? (c) What are the preimages of 4? (d) What are the preimages of 7?

6. Let A = {1, 2, 3, 4, 5}. Construct the adjacency matrices of the following functions f : A → A:

(a) f = {(1, 2), (2, 3), (3, 4), (4, 5), (5, 1)} (b) f = {(1, 1), (2, 3), (3, 2), (4, 5), (5, 4)} (c) f = {(1, 3), (2, 3), (3, 3), (4, 3), (5, 3)} 7. Use the results of the previous exercise to suggest an answer to the following question: What is special about the adjacency matrices of function on a set A, as opposed to mere relations on A?

8. Find the range of the following functions f : Z → Z:

(a) f(n) = n + 4 (b) f(n) = 3n + 2 (c) f(n) = |n − 7| (d) f(n) = n4

9. Almost anything in math is a function if you want to look at it that way. For example, the fundamental operations of arithmetic are functions. Take addition: when we add, we are inputting a pair of numbers and outputting a single number (their sum). That means addition is a function

add :(R × R) → R defined by the rule add(x, y) = x + y. Write down the functions corresponding to the following operations: subtraction, mul- tiplication, division, taking a square root, and taking a cube root. Be careful with the domains for division and taking a square root!

10. The floor function is the function b c : R → Z that rounds its input down to the nearest integer. For example, bπc = 3. Find real numbers x and y satisfying bxc+byc < bx + yc.

11. The ceiling function is the function d e : R → Z that rounds its input up to the nearest integer. For example, dπe = 4. Find real numbers x and y satisfying dxe+dye > dx+ye.

12. This is an important exercise. It shows that every function is hiding an equivalence relation inside it. Let A and B be sets, and let f : A → B be a function. For x, y ∈ A, define x ∼ y if and only if f(x) = f(y).

(a) Prove that ∼ is an equivalence relation on A. (b) Suppose A = B = {1, 2, 3, 4, 5, 6} and

f = {(1, 2), (2, 1), (3, 1), (4, 5), (5, 6), (6, 1)}.

Find all the equivalence classes. (c) Suppose A = B = R, and f(x) = sin x. What is the equivalence class containing x = 0?

13. Application to Geometry: A transformation of the plane is any function that moves points around; i.e. any function of the form f : R2 → R2. Try your best to describe the effects of the following transformations of the plane: (a) f(x, y) = (2x, y) (b) f(x, y) = (2x, 3y) (c) f(x, y) = (y, x) (d) f(x, y) = (x, 0)

Isometries are a special kind of plane transformation that preserve distances. That is, if f : R2 → R2 is an isometry that maps the points P and Q to the points P 0 and Q0, then the distance between P and Q equals the distance between P 0 and Q0. The most fundamental isometries are translations, rotations, and reflections.

Translation: All points shift the same distance in the same direction. Rotation: All points rotate through some angle about some fixed central point. Reflection: All points are reflected across some line (the axis of reflection).

(e) Find a formula f(x, y) = ··· for the translation that shifts all points five units to the right and three units down. (f) Find a formula f(x, y) = ··· for a 90◦ counterclockwise rotation centered at the point (0, 0). (g) Find a formula f(x, y) = ··· for a reflection across the x-axis. (h) Find a formula f(x, y) = ··· for a reflection about the y-axis.

13: Bijections

1. Let A = {1, 2, 3, 4, 5} and define a function f : A → A as

f = {(1, 3), (2, 1), (3, 4), (4, 1), (5, 5)}.

If f injective? Is it surjective?

2. Let A = {1, 2, 3, 4, 5} and define a function f : A → Z by the rule ( x2 + 1 if x is even, f(x) = 2x − 5 if x is odd.

List the ordered pairs of f. Is f injective?

3. Consider the function f(x) = |x|. Determine (with reasons) whether f is injective and or surjective in each of the following cases:

(a) viewing f as a function f : N → N, (b) viewing f as a function f : Z → Z, (c) viewing f as a function f : Z → N. 4. Let A = {1, 2, 3, 4, 5}, and define a function f : P(A) → P(A) by the rule f(S) = S ∩ {1, 2, 3, 4}. Is f injective? Is f surjective?

5. Prove that the function f : R → R defined by f(x) = 7x + 1 is a bijection.

6. Prove that the function g : Z → Z defined by g(n) = 7n + 1 is injective but not surjective.

7. Explain why the function f : R → R defined by f(x) = sin x is not injective. Then restrict the domain to as large a set as possible so as to make the function injective.

8. Recall that the addition and multiplication of real numbers are functions add, mult : (R × R) → R.

(a) Is add injective? Is it surjective? (b) Is mult injective? Is it surjective?

9. Is the floor function b c : R → Z injective? Is it surjective? Explain.

n n n 10. Consider the function f : N → Z defined by f(n) = (−1) b 2 c, where b 2 c means divide n by 2, then apply the floor function.

(a) Compute f(n) for n = 1, 2, 3 ... until you are convinced this function is a bijection. (b) Since bijections essentially pair off the elements from the domain with the elements in the codomain, the fact that there is a bijection from N to Z suggests that these two sets have the same “size”, even though Z contains N as a proper subset. Does this bother you? Provide arguments supporting your opinion.

11. Suppose A is a set containing m elements and B is a set containing n elements.

(a) If m > n, prove that no function f : A → B can be injective. (b) If m < n, prove that no function f : A → B can be surjective.

12. Informally, two graphs are isomorphic (meaning they have the “same shape”) if you can redraw one to look just like the other. Here is the formal definition: Let G1 = (V1,E1) and G2 = (V2,E2) be two graphs. An isomorphism is a bijection f : V1 → V2 with the additional property that {x, y} ∈ E1 if and only if {f(x), f(y)} ∈ E2 (in other words, an isomorphism maps vertices to vertices and also maps edges to edges). The graphs G1 and G2 are isomorphic if there exists an isomorphism from V1 to V2.

Two of the three graphs shown below are isomorphic; the third is not isomorphic to the other two. For the two that are isomorphic, prove it by exhibiting an isomorphism from one to the other. x

A B 1 2 w y

D C 4 3 z

13. Application to Geometry: Recall that an isometry of the plane is a transforma- tion f : R2 → R2 that preserves distances. The fundamental types of isometry are translations, rotations, and reflections.

(a) Explain why any isometry must necessarily be a bijection. (b) Give an example of a transformation f : R2 → R2 that is a bijection but not an isometry. If you have trouble finding an explicit formula, a verbal description is OK.

14: Inverse Functions

1. Let A = {1, 2, 3, 4, 5} and let f : A → A be the function

f = {(1, 2), (2, 3), (3, 4), (4, 5), (5, 1)}.

Find f −1.

2. Let A = {1, 2, 3}. There are exactly 27 different functions f : A → A. How many of them are invertible? List the pairs and draw the graph for each invertible function.

3. Of the invertible functions you found in the previous exercise, how many of them are equal to their own inverse?

4. Create the adjacency matrices for all the invertible functions you found in Exercise 2. Do you see anything special about the adjacency matrices of invertible functions, as opposed to the adjacency matrices of mere functions?

5. The function f : R → R defined by f(x) = 7x − 5 is a bijection and is therefore invertible. Find a formula for f −1.

6. Generalizing the previous exercise, the function f : R → R defined by f(x) = ax + b is invertible, provided a 6= 0. Find a formula for f −1.

7. Let R∗ = R − {0}. That is, R∗ is the set of all nonzero real numbers. Let f : R∗ → R∗ 1 be the function f(x) = x .

(a) Prove that f is invertible. (b) Find a formula for f −1. 8. Let G be the set of all graphs. Define a function comp : G → G by the rule comp(G) = G. In other words, this function inputs a graph and outputs its graph complement. Prove that this function is invertible, and moreover, it is its own inverse.

9. Application to Geometry: Last time we talked isometries, you (hopefully) explained why isometries are bijections. That means every isometry is invertible. Describe verbally the inverses of the following isometries:

(a) A translation that shifts all points 3 units to the right and 7 units up. (b)A 45◦ degree counterclockwise rotation centered at the origin. (c) A reflection about the x-axis. (d) A reflection across the line y = x.

10. Way back when we first learned about trees, we saw how computers can search for Hamilton cycles by forming the search tree of a graph, and then performing a depth- first search of the tree until a Hamilton cycle is found. For reference, here is the graph and search tree we used back then:

A

B C A C C D B D

B D D C D B

A A

Like almost everything in math, this process of creating a search tree from a given graph can be expressed in the language of functions. Specifically, let G be the set of all graphs, and let T be the set of all trees. When we create the search tree for a graph, we are really applying a function search : G → T . Input a graph, output its search tree. Here’s a fun question: Is this function invertible? That is, can we recreate a graph G from its search tree T ? Let’s try! Find a graph G with four vertices A, B, C, and D, whose search tree is A

B C D

C B D E C E

E B D E D E C

D B

A A

11. Keeping with the theme that almost everything in math can be expressed in the lan- guage of functions, let’s talk about that most important calculus concept: differentia- tion. You probably think of differentiation as something you do to functions, but guess what: differentiation is a function!

Specifically, let F denote the set of all real-valued functions of a real variable (functions that input a real number and output a real number; the ones you studied in Calc I and Calc II). Differentiation is a function D : F → F defined by D(f) = f 0. Every f ∈ F has a unique derivative f 0 ∈ F, so D satisfies the definition of function. Examples:

D(x2) = 2x, D(sin x) = cos x, D(ekx) = kekx.

The question is: is the function D : F → F invertible? Explain your reasoning clearly and completely.

15: Function Composition

1. Let A = {1, 2, 3, 4, 5} and B = {1, 2, 3, 8, 9}, and define functions f, g : A → B by

f = {(1, 8), (3, 9), (4, 3), (2, 1), (5, 2)} and g = {(1, 2), (3, 1), (2, 2), (4, 3), (5, 2)}.

Find f ◦ g or explain why it doesn’t exist. Repeat for g ◦ f, f ◦ f, and g ◦ g.

2. Let A = {1, 2, 3, 4}, and define functions f, g : A → A by

f = {(1, 3), (2, 2), (3, 4), (4, 1)} and g = {(1, 4), (2, 3), (3, 1), (4, 2)}.

Find the following compositions: (a) g−1 ◦ f ◦ g (b) f ◦ g−1 ◦ g (c) g ◦ f ◦ g−1 (d) g ◦ g−1 ◦ f (e) f −1 ◦ g−1 ◦ f ◦ g

3. Let f : R → Z be the floor function, and let g : R → Z be the ceiling function. Compute f ◦ g and g ◦ f.

4. Let f : R → R be the absolute value function. Compute f ◦ f. 5. We proved that if f : A → B and g : B → C are both injective, then their composition g ◦ f : A → C is also injective. The converse is false. Find an example of functions f, g such that g ◦ f is injective, but at least one of f or g is not injective.

6. Suppose f : A → B and g : B → C are surjective functions. Prove that g ◦ f is also surjective.

7. Find an example of functions f, g such that g ◦ f is surjective, but at least one of f or g is not surjective.

8. There is an important but boring function that exists on any set. Let A be a set, and define the function ι : A → A by the rule ι(x) = x for all x ∈ A. This is the identity function on A. It doesn’t do anything (input x, output x, no change!), but it’s important that it exists. For one thing, it is the function that results whenever you compose an invertible function f with its inverse:

f −1 ◦ f = f ◦ f −1 = ι.

(a) Let A = {1, 2, 3, 4}. List the ordered pairs, draw the directed graph, and create adjacency matrix for the identity function on A. (b) Let A = {1, 2, 3}, and let f, g : A → A be defined by

f = {(1, 2), (2, 3), (3, 1)}, and g = {(1, 3), (2, 2), (3, 1)}.

Compute g−1 ◦ f −1 ◦ f ◦ g. (c) Generalizing the previous part, explain why (f ◦ g)−1 = g−1 ◦ f −1.

9. Let A = R − {0, 1}; that is, A is the set of real numbers with 0 and 1 removed. Here are six functions on A: 1 1 1 x ι(x) = x, f(x) = 1 − , g(x) = , h(x) = , r(x) = , s(x) = 1 − x x 1 − x x x − 1 (a) Show that f ◦ g = ι and g ◦ r = s. Complete the table, thereby showing that the composition of any two of these functions is another one of them. ◦ ι f g h r s ι f ι g s h r s

(b) Which of the six given functions are invertible? Find the inverse of each invertible function.

10. Define a function f : Z → Z by the rule ( n − 2 if n ≥ 1000 f(n) = f(f(n + 4)) if n < 1000

(a) Find the values of f(1000), f(999), f(998), f(997), and f(996). (b) Can you guess a simpler formula for this function? (c) What is the range of this function?

11. When we compose a function with itself multiple times, it is customary to use expo- nents. For example, f ◦ f can be written as f 2 and f ◦ f ◦ f can be written as f 3, etc.

Let A = {1, 2, 3, 4, 5, 6}, and let f : A → A be defined by

f = {(1, 2), (2, 3), (3, 1), (4, 4), (5, 6), (6, 5)}.

Find f 2, f 3, and f 602.

12. Let A = {1, 2, 3, 4, 5} and let g : A → A be defined by

g = {(1, 2), (2, 3), (3, 4), (4, 5), (5, 5)}.

Find g3, g5, and g1000.

13. Grab a bunch of pennies and sort them into some stacks. For uniformity, lets agree to sort the stacks from biggest (on the left) to smallest (on the right). If, for example, you have stacks of size 5, 3, 3, and 1, I’ll represent that by the string 5331.

Now, take one penny from each stack, and make a new stack out of the pennies you took. So if you start with 5331, you end up with 4422 (the stack with a single penny disappears when you take one penny from each stack). Or if you start with 33322, you end up with 522211. Guess what? This is a function! Specifically, it is a function f : A → A, where A is the set of all possible “collections of stacks of pennies” (equivalently, A is the set of all numerical strings written in non-increasing order). (a) Prove that f is not injective by finding two different strings x and y with f(x) = f(y). (b) Prove that f is not surjective by finding a string x such that x 6= f(y) for any string y. (c) Find a string x satisfying f(x) = x. If you can’t (and depending on how many pennies you’re using, it might be impossible), find a string y satisfying f n(y) = y for some n ≥ 2.

Note: A former King’s student, who is now in graduate school pursuing a PhD, con- ducted research on this function several years ago. If you find this problem interesting, let me know; there are a lot of intriguing questions here I’ve yet to pursue.

14. Application to Geometry: OK, let’s talk about isometries again (this is the last time, I promise). This time we’ll talk about compositions of isometries.

Let Tx,y denote the translation that shifts the plane x units horizontally and y units vertically. Let Rθ denote a counterclockwise rotation about the origin with angle θ (with θ measured in degrees).

(a) Compute T1,2 ◦ T3,4.

(b) More generally, compute Ta,b ◦ Tc,d.

(c) Does Ta,b ◦ Tc,d = Tc,d ◦ Ta,b? Draw a picture supporting your answer.

(d) Compute R30 ◦ R20.

(e) More generally, compute Rα ◦ Rβ.

(f) Does Rα ◦ Rβ = Rβ ◦ Rα? Draw a picture supporting your answer.

16: Graphs and Counting

1. You should practice multiplying matrices until the technique becomes natural. Here are a few examples to practice with:

(a)  1 2   5 6   ??  × = 3 4 7 8 ?? (b)  1 −1   2 0   ??  × = −1 1 0 4 ?? (c)  2 −1 0   1 2 3   ???   −1 2 −1  ×  1 2 3  =  ???  0 −1 2 1 2 3 ??? 2. Reverse the order of the matrices in the previous exercise and multiply them again. For matrices, A × B does not usually equal B × A.

3. Consider the following graph:

2

1 4

3

(a) How many walks of length 3 are there from vertex 1 to vertex 2? Try to find them all by hand, then use matrix powers to check your answer. (b) How many walks of length 4 start and end at vertex 1? Again, try to find them all by hand, then use matrix powers to check your answer. (c) How many walks of length 8 are there from vertex 3 to vertex 1?

4. In a directed graph there tend to be fewer possible walks, because the streets (edges) are one-way. Here is a directed version of the graph from the previous exercise:

2

1 4

3

For k = 1, 2, 3,..., how many walks of length k are there from vertex 1 to vertex 4?

5. I want to show you a connection between matrix multiplication and function composi- tion. Let A = {1, 2, 3, 4} and let f, g : A → A be functions on A defined by

f = {(1, 2), (2, 3), (3, 1), (4, 4)} and g = {(1, 3), (2, 4), (3, 1), (4, 2)}.

(a) Find the compositions f ◦ g and g ◦ f.

(b) Draw the adjacency matrices for f and g. Call them Af and Ag.

(c) Compute the matrix products Af × Ag and Ag × Af .

(d) If you didn’t make any mistakes, you should find that Af × Ag is the adjacency matrix of g ◦ f and Ag × Af is the adjacency matrix of f ◦ g. Please confirm. In a nutshell: functions have adjacency matrices with only zeros and ones. Multiplying those matrices is the same as composing the functions. Imagine an algorithm for teaching a computer to perform function composition; all that fancy “input/output” stuff can be completely encoded in ones and zeros, addition and multiplication. Nice!

6. Recall that Km,n is the complete bipartite graph with m “red” vertices and n “blue” vertices, with every red vertex adjacent to every blue vertex.

(a) Prove that if m 6= n, then Km,n is not Hamiltonian.

(b) How many Hamilton cycles does K4,4 possess?

(c) How many Hamilton cycles does Kn,n possess?

7. If X is a finite set, |X| denotes the number of elements of X. Suppose A and B are sets with |A| = 4 and |B| = 7.

(a) How many functions are there from A to B? (b) How many injective functions are there from A to B? (c) Generalize the previous parts; suppose |A| = a and |B| = b. How many functions from A to B are there? How many of them are injective?

8. We learned that a permutation is a bijection from a set to itself. If a set A has n ele- ments, there are exactly n! permutations of A. In some of these permutations, elements of A will be their own images (graphically, these are the loops). A derangement is a permutation in which no element is its own image (or a permutation whose digraph has no loops). The number of derangements of a set with n elements is

 1 1 1 1  D = n! 1 − + − + ··· + (−1)n n 1! 2! 3! n! We’ll prove this result later, but for now let’s just play with it.

(a) Find all possible derangements of A = {1, 2, 3}, and confirm that the above formula gets it right. (b) Find all possible derangements of A = {1, 2, 3, 4}, and confirm that the formula gets it right again. (c) I hope you haven’t forgotten the Maclaurin series for ex that you learned in Calculus 2. If you did, then look it up, and plug in x = −1. Use this series n! Dn 1 to show that Dn ≈ e . This means n! ≈ e ≈ 0.368. In other words, if you randomly permute the elements of a set, there is a 36.8% chance you’ll produce a derangement. Neat!

9. Choosing which shirts to pack for a vacation is equivalent to choosing which shirts not n to pack. Which “preliminary fact about the numbers k ” is this statement referencing? n 10. Explain in clear and simple English why 0 should equal 1. n 11. Explain in clear and simple English why n should equal 1. 1000000 12. Grab a calculator and try to compute 2 using the formula on Slide 82. Explain why this formula is a terrible way to compute this number. What is a better way?

17: More Counting

Each of the first 10 problems can be interpreted as selection problems, where you are selecting k objects from a set of n objects. Determine n and k, whether the order of selection matters, and whether repetition is allowed. Then find the answer; no simplifying necessary.

1. How many 4-digit numbers can you make using only odd digits?

2. If A is a set with 30 elements, how many subsets of A have exactly 12 elements?

3. Suppose you have 120 books and you want to line them up on a shelf from left to right, but the shelf only has room for 75 books. In how many ways can you fill the shelf?

4. How many triples (x, y, z) of nonnegative integers satisfy x + y + z = 10?

5. 12 runners enter a race. The top 3 finishers earn gold, silver, and bronze medals, respectively. In how many ways can the medals be awarded?

6. How many pairs of dance partners can be selected from a group of 12 women and 20 men, assuming men may only dance with women and women may only dance with men?

7. You are packing for a vacation. Suppose you have 11 shirts, but only enough space to pack 7 of them. How many combinations of shirts can you pack?

8. How many ways can you distribute 8 identical pieces of candy among 5 children, assuming you may give each child as many or as few pieces as you like?

9. Draw a 5 × 5 grid, and imagine that it represents a city street map. In how many ways can you travel from the southwest corner to the northeast corner, assuming you can only move north and east?

10. Assume you have an unlimited supply of each of 4 varieties of donut, and you eat one for breakfast every day. How many different ways can you eat breakfast for one week (seven days)?

The next ten problems combine various counting techniques with one or more selection scenarios. This does not mean that they are harder problems, only that they can not be so neatly categorized as the first 10 problems. Solve them however you like.

11. If we define a “word” to be any arrangement of letters, how many words can be formed by rearranging the letters of the word MISSISSIPPI? 12. Draw an n×k grid, where n and k are natural numbers, and imagine that it represents a city street map. In how many ways can you travel from the southwest corner to the northeast corner, assuming you can only move north and east? Answer the same question if one of the city blocks is closed off (so there is a road you can not travel on).

13. If A is a set with 9 elements, how many subsets of A have an odd number of elements?

14. 10 girls and 8 boys want to play kickball. In how many ways can you form a team consisting of 5 girls and 5 boys?

15. In how many ways can 4 boys and 4 girls sit in a row, if all the girls must sit together, but the boys may not sit all together?

16. How many ways can you distribute 8 identical pieces of candy among 5 children, assuming you must give each child at least one piece?

17. In how many ways can you rearrange the letters a, b, c, d, e, f, g such that the string abc appears? For example, the arrangement abecdfg is not permitted, since the letters a, b, and c are not all adjacent.

18. How many 4-digit numbers contain at least one repeated digit?

19. Suppose you roll a die three times in succession. In how many ways can the sum of the rolls equal 10?

20. How many triples of integers (x, y, z) satisfy x + y + z = 10, subject to x ≥ 1, y ≥ 2, and z ≥ 3?

18: Even More Counting!

1. In how many ways can you rearrange the letters a, b, c, d, e, f, g such that the string abc does not appear? For example, the arrangement abecdfg is permitted, since the letters a, b, and c are not all adjacent.

2. If a coin is tossed 5 times, what is the probability that it lands heads at least once?

3. If a coin is tossed 5 times, what is the probability that it lands heads at least three times?

4. Among the 30 students registered for a discrete math course, 15 know Java, 12 know Python, and 5 know both of these languages.

(a) How many students know at least one of Java or Python? (b) How many students know only Java? (c) How many students know only Python? (d) How many students know neither Java nor Python? 5. How many integers between 1 and 500 are divisible by 3 or 5?

6. Suppose A and B are finite sets with |A ∪ B| < |A| + |B|. Prove that A and B have at least one element in common.

7. The rule we learned for computing the size of unions is called The Principle of Inclu- sion/Exclusion, because you “include” the sets, “exclude” the intersections, “include” the triple intersections, etc. We can use this principle to justify the formula for de- rangements given in Section 16. Recall Dn denotes the number of derangements of a set of size n. We’ll derive the formula for D4, and then generalize it.

(a) Let A = {1, 2, 3, 4}. Let A1 denote the permutations of A where 1 is fixed. Let A2 denote the permutations of A where 2 is fixed. A3 and A4 are defined similarly. Justify the following formula:

D4 = 4! − |A1 ∪ A2 ∪ A3 ∪ A4|.

(b) Now use the principle of inclusion/exclusion to express the union of the Ais in terms of intersections.

(c) Confirm that |Ai| = 3! for each i = 1, 2, 3, 4. Also confirm that |Ai ∩ Aj| = 2 for 4 each of the 2 possible intersections. Finally, confirm that |Ai ∩ Aj ∩ Ak| = 1 for 4 each of the 3 triple intersections. (d) Use the numbers from the previous part and the formula for the first part to derive the result  1 1 1 1  D = 4! 1 − + − + . 4 1! 2! 3! 4!

(e) Try to generalize the preceding steps as a proof of the general formula for Dn.

8. Thirty buses are to be used to transport 2000 King’s students from Wilkes-Barre to South Bend, Indiana. Each bus has 80 seats. Assume one passenger per seat.

(a) Prove that one of the buses will carry at least 67 passengers. (b) Prove that one of the buses will have at least 14 empty seats.

9. If there are 44 chairs positioned around 5 tables in a room, show that one table must have at least 9 chairs around it.

10. What is the smallest number of people you can pack into a room to be certain that two of the people have the same first and last initials?

11. Use the Pigeonhole Principle to prove that in any graph G there must be two vertices with equal degree. 19: The Binomial Theorem

1. Use the Binomial Theorem to expand (a + 4b)5. Simplify your answer.

 1 8 2. Expand and simplify 2x3 − using the Binomial Theorem. x2 3. Find the coefficient of the term containing y8 in the binomial expansion of (x + 3y2)17.

 3 58 4. Find the coefficient of x25 in the binomial expansion of 2x − . x2 5. Prove the identity n n − 1 n − 1 = + . k k − 1 k This identity, by the way, is the easy way to compute the “next” row of Pascal’s triangle; add the entries diagonally above to get the new entries.

6 X k 7 6. Show that = and interpret this result with reference to Pascal’s triangle. 2 3 k=2 7. The previous exercise is an example of a more general identity:

n X k n + 1 = r r + 1 k=r for any r and n with 1 ≤ r ≤ n. This is commonly called the Hockey Stick Identity. Can you guess why? Experiment with specific small values of r and n, and interpret with reference to Pascal’s triangle. n n − 1 8. Prove the identity k = n . k k − 1 9. Use the Binomial Theorem and the limit definition of the derivative df f(x + h) − f(x) = lim dx h→0 h d to prove the Power Rule: xn = nxn−1 (assume n ∈ ). dx N 10. Pascal’s triangle is full of beautiful connections. We’ve already seen that the sum of the entries in the nth row equals 2n. That seems curious until you remember that binomial coefficients count the numbers of subsets of various sizes. This next one is straight-up crazy. Consider the powers of 11:

110 = 1 Row 0 of Pascal’s triangle . . . meh 111 = 11 Row 1 of Pascal’s triangle . . . huh? 112 = 121 Row 2 of Pascal’s triangle . . . huh! 113 = 1331 Row 3 of Pascal’s triangle . . . wft? 114 = 14641 Row 4 of Pascal’s triangle . . . omg!

This very strange pattern appears to break down in row 5, because 115 = 161051, while the entries in row 5 form the string 1 − 5 − 10 − 10 − 5 − 1. However, there is a way to make this fit the pattern. Can you find it? Don’t Google; that would spoil the fun! If you think you found the secret, test it on the next few rows. Then, state your general result as clearly as possible.

11. Create the first fifteen rows of Pascal’s triangle (which is really 16 rows, because we start with row zero). Then, grab two different-colored markers (I’ll say red and blue). Color each even number blue, and color each odd number red. You should see an interesting pattern.

Now, go online and search for "chaos game numberphile". It should be the top hit. Just in case, the exact address is https://www.youtube.com/watch?v=kbKtFN71Lfs. Watch the video. It’s cool. Tell me what you think!

20: Induction

1. Prove by induction that for all n ∈ N,

n X n2(n + 1)2 k3 = . 4 k=1

2. Use the result of the previous problem and another result from class to prove the very awesome identity (1 + 2 + ··· + n)2 = 13 + 23 + ··· + n3, which is valid for any n ∈ N.

3. Prove by induction that for all n ∈ N, n3 + (n + 1)3 + (n + 2)3 is divisible by 9.

d n n−1 4. Use induction to prove the Power Rule dx x = nx for all n ∈ N. 5. Compute the first, second, third, etc. derivatives of the function f(x) = xex. If you simplify after each step, you should see a pattern forming which allows you to state the general formula for the nth derivative of f. State this formula, and prove it works by induction. 6. Repeat the previous problem for the function f(x) = x2ex. This time you have to take extra care in simplifying after each step, otherwise the pattern may not appear to you.

7. We’ve already used a combinatorial argument to establish that if A is a set with n elements, then |P(A)| = 2n. Try to prove this fact inductively. In the induction step, let A = {1, 2, 3, . . . , n, n + 1}. How can the subsets of A be “built” from the subsets of {1, 2, 3, . . . , n}?

8. Use induction to prove the Hockey Stick identity

n X k n + 1 = r r + 1 k=r This holds for any 1 ≤ r ≤ n. Induct on n; the base case is n = r.

9.A convex n-gon is a polygon with n vertices and such that the interior angles at each vertex are less than 180◦. Prove by induction that the interior angles of any convex n-gon always sum to (n − 2) · 180◦.

10. Prove by induction that 2n > n2 for all n ≥ 5.

11. Use induction to prove the Binomial Theorem. A comment: If you get stuck on this and Google a solution, you’ll probably see many proofs using sigma notation in ways that seem strange or unclear. Don’t do that; this proof is much easier if you avoid sigma notation whenever possible.

21: Induction and Graph Theory

1. Suppose G is a connected graph. Prove that if every vertex has degree at least 2, then G contains at least one cycle. Note: This problem does not require induction, but the result is useful for the next two problems.

2. Use the previous result to prove that any tree has at least one vertex of degree 1. Bonus: can you prove that every tree has at least two vertices of degree 1?

3. Suppose G is a connected graph in which every vertex has even degree. Prove G has an Euler circuit.

4. Let G be a graph with 2k vertices and no triangles. Prove by induction on k that G has 2 at most k edges. Hint: In the induction step, let v1 and v2 be adjacent vertices. Since G contains no triangles, there are no vertices adjacent to both v1 and v2. Remove v1 and v2 (and any incident edges), use the induction hypothesis, then reinsert v1 and v2 (and any incident edges). How many extra edges appear when v1 and v2 are reinserted? 5. Give an example of a graph with 2k vertices, k2 edges, and no triangles. This exercise shows that the inequality from the previous problem is sharp, meaning there are examples meeting the bound. 6. Recall Brooks’ Theorem, which says that every graph G has χ(G) ≤ ∆G + 1, where χ(G) denotes the chromatic number of G and ∆G denotes the largest degree of all the vertices of G. Prove this fact by induction on the number of vertices in G. Do not attempt to prove the more difficult part of Brooks’ Theorem, which says that the only graphs satisfying χ(G) = ∆G are complete graphs and odd cycles.

7. Start with a rectangle, and chop it up by drawing straight lines from one point on the boundary to another. If you draw a lot of lines, the rectangle ends up divided into a lot of smaller polygons. For example:

Now pretend that the rectangle is a country, and the little polygons are the states. Prove by induction that maps of this type are always properly 2-colorable, meaning the states can be colored using only two colors so that states with some length of common border are colored differently.

8. In class we proved that every planar graph G has χ(G) ≤ 6. We can actually do better, though the proof is more difficult. Let’s prove that every planar graph has χ(G) ≤ 5.

This fact is obvious if G has 5 or fewer vertices. Suppose it’s true for all planar graphs with n vertices, and consider a planar graph G with n + 1 vertices. We know that G has a vertex v of degree at most five. Deleting v leaves a graph with n vertices; by hypothesis, this graph can be colored with at most five colors. Our task is to re-insert v and properly color it with one of the five available colors, which completes the proof.

(a) First suppose v has degree ≤ 4. In this case, the proof is easy. Why? (b) So suppose v has degree 5. Here are v and the five vertices adjacent to v:

A

B E v

C D Explain why, under the given hypotheses, the vertices A, B, C, D, and E can’t all be pairwise adjacent to one another. (c) Therefore, there must be two vertices adjacent to v (without loss of generality, say A and B) that are not adjacent to each other. From here, explain how to color G using at most five colors. (d) Combine the previous parts and write a complete, coherent proof of the result.

22: Recursion

1. Find a closed-form solution for the sequence defined recursively by f(1) = 1 and f(n) = 3f(n − 1) for n ≥ 2. Prove your solution works by induction.

2. Find a closed-form solution for the sequence defined recursively by f(1) = 1 and f(n) = 2f(n − 1) + 1 for n ≥ 2. Prove your solution works by induction.

3. Consider the sequence defined by f(1) = 1, f(2) = 0, and for n ≥ 3,

f(n) = 4f(n − 1) − 4f(n − 2).

n n  Prove that f(n) = 2 1 − 2 for all n ∈ N. 4. Find a closed-form solution for the sequence defined recursively by f(1) = 0, f(2) = 1, and for n ≥ 3, f(n) = 4f(n − 2). Note: you’ll want to use a piecewise formula.

5. Consider the sequence defined recursively by f(1) = 0, and f(n) = n3 + f(n − 1) for n ≥ 2. Prove by induction that the closed form of this sequence is (n − 1)(n + 2)(n2 + n + 2) f(n) = for n ≥ 1. 4

6. An arithmetic sequence is any sequence f(n) where the difference between any two successive terms is always the same; i.e. f(n) − f(n − 1) = d for some constant d. We call the constant d the common difference of the sequence. For example, 4, 7, 10, 13, 17,... is an arithmetic sequence with common difference d = 3.

(a) For an arithmetic sequence whose first term is a and whose common difference is d, prove that the nth term is a + (n − 1)d. n (b) Prove the sum of the first n terms of an arithmetic sequence is 2 [2a + (n − 1)d]. (c) An arithmetic sequence begins 5, 9, 13, 17,.... What is the 100th term of this sequence? Also, what is the sum of the first 100 terms?

7.A geometric sequence is any sequence f(n) where the ratio between any two suc- cessive terms is always the same; i.e. f(n)/f(n − 1) = r for some constant r. We call the constant r the common ratio of the sequence. For example, 1, 3, 9, 27, 81,... is a geometric sequence with common ratio r = 3. More generally, all geometric sequences have the shape a, ar, ar2, ar3,..., with the nth term being arn−1. Assuming r 6= 1 (which is reasonable, because a geometric sequence with r = 1 is just a constant sequence), prove that the sum of the first n terms of a geometric sequence is a(1 − rn) . 1 − r √ 1 + 5 8. The number Φ = is very curious. Among its many properties is the fact that the 2 geometric sequence 1, Φ, Φ2, Φ3,... satisfies the recurrence f(n) = f(n − 1) + f(n − 2). That means every term in the sequence is the sum of the two preceding terms. Establish this fact.

9. Consider the sequence whose recursive rule is ( f(n − 1)/2 if f(n − 1) is even, f(n) = 3f(n − 1) + 1 if f(n − 1) is odd.

The behavior of this sequence depends upon its initial value f(1).

(a) Investigate the sequence with f(1) = 1. Summarize briefly how the sequence behaves. (b) Now use the initial value f(1) = 5. Again, summarize the sequence’s behavior. (c) Now use the initial value f(1) = 9. Summarize the sequence’s behavior. (d) Based upon the previous parts, would you care to offer any conjectures about this sequence? Test your conjecture with the initial value f(1) = 27. Have patience (and a calculator) for this one!

10. Let f0(x) = x/(x + 1). For n ∈ N, define fn(x) = f0 ◦ fn−1. In other words, we are defining a sequence of functions by repeatedly composing f0 with itself. Compute f1, f2, etc., until you spot a pattern (be sure to clean up after each step!). Then, state the general formula for fn, and prove it works by induction.

11. Repeat the previous problem for f0(x) = 1/(2 − x).

23: Divisibility

1. Suppose a, b ∈ N with a | b and b | a. What can you conclude about a and b?

2. We proved that the divides relation is a partial order on N. But if we expand our attention to Z, then “divides” is not a partial order. Why not? Specifically, which property or properties of partial orders (reflexivity, antisymmetry, transitivity) fail when we put the divides relation on the set Z? 3. Let A = {1, 2, 4, 8, 16, 32, 64, 128, 256}. Draw the Hasse diagram for A, ordered by |. 4. Many students have trouble remembering how 0 fits in with the divides relation. One of the following statements is true, and the other is false. Which is which? Please justify your choices.

(a) 0 | n for all n ∈ Z. (b) n | 0 for all n ∈ Z.

5. Find the unique quotient q and remainder r when a is divided by b:

(a) a = 500, b = 17 (b) a = 17, b = 500 (c) a = 5286, b = 19 (d) a = 19, b = 5286 (e) a = 98764, b = 4789

6. Using the Division Algorithm is a little more tricky when negative numbers are in- volved. Remember that the remainder must satisfy 0 ≤ r < |b|; the absolute value around b is important! Find the unique quotient q and remainder r when a is divided by b:

(a) a = −500, b = 17 (b) a = 500, b = −17 (c) a = −500, b = −17 (d) a = 5286, b = −19 (e) a = −19, b = 5286

7. Fix a natural number b ≥ 2, and define a function f : Z → Z by mapping each a ∈ Z to the quotient when a is divided by b. That is, f(a) = q, where a = qb + r with 0 ≤ r < b.

(a) Is f injective? (b) Is f surjective?

Explain your answers.

8. Fix a natural number b ≥ 2, and define a function f : Z → Z by mapping each a ∈ Z to the remainder when a is divided by b. That is, f(a) = r, where a = qb + r with 0 ≤ r < b.

(a) Is f injective? (b) Is f surjective?

Explain your answers. 9. Find the base 2, base 3, and base 8 representations of the following numbers:

(a) 100 (b) 1024 (c) 4034

10. Let n ∈ Z. Prove that n2 − 2 is never divisible by 4. 11. Suppose a and b are integers that leave the same remainder when divided by some natural number n. Prove that n | (a − b).

12. Suppose a and b are integers with a > 1. Also suppose a | (11b + 3) and a | (55b + 52). Find a.

13. True or false? In each case, provide a proof or a counterexample.

(a) If a | b and c | b, then ac | b. (b) If a | b and a | c, then a | ac. (c) If a | b and c | d, then ac | bd.

14. Write down any six natural numbers. Verify that there is a string of consecutive numbers in your list (possibly a string of just one number) whose sum is divisible by 6. Prove that this must always be the case.

24: The Primes

1. Determine whether the following numbers are prime or composite:

(a) 157 (b) 9831 (c) 9833

2. Find the prime factorization of the following numbers:

(a) 856 (b) 2323 (c) (28 − 1)20

3. Prove that, for all n ≥ 1, the number 14n never terminates in a 0.

4. Let A = N − {1} (i.e. A is the set of all natural numbers except 1). Define a function f : A → N by mapping each n ∈ N to its largest prime factor.

(a) Find the range of f. (b) Is f injective? (c) Is f surjective? (d) Why didn’t we define f as a function f : N → N? Explain.

5. Prove that the sum of two odd primes is never prime. Also, demonstrate that if you remove the word “odd” from the previous sentence, it is no longer true.

6. Let a and b be integers, and let p be a prime. Answer true or false and explain:

(a) If p | a11, then p | a. (b) If p | a and p | (a2 + b2), then p | b. (c) If p | (a9 + a17), then p | a.

7. One of the great achievements of 19th century mathematics was the proof of the Prime Number Theorem, which approximates how many prime numbers there are up to any particular value. Let π : N → N denote the prime counting function, where π(n) equals the number of primes ≤ n (here, π is the name of the function, not the familiar constant). For example, π(5) = 3, because there are three primes ≤ 5, and π(20) = 8, because there are 8 primes less than or equal to 20.

The Prime Number Theorem states that

π(n) lim = 1, n→∞ n/ ln n

meaning that as n increases, the prime counting function π(n) grows roughly as fast as the more-easily-computed function n/ ln n.

(a) Use the Prime Number Theorem to estimate the number of primes less than one thousand, less than one million, and less than one trillion. (b) Check online for the actual values of π(n) for n = one thousand, one million, and π(n) one trillion. Compute the ratios n/ ln n , and confirm that they are indeed getting closer to 1.

8. The main thing about prime numbers that has long fascinated humans is the way they defy predictability. One consequence of the Prime Number Theorem is that they “thin out” as n increases (graph the function f(x) = x/ ln x if you don’t see why). But there are infinitely many primes, so they never completely stop appearing as we travel along the number line.

But here is one neat trick: for any n ∈ N, it is easy to find a string of n consecutive composite integers. For example, consider n = 5. Look at the five numbers starting with 6! + 2. Note 6! + 2 can’t be prime, because it’s divisible by 2. The next number is 6! + 3, which isn’t prime because it’s divisible by 3. Similar arguments hold for the next three consecutive integers. Generalize the argument in the preceding paragraph to prove that for any n ∈ N, there exists a string of n consecutive composite integers.

9.A Mersenne prime is any prime number of the form 2p − 1, where p is itself a prime number. For example, 7 is a Mersenne prime, because 7 = 23 − 1, as is 31 = 25 − 1. These numbers are named after Father Marin Mersenne (1588 – 1648), who was very interested in numbers of the form 2n − 1.

(a) Use high-school algebra to show that 215 − 1 is not prime. (b) Show that if 2n − 1 is prime, then n itself must be prime. (c) Show by example that if p is prime, then 2p − 1 may be composite. You may Google this one. (d) Are there infinitely many Mersenne primes? Nobody knows! This is a famous open question. As of this writing, the largest known prime number is a Mersenne prime. What is it? Again, Google is OK.

10. Without explicitly listing all the factors, how many distinct factors do the following numbers have:

(a) 60 (b) 300 (c) 10100

11. Imagine a hallway with 100 light switches each connected to an overhead lamp. Ini- tially, all the lamps are off. Then, 100 people walk down the hall. The first person flips every switch. The second person flips every second switch (the second, the fourth, etc.). The third person flips every third switch (the third, the sixth, etc.). This con- tinues until all 100 people have walked down the hall. At the end of all this weirdness, which lights are on?

12. The sieve of Eratosthenes is an ancient algorithm for finding prime numbers. Start by listing all the numbers from 2 up to 100 (a 10 × 10 grid works nicely). Circle 2, then cross out every second number after 2 (so cross out 4, 6, etc.). Then circle 3 and cross out every third number after 3. Some of these numbers will already be crossed out; that’s fine. Next circle 5 and cross out every fifth number after 5. And finally, circle 7 and cross out every seventh number after 7. At this point, any number that hasn’t been crossed out is prime, so we’ve found all the primes less than 100.

(a) Why does this work? In particular, after crossing out the multiples of 2, 3, 5, and 7, how do you know all the remaining numbers are prime? (b) If we wanted to find all primes up to, say, 200, would it suffice to cross out only the multiples of 2, 3, 5, and 7? Explain. 13. Application to Programming: Prime numbers appear in a lot of fun recreational programming problems. Here’s a relatively-simple one: Find the sum of all prime numbers less than 10000. One standard approach is to implement a sieve (as in the previous problem) to find all the prime numbers less than 10000, then sum them. If you are confident in your programming skills, try this one out!

25: The Euclidean Algorithm

1. Find gcd(1800, 756).

2. Find integers x and y satisfying 154x + 260y = 2.

3. Find integers x and y satisfying 7x + 5y = 17.

4. Suppose a is a nonzero integer.

(a) What’s gcd(a, a)? (b) What’s gcd(a, 0)? (c) What’s gcd(0, 0)?

5. If a and b are relatively prime integers, prove that gcd(a + b, a − b) = 1 or 2.

6. Suppose a, b, and c are integers such that a | bc. Prove that if a and b are relatively prime, then a | c.

7. Suppose a, b, and c are nonzero integers with a and b relatively prime. Prove that gcd(a, bc) = gcd(a, c).

8. Let a, b ∈ N with a > b. Prove that gcd(a, a + b) = gcd(a, b).

9. Use the result of the previous problem to prove that for any n ∈ N, there exists a pair of integers (a, b) for which the Euclidean algorithm takes exactly n steps to find gcd(a, b).

10. Prove that if a | c and b | c and a and b are relatively prime, then ab | c.

11. Suppose that p is a prime and a, b ∈ N with gcd(a, p2) = p and gcd(b, p3) = p2, find

(a) gcd(ab, p4) (b) gcd(a + b, p4)

12. Let a, b ∈ N. The least common multiple of a and b, denoted lcm(a, b), is the unique positive integer satisfying

• lcm(a, b) is a multiple of both a and b, and • if c is any other number that is a multiple of both a and b, then lcm(a, b) < c. Since the definitions of gcd(a, b) and lcm(a, b) are so similar, you might expect an algorithm for computing lcm(a, b) analogous to the Euclidean algorithm. Turns out, you don’t need anything extra other than the following fact:

gcd(a, b) · lcm(a, b) = ab,

which holds for all nonzero integers a, b.

(a) Use the above formula and the Euclidean algorithm to compute lcm(63, 273) and lcm(56, 200). (b) Prove that gcd(a, b) | lcm(a, b) for all nonzero integers a and b. (c) Try to prove gcd(a, b) · lcm(a, b) = ab. Probably the quickest way is to deter- mine how the prime factorizations of gcd(a, b) and lcm(a, b) relate to the prime factorizations of a and b.

13. Let A = {1, 2, 3, 4, 5, 6, 7}, and consider the permutation f : A → A defined by

{(1, 2), (2, 3), (3, 1), (4, 5), (5, 6), (6, 7), (7, 4)}.

If you draw the digraph of f, you’ll quickly see that there are two disjoint cycles, one of length 3 and the other of length 4.

(a) Recall that f n means f composed with itself n times. Explain why f 12 = ι (the identity function), and why f n 6= ι for any n < 12. (b) Explain why f 15 = f 3. (c) What is the inverse of f 8?

26: Modular Arithmetic

1. Find a (mod n) in each of the following cases:

(a) a = 1286, n = 39 (b) a = 43197, n = 333 (c) a = 125, n = 400

2. Carry out the indicated calculations, giving the answer mod n.

(a) 17123 + 12948, n = 6 (b) 17123 · 12948, n = 6 (c) (17123)50, n = 6 (d) 104, 108, 1012, 1020, 1024, n = 7 (e) 4, 42, 43, 44, 45, 46, 47, 48, 49, 410, n = 11 3. Fix n ≥ 2, and consider the function f : Z → Z defined by f(x) = x2 (mod n). For example, with n = 4, we’d have f(3) = 1, because 32 = 9 and 9 (mod 4) = 1. Our goal is to find the range of f, for several choices of n.

(a) Even though the domain is Z, we can find the range simply by computing the outputs for x = 0, 1, . . . , n − 1. Why are these n inputs sufficient to completely determine the range? (b) Find the range when n = 11. (c) Find the range when n = 12. (d) Find the range when n = 13. (e) You may have noticed similar patterns for n = 11 and n = 13, but when n = 12, something slightly different occurs. Why do you think that is? If you think you see why, state a conjecture and test it for other values of n, then report what you’ve discovered.

4. In class we proved that a ≡ b (mod n) if and only if n | (a − b). Use this result to prove the remaining theorems from that same slide. Specifically, suppose a, b, c, and n are integers with n ≥ 2. Prove the following:

(a) If a ≡ b (mod n), then a ± c ≡ b ± c (mod n). (b) If a ≡ b (mod n), then ac ≡ bc (mod n). (c) If a ≡ b (mod n), then ac ≡ bc (mod n), provided c > 0.

It is important to spend some time proving these theorems, because they justify all the slick tricks of modular arithmetic. The first result (a ≡ b (mod n) if and only if n | (a − b)) is the key; use it to prove all the others.

5. If a ≡ b (mod n), show that gcd(a, n) = gcd(b, n).

6. Prove that a number is divisible by 11 only if the alternating sum of the number’s digits is divisible by 11.

7. One of the exercises in Chapter 2 of the Math 127 textbook is to prove the following: If n is even, then n2 − 6n + 5 is odd. Back then, the approach was to let n = 2k, where k ∈ Z, and prove that n2 − 6n + 5 = 2j + 1 for some j ∈ Z. Modular arithmetic streamlines this argument. Restate the theorem in the language of modular arithmetic, and prove it (it should be a one-line proof).

8. Suppose a, b ∈ Z and 3 | (a2 + b2). Show that 3 | a and 3 | b. √ 9. In Math 127 you (hopefully) saw a proof that 2 is irrational. Modular arithmetic once again provides a√ much quicker proof. The quicker proof starts the same way: to a the contrary, suppose 2 = b , where a, b ∈ N and a, b have no common factors. Now use the result of the previous problem to finish the proof. 10. Prove that every prime p ≥ 3 is congruent to 1 or 5 modulo 6.

11. Prove that p2 − 1 is divisible by 24 for all primes p ≥ 5.

12. Application to Information Science: Every book published since roughly 1970 has a unique identification number, called an International Standard Book Number, abbreviated ISBN. Originally, these numbers consisted of ten digits, but in 2007 they expanded ISBNs to 13 digits. We’ll only discuss ISBN-10.

A major consideration for identification numbers is that people (and machines) can make mistakes. What if a bookstore orders one thousand copies of a book, but the person placing the order types in the wrong ISBN? Does the bookstore end up receiv- ing 1000 calculus books instead of 1000 Harry Potter books? That would be tragic! The smart people who designed the ISBN system built in a safeguard against such calamities: one of the ten digits in a book number is a check digit that ensures the number is a legitimate ISBN. And further, the system is able to detect some common mistakes, such as mistyping a single digit or transposing (switching the order of) two adjacent digits.

Here’s how it works. Denote the ten digits by the vector a = (a1, a2, . . . , a10). The first nine digits are in the range 0 − 9. The tenth digit (the check digit) is chosen from the range 0 − 10 so that

a1 + 2a2 + 3a3 + ··· + 9a9 + 10a10 ≡ 0 (mod 11).

If the calculation forces a10 to equal 10, it is recorded as an X.

(a) If the first nine digits of an ISBN-10 are 093603103, what will the check digit be? (b) If a single digit of an ISBN-10 is copied incorrectly, a computer can easily detect that a mistake has been made. For example, a popular discrete math textbook’s ISBN-10 is 0130920002. Explain why, if any single digit of this ISBN is changed, an error will be detected. (c) Show by examples that if two digits are changed in an ISBN-10, the errors may or may not be detected. You can use the ISBN from the previous part. (d) Another common mistake when a number is copied is a transposition error, mean- ing two consecutive digits are accidentally switched (for example, typing 1426 instead of 1246). Show that the ISBN-10 system can detect transposition errors. Hint: Let a = a1 + 2a2 + ··· + kak + (k + 1)ak+1 + ··· + 10a10 be a correct ISBN. Let b be the same number with the digits ak and ak+1 transposed. Consider a − b.