You are on page 1of 10

CONTENTS x

12.2.3 Independence of random variables . . . . . . . . . . . 236


12.2.3.1 Examples . . . . . . . . . . . . . . . . . . . . 237
12.2.3.2 Independence of many random variables . . . 237
12.2.4 The expectation of a random variable . . . . . . . . . 238
12.2.4.1 Variables without expectations . . . . . . . . 239
12.2.4.2 Expectation of a sum . . . . . . . . . . . . . 239
Example . . . . . . . . . . . . . . . . . . . . . . 240
12.2.4.3 Expectation of a product . . . . . . . . . . . 240
12.2.4.4 Conditional expectation . . . . . . . . . . . . 241
Examples . . . . . . . . . . . . . . . . . . . . . 242
12.2.4.5 Conditioning on a random variable . . . . . . 244
12.2.5 Markov’s inequality . . . . . . . . . . . . . . . . . . . 245
12.2.5.1 Example . . . . . . . . . . . . . . . . . . . . 246
12.2.5.2 Conditional Markov’s inequality . . . . . . . 246
12.2.6 The variance of a random variable . . . . . . . . . . . 246
12.2.6.1 Multiplication by constants . . . . . . . . . . 247
12.2.6.2 The variance of a sum . . . . . . . . . . . . . 248
12.2.6.3 Chebyshev’s inequality . . . . . . . . . . . . 249
Application: showing that a random variable is
close to its expectation . . . . . . . 249
Application: lower bounds on random variables 250
12.2.7 Probability generating functions . . . . . . . . . . . . 250
12.2.7.1 Sums . . . . . . . . . . . . . . . . . . . . . . 251
12.2.7.2 Expectation and variance . . . . . . . . . . . 251
12.2.8 Summary: effects of operations on expectation and
variance of random variables . . . . . . . . . . . . . . 252
12.2.9 The general case . . . . . . . . . . . . . . . . . . . . . 253
12.2.9.1 Densities . . . . . . . . . . . . . . . . . . . . 254
12.2.9.2 Independence . . . . . . . . . . . . . . . . . . 255
12.2.9.3 Expectation . . . . . . . . . . . . . . . . . . 255

13 Linear algebra 257


13.1 Vectors and vector spaces . . . . . . . . . . . . . . . . . . . . 257
13.1.1 Relative positions and vector addition . . . . . . . . . 258
13.1.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . 259
13.2 Abstract vector spaces . . . . . . . . . . . . . . . . . . . . . . 260
13.3 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
13.3.1 Interpretation . . . . . . . . . . . . . . . . . . . . . . . 262
13.3.2 Operations on matrices . . . . . . . . . . . . . . . . . 263
13.3.2.1 Transpose of a matrix . . . . . . . . . . . . . 263
CONTENTS xi

13.3.2.2 Sum of two matrices . . . . . . . . . . . . . . 263


13.3.2.3 Product of two matrices . . . . . . . . . . . . 264
13.3.2.4 The inverse of a matrix . . . . . . . . . . . . 265
Example . . . . . . . . . . . . . . . . . . . . . . 266
13.3.2.5 Scalar multiplication . . . . . . . . . . . . . . 267
13.3.3 Matrix identities . . . . . . . . . . . . . . . . . . . . . 267
13.4 Vectors as matrices . . . . . . . . . . . . . . . . . . . . . . . . 269
13.4.1 Length . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
13.4.2 Dot products and orthogonality . . . . . . . . . . . . . 271
13.5 Linear combinations and subspaces . . . . . . . . . . . . . . . 272
13.5.1 Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
13.6 Linear transformations . . . . . . . . . . . . . . . . . . . . . . 274
13.6.1 Composition . . . . . . . . . . . . . . . . . . . . . . . 275
13.6.2 Role of rows and columns of M in the product M x . . 275
13.6.3 Geometric interpretation . . . . . . . . . . . . . . . . . 276
13.6.4 Rank and inverses . . . . . . . . . . . . . . . . . . . . 278
13.6.5 Projections . . . . . . . . . . . . . . . . . . . . . . . . 279
13.7 Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . 281

14 Finite fields 283


14.1 A magic trick . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
14.2 Fields and rings . . . . . . . . . . . . . . . . . . . . . . . . . . 284
14.3 Polynomials over a field . . . . . . . . . . . . . . . . . . . . . 286
14.4 Algebraic field extensions . . . . . . . . . . . . . . . . . . . . 287
14.5 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
14.5.1 Linear-feedback shift registers . . . . . . . . . . . . . . 289
14.5.2 Checksums . . . . . . . . . . . . . . . . . . . . . . . . 290
14.5.3 Cryptography . . . . . . . . . . . . . . . . . . . . . . . 291

A Sample assignments from Fall 2017 292


A.1 Assignment 1: Due Wednesday, 2017-09-13, at 5:00 pm . . . . 292
A.1.1 A curious proposition . . . . . . . . . . . . . . . . . . 293
A.1.2 Relations . . . . . . . . . . . . . . . . . . . . . . . . . 294
A.1.3 A theory of shirts . . . . . . . . . . . . . . . . . . . . . 295
A.2 Assignment 2: Due Wednesday, 2017-09-20, at 5:00 pm . . . . 297
A.2.1 Arithmetic, or is it? . . . . . . . . . . . . . . . . . . . 297
A.2.2 Some distributive laws . . . . . . . . . . . . . . . . . . 298
A.2.3 Elements and subsets . . . . . . . . . . . . . . . . . . 299
A.3 Assignment 3: Due Wednesday, 2017-09-27, at 5:00 pm . . . . 300
A.3.1 A powerful problem . . . . . . . . . . . . . . . . . . . 300
CONTENTS xii

A.3.2 A correspondence . . . . . . . . . . . . . . . . . . . . . 300


A.3.3 Inverses . . . . . . . . . . . . . . . . . . . . . . . . . . 301
A.4 Assignment 4: Due Wednesday, 2017-10-04, at 5:00 pm . . . . 301
A.4.1 Covering a set with itself . . . . . . . . . . . . . . . . 301
A.4.2 More inverses . . . . . . . . . . . . . . . . . . . . . . . 301
A.4.3 Rational and irrational . . . . . . . . . . . . . . . . . . 302
A.5 Assignment 5: Due Wednesday, 2017-10-11, at 5:00 pm . . . . 302
A.5.1 A recursive sequence . . . . . . . . . . . . . . . . . . . 302
A.5.2 Comparing products . . . . . . . . . . . . . . . . . . . 303
A.5.3 Rubble removal . . . . . . . . . . . . . . . . . . . . . . 304
A.6 Assignment 6: Due Wednesday, 2017-10-25, at 5:00 pm . . . . 305
A.6.1 An oscillating sum . . . . . . . . . . . . . . . . . . . . 305
A.6.2 An approximate sum . . . . . . . . . . . . . . . . . . . 307
A.6.3 A stretched function . . . . . . . . . . . . . . . . . . . 307
A.7 Assignment 7: Due Wednesday, 2017-11-01, at 5:00 pm . . . . 308
A.7.1 Divisibility . . . . . . . . . . . . . . . . . . . . . . . . 308
A.7.2 Squares . . . . . . . . . . . . . . . . . . . . . . . . . . 309
A.7.3 A Series of Unfortunate Exponents . . . . . . . . . . . 309
A.8 Assignment 8: Due Wednesday, 2017-11-08, at 5:00 pm . . . . 310
A.8.1 Minimal and maximal elements . . . . . . . . . . . . . 310
A.8.2 No trailing zeros . . . . . . . . . . . . . . . . . . . . . 311
A.8.3 Domination . . . . . . . . . . . . . . . . . . . . . . . . 313
A.9 Assignment 9: Due Wednesday, 2017-11-15, at 5:00 pm . . . . 314
A.9.1 Quadrangle closure . . . . . . . . . . . . . . . . . . . . 314
A.9.2 Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
A.9.3 Deleting a graph . . . . . . . . . . . . . . . . . . . . . 316
A.10 Assignment 10: Due Wednesday, 2017-11-29, at 5:00 pm . . . 317
A.10.1 Too many injections . . . . . . . . . . . . . . . . . . . 317
A.10.2 Binomial coefficients . . . . . . . . . . . . . . . . . . . 317
A.10.3 Variable names . . . . . . . . . . . . . . . . . . . . . . 318

B Sample exams from Fall 2017 322


B.1 CPSC 202 Exam 1, October 17th, 2017 . . . . . . . . . . . . 322
B.1.1 Factorials (20 points) . . . . . . . . . . . . . . . . . . 322
B.1.2 A tautology (20 points) . . . . . . . . . . . . . . . . . 322
B.1.3 Subsets (20 points) . . . . . . . . . . . . . . . . . . . . 323
B.1.4 Surjective functions (20 points) . . . . . . . . . . . . . 323
B.2 CPSC 202 Exam 2, December 7th, 2017 . . . . . . . . . . . . 323
B.2.1 Non-decreasing sequences (20 points) . . . . . . . . . . 324
B.2.2 Perfect matchings (20 points) . . . . . . . . . . . . . . 325
CONTENTS xiii

B.2.3 Quadratic forms (20 points) . . . . . . . . . . . . . . . 326


B.2.4 Minimal lattices (20 points) . . . . . . . . . . . . . . . 327

C Sample assignments from Fall 2013 328


C.1 Assignment 1: due Thursday, 2013-09-12, at 5:00 pm . . . . . 328
C.1.1 Tautologies . . . . . . . . . . . . . . . . . . . . . . . . 328
C.1.2 Positively equivalent . . . . . . . . . . . . . . . . . . . 330
C.1.3 A theory of leadership . . . . . . . . . . . . . . . . . . 331
C.2 Assignment 2: due Thursday, 2013-09-19, at 5:00 pm . . . . . 332
C.2.1 Subsets . . . . . . . . . . . . . . . . . . . . . . . . . . 332
C.2.2 A distributive law . . . . . . . . . . . . . . . . . . . . 333
C.2.3 Exponents . . . . . . . . . . . . . . . . . . . . . . . . . 333
C.3 Assignment 3: due Thursday, 2013-09-26, at 5:00 pm . . . . . 334
C.3.1 Surjections . . . . . . . . . . . . . . . . . . . . . . . . 334
C.3.2 Proving an axiom the hard way . . . . . . . . . . . . . 335
C.3.3 Squares and bigger squares . . . . . . . . . . . . . . . 335
C.4 Assignment 4: due Thursday, 2013-10-03, at 5:00 pm . . . . . 336
C.4.1 A fast-growing function . . . . . . . . . . . . . . . . . 336
C.4.2 A slow-growing set . . . . . . . . . . . . . . . . . . . . 337
C.4.3 Double factorials . . . . . . . . . . . . . . . . . . . . . 338
C.5 Assignment 5: due Thursday, 2013-10-10, at 5:00 pm . . . . . 339
C.5.1 A bouncy function . . . . . . . . . . . . . . . . . . . . 339
C.5.2 Least common multiples of greatest common divisors . 340
C.5.3 Adding and subtracting . . . . . . . . . . . . . . . . . 341
C.6 Assignment 6: due Thursday, 2013-10-31, at 5:00 pm . . . . . 341
C.6.1 Factorials mod n . . . . . . . . . . . . . . . . . . . . . 341
C.6.2 Indivisible and divisible . . . . . . . . . . . . . . . . . 342
C.6.3 Equivalence relations . . . . . . . . . . . . . . . . . . . 342
C.7 Assignment 7: due Thursday, 2013-11-07, at 5:00 pm . . . . 343
C.7.1 Flipping lattices with a function . . . . . . . . . . . . 343
C.7.2 Splitting graphs with a mountain . . . . . . . . . . . . 344
C.7.3 Drawing stars with modular arithmetic . . . . . . . . 344
C.8 Assignment 8: due Thursday, 2013-11-14, at 5:00 pm . . . . 347
C.8.1 Two-path graphs . . . . . . . . . . . . . . . . . . . . . 347
C.8.2 Even teams . . . . . . . . . . . . . . . . . . . . . . . . 349
C.8.3 Inflected sequences . . . . . . . . . . . . . . . . . . . . 350
C.9 Assignment 9: due Thursday, 2013-11-21, at 5:00 pm . . . . 351
C.9.1 Guessing the median . . . . . . . . . . . . . . . . . . . 351
C.9.2 Two flushes . . . . . . . . . . . . . . . . . . . . . . . . 352
C.9.3 Dice and more dice . . . . . . . . . . . . . . . . . . . . 354
CONTENTS xiv

D Sample exams from Fall 2013 356


D.1 CS202 Exam 1, October 17th, 2013 . . . . . . . . . . . . . . . 356
D.1.1 A tautology (20 points) . . . . . . . . . . . . . . . . . 356
D.1.2 A system of equations (20 points) . . . . . . . . . . . 357
D.1.3 A sum of products (20 points) . . . . . . . . . . . . . 357
D.1.4 A subset problem (20 points) . . . . . . . . . . . . . . 358
D.2 CS202 Exam 2, December 4th, 2013 . . . . . . . . . . . . . . 358
D.2.1 Minimum elements (20 points) . . . . . . . . . . . . . 359
D.2.2 Quantifiers (20 points) . . . . . . . . . . . . . . . . . . 359
D.2.3 Quadratic matrices (20 points) . . . . . . . . . . . . . 359
D.2.4 Low-degree connected graphs (20 points) . . . . . . . 361

E Midterm exams from earlier semesters 362


E.1 Midterm Exam, October 12th, 2005 . . . . . . . . . . . . . . 362
E.1.1 A recurrence (20 points) . . . . . . . . . . . . . . . . . 362
E.1.2 An induction proof (20 points) . . . . . . . . . . . . . 363
E.1.3 Some binomial coefficients (20 points) . . . . . . . . . 364
E.1.4 A probability problem (20 points) . . . . . . . . . . . 364
E.2 Midterm Exam, October 24th, 2007 . . . . . . . . . . . . . . 365
E.2.1 Dueling recurrences (20 points) . . . . . . . . . . . . . 365
E.2.2 Seating arrangements (20 points) . . . . . . . . . . . . 365
E.2.3 Non-attacking rooks (20 points) . . . . . . . . . . . . . 366
E.2.4 Subsets (20 points) . . . . . . . . . . . . . . . . . . . . 367
E.3 Midterm Exam, October 24th, 2008 . . . . . . . . . . . . . . 367
E.3.1 Some sums (20 points) . . . . . . . . . . . . . . . . . . 367
E.3.2 Nested ranks (20 points) . . . . . . . . . . . . . . . . . 367
E.3.3 Nested sets (20 points) . . . . . . . . . . . . . . . . . . 368
E.3.4 An efficient grading method (20 points) . . . . . . . . 369
E.4 Midterm exam, October 21st, 2010 . . . . . . . . . . . . . . . 369
E.4.1 A partial order (20 points) . . . . . . . . . . . . . . . 370
E.4.2 Big exponents (20 points) . . . . . . . . . . . . . . . . 370
E.4.3 At the playground (20 points) . . . . . . . . . . . . . . 370
E.4.4 Gauss strikes back (20 points) . . . . . . . . . . . . . . 371

F Final exams from earlier semesters 372


F.1 CS202 Final Exam, December 15th, 2004 . . . . . . . . . . . 372
F.1.1 A multiplicative game (20 points) . . . . . . . . . . . 372
F.1.2 An equivalence in space (20 points) . . . . . . . . . . . 374
F.1.3 A very big fraction (20 points) . . . . . . . . . . . . . 374
F.1.4 A pair of odd vertices (20 points) . . . . . . . . . . . . 375
CONTENTS xv

F.1.5 How many magmas? (20 points) . . . . . . . . . . . . 375


F.1.6 A powerful relationship (20 points) . . . . . . . . . . . 375
F.1.7 A group of archaeologists (20 points) . . . . . . . . . . 376
F.2 CS202 Final Exam, December 16th, 2005 . . . . . . . . . . . 376
F.2.1 Order (20 points) . . . . . . . . . . . . . . . . . . . . . 377
F.2.2 Count the subgroups (20 points) . . . . . . . . . . . . 377
F.2.3 Two exits (20 points) . . . . . . . . . . . . . . . . . . . 377
F.2.4 Victory (20 points) . . . . . . . . . . . . . . . . . . . . 378
F.2.5 An aggressive aquarium (20 points) . . . . . . . . . . 378
F.2.6 A subspace of matrices (20 points) . . . . . . . . . . . 379
F.3 CS202 Final Exam, December 20th, 2007 . . . . . . . . . . . 380
F.3.1 A coin-flipping problem (20 points) . . . . . . . . . . . 380
F.3.2 An ordered group (20 points) . . . . . . . . . . . . . . 381
F.3.3 Weighty vectors (20 points) . . . . . . . . . . . . . . . 381
F.3.4 A dialectical problem (20 points) . . . . . . . . . . . . 382
F.3.5 A predictable pseudorandom generator (20 points) . . 383
F.3.6 At the robot factory (20 points) . . . . . . . . . . . . 384
F.4 CS202 Final Exam, December 19th, 2008 . . . . . . . . . . . 384
F.4.1 Some logical sets (20 points) . . . . . . . . . . . . . . 384
F.4.2 Modularity (20 points) . . . . . . . . . . . . . . . . . . 385
F.4.3 Coin flipping (20 points) . . . . . . . . . . . . . . . . . 385
F.4.4 A transitive graph (20 points) . . . . . . . . . . . . . . 386
F.4.5 A possible matrix identity (20 points) . . . . . . . . . 386
F.5 CS202 Final Exam, December 14th, 2010 . . . . . . . . . . . 387
F.5.1 Backwards and forwards (20 points) . . . . . . . . . . 387
F.5.2 Linear transformations (20 points) . . . . . . . . . . . 388
F.5.3 Flipping coins (20 points) . . . . . . . . . . . . . . . . 389
F.5.4 Subtracting dice (20 points) . . . . . . . . . . . . . . . 390
F.5.5 Scanning an array (20 points) . . . . . . . . . . . . . . 391

G How to write mathematics 392


G.1 By hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
G.2 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
G.3 Microsoft Word equation editor . . . . . . . . . . . . . . . . . 393
G.4 Google Docs equation editor . . . . . . . . . . . . . . . . . . . 396
G.5 ASCII and/or Unicode art . . . . . . . . . . . . . . . . . . . . 396
G.6 Markdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
CONTENTS xvi

H Tools from calculus 398


H.1 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
H.2 Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
H.3 Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

I The natural numbers 405


I.1 The Peano axioms . . . . . . . . . . . . . . . . . . . . . . . . 405
I.2 A simple proof . . . . . . . . . . . . . . . . . . . . . . . . . . 407
I.3 Defining addition . . . . . . . . . . . . . . . . . . . . . . . . . 408
I.3.1 Other useful properties of addition . . . . . . . . . . . 410
I.4 A scary induction proof involving even numbers . . . . . . . . 411
I.5 Defining more operations . . . . . . . . . . . . . . . . . . . . 412

Bibliography 414

Index 417
List of Figures

8.1 Trace of extended Euclidean algorithm . . . . . . . . . . . . . 121


8.2 Python code for extended Euclidean algorithm . . . . . . . . 122

9.1 A directed graph . . . . . . . . . . . . . . . . . . . . . . . . . 133


9.2 Relation as a directed graph . . . . . . . . . . . . . . . . . . . 133
9.3 Factors of 12 partially ordered by divisibility . . . . . . . . . 141
9.4 Maximal and minimal elements . . . . . . . . . . . . . . . . . 142
9.5 Topological sort . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.6 Reflexive, symmetric, and transitive closures . . . . . . . . . . 149
9.7 Strongly-connected components . . . . . . . . . . . . . . . . . 150

10.1 A directed graph . . . . . . . . . . . . . . . . . . . . . . . . . 153


10.2 A graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
10.3 Two representations of a hypergraph . . . . . . . . . . . . . . 155
10.4 Complete graphs K1 through K10 . . . . . . . . . . . . . . . . 157
10.5 Cycle graphs C3 through C11 . . . . . . . . . . . . . . . . . . 158
10.6 Path graphs P0 through P4 . . . . . . . . . . . . . . . . . . . 159
10.7 Complete bipartite graph K3,4 . . . . . . . . . . . . . . . . . 159
10.8 star graphs K1,3 through K1,8 . . . . . . . . . . . . . . . . . . 160
10.9 Cayley graph of D4 . . . . . . . . . . . . . . . . . . . . . . . . 160
10.10Two presentations of the cube graph Q3 . . . . . . . . . . . . 161
10.11Subgraphs and minors . . . . . . . . . . . . . . . . . . . . . . 162
10.12Cycles and closed walks . . . . . . . . . . . . . . . . . . . . . 166

13.1 Geometric interpretation of vector addition . . . . . . . . . . 258

C.1 Examples of Sm,k for Problem C.7.3 . . . . . . . . . . . . . . 345


C.2 All 90 two-path graphs on five vertices . . . . . . . . . . . . . 346

G.1 Source code for sample LATEX document. . . . . . . . . . . . . 394

xvii
LIST OF FIGURES xviii

G.2 Formatted sample LATEX document. . . . . . . . . . . . . . . 395


List of Tables

2.1 Compound propositions . . . . . . . . . . . . . . . . . . . . . 15


2.2 Common logical equivalences . . . . . . . . . . . . . . . . . . 20
2.3 Absorption laws . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.4 Natural deduction: introduction and elimination rules . . . . 41
2.5 Natural deduction: introduction and elimination rules for
quantifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.6 Proof techniques . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.1 Set comprehension vs list comprehension . . . . . . . . . . . . 54

4.1 Features of various standard algebras . . . . . . . . . . . . . . 82

8.1 Arithmetic in Z5 . . . . . . . . . . . . . . . . . . . . . . . . . 119


8.2 Multiplication table for Z9 . . . . . . . . . . . . . . . . . . . . 125

H.1 Table of derivatives . . . . . . . . . . . . . . . . . . . . . . . . 401


H.2 Table of integrals . . . . . . . . . . . . . . . . . . . . . . . . . 403

xix

You might also like