CS 124 Math Review Section January 29, 2018

Similar documents
Basics of Proofs. 1 The Basics. 2 Proof Strategies. 2.1 Understand What s Going On

Chapter 1 Review of Equations and Inequalities

HOW TO WRITE PROOFS. Dr. Min Ru, University of Houston

Math 31 Lesson Plan. Day 2: Sets; Binary Operations. Elizabeth Gillaspy. September 23, 2011

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 10

Introducing Proof 1. hsn.uk.net. Contents

Lecture 4: Constructing the Integers, Rationals and Reals

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14

CS 246 Review of Proof Techniques and Probability 01/14/19

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

Solving with Absolute Value

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

Introduction to Algebra: The First Week

MAT Mathematics in Today's World

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

CS1800: Strong Induction. Professor Kevin Gold

P (A) = P (B) = P (C) = P (D) =

Math 38: Graph Theory Spring 2004 Dartmouth College. On Writing Proofs. 1 Introduction. 2 Finding A Solution

One-to-one functions and onto functions

means is a subset of. So we say A B for sets A and B if x A we have x B holds. BY CONTRAST, a S means that a is a member of S.

RVs and their probability distributions

What is proof? Lesson 1

Algebra Exam. Solutions and Grading Guide

Big-oh stuff. You should know this definition by heart and be able to give it,

Discrete Mathematics and Probability Theory Fall 2012 Vazirani Note 14. Random Variables: Distribution and Expectation

Mathematical Induction

Lecture 5. 1 Review (Pairwise Independence and Derandomization)

6.042/18.062J Mathematics for Computer Science November 28, 2006 Tom Leighton and Ronitt Rubinfeld. Random Variables

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 12. Random Variables: Distribution and Expectation

Counting in the Twilight Zone

Calculus II. Calculus II tends to be a very difficult course for many students. There are many reasons for this.

Math 300: Foundations of Higher Mathematics Northwestern University, Lecture Notes

An analogy from Calculus: limits

Mathematical induction

Proofs. 29th January 2014

Gradient. x y x h = x 2 + 2h x + h 2 GRADIENTS BY FORMULA. GRADIENT AT THE POINT (x, y)

PGSS Discrete Math Solutions to Problem Set #4. Note: signifies the end of a problem, and signifies the end of a proof.

The Inductive Proof Template

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Note 2

CHAPTER 1. REVIEW: NUMBERS

Example. How to Guess What to Prove

Hypothesis testing I. - In particular, we are talking about statistical hypotheses. [get everyone s finger length!] n =

a. See the textbook for examples of proving logical equivalence using truth tables. b. There is a real number x for which f (x) < 0. (x 1) 2 > 0.

AQA Level 2 Further mathematics Further algebra. Section 4: Proof and sequences

Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2:

Proof Techniques (Review of Math 271)

6.041SC Probabilistic Systems Analysis and Applied Probability, Fall 2013 Transcript Tutorial:A Random Number of Coin Flips

1. When applied to an affected person, the test comes up positive in 90% of cases, and negative in 10% (these are called false negatives ).

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Note 15. Random Variables: Distributions, Independence, and Expectations

Mathematics-I Prof. S.K. Ray Department of Mathematics and Statistics Indian Institute of Technology, Kanpur. Lecture 1 Real Numbers

Grades 7 & 8, Math Circles 10/11/12 October, Series & Polygonal Numbers

One sided tests. An example of a two sided alternative is what we ve been using for our two sample tests:

How to write maths (well)

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 3

LECTURE 15: SIMPLE LINEAR REGRESSION I

Topic 1: Propositional logic

Guide to Proofs on Sets

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

Discrete Structures Proofwriting Checklist

Seunghee Ye Ma 8: Week 2 Oct 6

Chapter 26: Comparing Counts (Chi Square)

CSE 103 Homework 8: Solutions November 30, var(x) = np(1 p) = P r( X ) 0.95 P r( X ) 0.

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 16. Random Variables: Distribution and Expectation

25. REVISITING EXPONENTS

PROOF WITHOUT WORDS MATH CIRCLE (BEGINNERS) 05/06/2012

You separate binary numbers into columns in a similar fashion. 2 5 = 32

Isomorphisms and Well-definedness

Quadratic Equations Part I

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

1 Impact Evaluation: Randomized Controlled Trial (RCT)

What can you prove by induction?

Theorem (Special Case of Ramsey s Theorem) R(k, l) is finite. Furthermore, it satisfies,

Proving languages to be nonregular

1 Proof techniques. CS 224W Linear Algebra, Probability, and Proof Techniques

CS280, Spring 2004: Final

Probability (Devore Chapter Two)

DIFFERENTIAL EQUATIONS

Discrete Mathematics for CS Spring 2006 Vazirani Lecture 22

Math 291-1: Lecture Notes Northwestern University, Fall 2015

Inference and Proofs (1.6 & 1.7)

MI 4 Mathematical Induction Name. Mathematical Induction

Cambridge University Press How to Prove it: A Structured Approach: Second edition Daniel J. Velleman Excerpt More information

Mathematical Induction. EECS 203: Discrete Mathematics Lecture 11 Spring

Direct Proofs. the product of two consecutive integers plus the larger of the two integers

Math 5a Reading Assignments for Sections

Intermediate Logic. Natural Deduction for TFL

Basic Probability. Introduction

PROBLEM SET 3: PROOF TECHNIQUES

Mathematical Induction

Lecture 12: Quality Control I: Control of Location

Countability. 1 Motivation. 2 Counting

Expected Value II. 1 The Expected Number of Events that Happen

Hypothesis Testing. ) the hypothesis that suggests no change from previous experience

Getting Started with Communications Engineering

Basic counting techniques. Periklis A. Papakonstantinou Rutgers Business School

Discrete Mathematics for CS Fall 2003 Wagner Lecture 3. Strong induction

5.3 Conditional Probability and Independence

Fundamentals of Probability CE 311S

Transcription:

CS 124 Math Review Section CS 124 is more math intensive than most of the introductory courses in the department. You re going to need to be able to do two things: 1. Perform some clever calculations to understand how your algorithms behave. 2. Use clear mathematical language to describe your algorithms to other people (and to convince yourself that they do what you think they do). Number 1 is something all of you are going to be able to do, but I ll start off by reviewing some material from calculus, probability, etc. that you might find particularly useful in algorithmic analysis. Number 2 is trickier. Only the crystal-clear language of mathematical proof will convince your skeptical TFs that you know what you re doing. Some of you might not have written a (good) mathematical proof before. Most of our time will be spent going over how to do that. If you ve taken CS121, you should be well-prepared for this, but your proofs might feel a little different because we re working with different material. 1 Some calculation techniques 1.1 Probability and counting This will be useful later in the course when we talk about hashing and randomized algorithms. Problem 1 (Probability and expected value): Suppose that I have 17 bins in a row in front of me and I m throwing a bunch of balls towards them. For each ball, there s a 1/5 chance that it lands in the bin on the far left and a 1/20 chance that it lands in each of the other bins. I throw two balls. What is the probability that both land in the bin on the far left? What is the probability that neither lands in the bin on the far right? Let c = 0. From left to right, I number the bins 1, 2,..., 17. I throw 100 balls at the bins. For each ball, I figure out what bin it s in, and I add the bin s number to c. What is the expected value of c? I throw 5 balls. What is the chance that one will land in the bin on the far left and no two balls will land in the same bin? 1

1.2 Sums and series Being able to quickly calculate n i i=1 saved us a lot of time on the second part of Problem 1. It often happens happens in CS that we are given a sequence of numbers and need to add them together. If the sequence has a pattern, we can exploit the pattern to avoid adding the numbers one at a time. Here s another example: n (1/2) i Problem 2: What s the value of this sum in terms of n? The above two expressions are examples of finite sums. You ll remember from calculus that we can go a step further and consider an infinite series: lim n n.5 i =.5 i All we re asking here is what happens to the value we found in Problem 2 when n gets really big?. Often, the sum just blows-up to infinity. But in the given case, the numbers that we re adding get very very small so the sum is not infinite (recall Zeno s paradox). Problem 3 What is the value of the above sum? 2

Be careful. Just because the terms in a sum get small doesn t mean that the sum converges: 1/i = Dealing with tricky sums is a great topic for a real analysis course. In this course we ll just use sums for our own ends. Appendix A in CLRS has a huge collection of useful sums. Two in particular: r n = n=0 n=0 2 How to write a proof x n n! = ex { 1 1 r if 0 < r < 1, if r 1. A proof really isn t anything fancy, it s just a rock-solid mathematical argument. You write a proof to convince the other guy that you re correct. But the point of a proof is more than that. I could just say I m the TF and I know what I m talking about and you d probably decide that I m correct. A proof on the other hand leads the reader step by step from what they already believe to what you want them to believe. They should feel like they re being gently carried along to a higher state of knowledge. This requires a couple things: 1. Start with what the reader already believes. 2. Proceed in logical steps, building on what you ve already proved. Don t obsess over every statement that you make, just ensure that each statement follows logically from the statement before it. Make sure that your language is clear and straightforward. 3.???? 4. Profit That s all there is to it. It s tempting to just write down whatever your train of thought was when you solved the problem. Don t. Write something that is clear, direct, and pleasant to read. Solving the problem is just the first step. There are many paths to a solution and a good proof takes the most beautiful one. 3

2.1 Important things to not do Do not substitute an example for a proof. Do not substitute a picture for a proof. Do not skip logical steps because you re having trouble writing what you mean. There is a very good chance that you are having trouble because you misunderstand something. Suppose that I ask you to prove that F n = 2 2n + 1 is prime for all n. It s easy to check that this is true for n = 0, 1, 2, 3, and 4 but hard to prove in general (because it s wrong). Make sure that you re proving all of what you re asked to prove. 2.2 Non-examples and an example Example problem: We have a (possibly biased) coin that gives heads with probability q, such that 0 < q < 1. I have a genius strategy to produce unbiased coin flips using this biased coin. I start by flipping the biased coin twice. I look at these two biased flips. If they are HT, I add H to the output stream. If they are TH, I add T to the output string. Then I flip the coin again, look at the second and third flips, and do the same thing. Then I flip again and look at the third and fourth flips. And so on. If the pair of input flips that I look at is HH or TT then I skip this pair completely, flipping the biased coin twice in a row in order to get a new pair. Prove that the coin flips in the output stream are biased. Bad (1/10): Two output flips that I produce with this method are related to each other because they both share one of the same input flips. The fact that they share an input flip means that one of them depends on the other so that the output flips are not unbiased. Why it s bad: This is the correct idea, but the presentation is shoddy. The remark they both share one of the same input flips is unacceptably vague, even though we can figure out from context what it means. The conclusion of the argument is one of them depends on the other but I, as the reader, don t understand how the word depends relates to the mathematical idea of being biased. Better but still bad (6/10): If a stream of coin flips is unbiased, then the probability that the n th flip is heads does not depend on the outcome of the first n 1 flips. Suppose that we use the above method to generate a stream of coin flips. If the k th flip in the output stream is H then the (k + 1) th flip in the output stream is more likely to be a T than an H. To see this, consider what happens when we are producing these output flips. We see HT and produce H as the k th output flip. Then the next input bit is either T or H. If it is T then we start over. If it is H then we produce T. Thus we are more likely to produce a T next. Why it s bad: This is much better. This person states clearly what they mean by unbiased and states clearly why this stream is not unbiased. However, they trail off at the end. They have shown one way that you might get an H and then get a T. They have not proven that an H is more likely to be followed by a T than by an H. 4

Acceptable: If a stream of coin flips is unbiased, then the probability that the n th flip is heads does not depend on the outcome of the first n 1 flips. Suppose that we use the above method to generate a stream of coin flips. I claim that if the k th flip in the output stream is H then the (k + 1) th flip in the output stream is more likely to be a T than an H. To see this, consider what happens when we are producing these output flips. We see HT and produce H as the k th output flip. With probability q, the next input flip is H and we produce a T. With probability 1 q, the next input flip is T and there is equal probability of the next output flip being H and T. Thus the probability of the next flip being H is q + 1(1 q) = 1 + q > 1. This proves 2 2 2 2 the result. 2.3 Proof techniques 2.3.1 Proof by induction We often use induction when we want to prove that a certain statement is correct for any natural number n. This seems like a tricksy thing to do. If I prove correctness for n = 0 and n = 1 and n = 2, I will have failed CS 124 long before I ve proved the statement for F 5 = 4294967297. So here s the clever hack. Establish a base case: prove that the statement is true for the minimum value of n that I am interested in (usually n = 0 or n = 1). Now fire up the induction machine: supposing that the statement is true for n = k (k is a dummy variable), prove that the statement is true for n = k + 1. The induction machine now chews through all of the natural numbers for us. Another way of phrasing it: if you want to climb up a ladder then you only need two things: You need to be on a rung of the ladder. You need to know how to get from a rung to the rung above it. If you know these two things, you can climb the whole ladder. When you establish a base case, you prove that you are on a rung of the ladder. When you prove that you have a working induction machine, you prove that you have a gizmo that gets you from one rung to the next. Example proof: What is the sum of the first n odd numbers? Proof We will prove by induction that the sum of the first n odd numbers is n 2. The sum of the first 1 odd numbers is 1, so our claim is valid when n = 1. Suppose that the sum of the first k odd numbers is k 2. Consider the sum of the first k + 1 odd numbers: 1 + (2 2 1) +... + (2 k 1) + (2 (k + 1) 1) By the induction hypothesis, this is equal to k 2 + (2 (k + 1) 1) = k 2 + 2k + 1 = (k + 1) 2 5

The result follows by induction. That s all there is to it! Give it a try yourself: Problem 4: The triangle inequality says that for x, y real numbers: x + y x + y. Prove the following for any n: if x 1,..., x n are real numbers then x i x i. Problem 5: Prove an exercise from the class notes for the second lecture: F n 2 n/2 for n 8. (Where F n is the n th Fibonacci number.) 2.3.2 Proof by contradiction Prime numbers are fantastically useful in computer science (anyone know an example of why?). Fortunately for us, there are infinitely many prime numbers. How do we prove something like this. It seems too vague to get a good handle on. Well, let s 6

pretend for a minute that it s false (pretending that the answer is false is often a good way to figure out why it s true, even if we don t end up using a proof by contradiction). If the statement is false then there are only n prime numbers: p 1,..., p n. Here s a proof by contradiction: Proof Suppose that the only prime numbers are p 1,..., p n. Consider the number N = p 1... p n + 1. Either N is prime or it is divisible by a prime number. It is larger than any of the p i, so it must not be prime. Thus it has a prime divisor. However, none of the p i can divide N (because they divide N 1), so the p i are not all of the primes. This is a contradiction. There must be infinitely many primes. Easy peasy. Try it yourself: Problem 6: Prove that 2 is irrational. 7