October 3, 2001CSE 373, Autumn 20011 Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.

Slides:



Advertisements
Similar presentations
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
Advertisements

Induction and recursion
Proof Techniques and Recursion. Proof Techniques Proof by induction –Step 1: Prove the base case –Step 2: Inductive hypothesis, assume theorem is true.
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
1 Intro to Induction Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
1 Strong Mathematical Induction. Principle of Strong Mathematical Induction Let P(n) be a predicate defined for integers n; a and b be fixed integers.
analysis, plug ‘n’ chug, & induction
Induction and recursion
Mathematical Maxims and Minims, 1988
1 CS 201 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Chapter 6 Mathematical Induction
Reading and Writing Mathematical Proofs
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
Chapter 2 - Mathematical Review Functions
CSE 20 Lecture 12 Induction CK Cheng 1. Induction Outlines Introduction Theorem Examples: The complexity calculation – Tower of Hanoi – Merge Sort – Fibonacci.
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
1 CE 221 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Advance Data Structure and Algorithm COSC600 Dr. Yanggon Kim Chapter 1.
Copyright © Peter Cappello Mathematical Induction Goals Explain & illustrate construction of proofs of a variety of theorems using mathematical induction.
Recursion l Powerful Tool l Useful in simplifying a problem (hides details of a problem) l The ability of a function to call itself l A recursive call.
Chapter 1 Introduction. Goals Why the choice of algorithms is so critical when dealing with large inputs Basic mathematical background Review of Recursion.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
INDUCTION AND RECURSION. PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function,
CSC201 Analysis and Design of Algorithms Asst.Proof.Dr.Surasak Mungsing Oct-151 Lecture 2: Definition of algorithm and Mathematical.
Methods of Proofs PREDICATE LOGIC The “Quantifiers” and are known as predicate quantifiers. " means for all and means there exists. Example 1: If we.
Mathematical Background and Linked Lists. 2 Iterative Algorithm for Sum Find the sum of the first n integers stored in an array v : sum (v[], n) temp_sum.
Recursive Algorithms &
Chap 3 –A theorem is a statement that can be shown to be true –A proof is a sequence of statements to show that a theorem is true –Axioms: statements which.
Logical Reasoning:Proof Prove the theorem using the basic axioms of algebra.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 3 The Foundations: Logic and Proof,
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 1: Introduction
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Math Review 1.
Mathematical Induction
1 CMSC 341 Math Review. 2 Exponents Identities (X A ) B = X AB X A * X B = X A+B X A / X B = X A-B X A + X B  X A+B.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
Quiz 7 The way I expected it.. How to do it! 1. Let P(n) be the statement that n 2 = n(n + 1)(2n + 1)/6 for the positive integer n. Be.
CSE 311 Foundations of Computing I Lecture 8 Proofs Autumn 2012 CSE
TCSS 342 Autumn 2004 Version TCSS 342 Data Structures & Algorithms Autumn 2004 Ed Hong.
5-5 Indirect Proof. Indirect Reasoning: all possibilities are considered and then all but one are proved false. The remaining possibility must be true.
Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach a particular.
EXAMPLE 3 Write an indirect proof Write an indirect proof that an odd number is not divisible by 4. GIVEN : x is an odd number. PROVE : x is not divisible.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
1 Proofs by Counterexample & Contradiction There are several ways to prove a theorem:  Counterexample: By providing an example of in which the theorem.
11.7 – Proof by Mathematical Induction
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Induction and recursion
CSE 311: Foundations of Computing
Methods of Proof A mathematical theorem is usually of the form pq
Mathematical Induction Recursion
Chapter 5 Induction and Recursion
BaSIC Math Reviews.
Notes 9.5 – Mathematical Induction
Induction and recursion
Follow me for a walk through...
Applied Discrete Mathematics Week 9: Integer Properties
CMSC 341 Math Review.
CE 221 Data Structures & Algorithms Chapter 1 Introduction
Geometry.
CSE 373 Optional Section Led by Yuanwei, Luyi Apr
Follow me for a walk through...
Mathematical Induction
Mathematical Induction
Follow me for a walk through...
5.6 Inequalities in Two Triangles and Indirect Proof
DS.I.1 CSE 373: Data Structures and Algorithms Autumn Quarter 2000
Data Structures & Programming
Presentation transcript:

October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1 Logarithms Definition: X A = B if and only if log X B = A.

October 3, 2001CSE 373, Autumn Logarithms, continued log AB = log A + log B Proof: Let X = log A, Y = log B, and Z = log AB. Then 2 X = A, 2 Y = B, and 2 Z = AB. So, 2 X 2 Y = AB = 2 Z. Therefore, X + Y = Z.

October 3, 2001CSE 373, Autumn Logarithms, Series log A/B = log A – log B log (A B ) = B log A Series binary representation of numbers

October 3, 2001CSE 373, Autumn Boolean Logic Let P and Q be statements. “not P” is true if P is false. “P and Q” is true if both P and Q are true. “P or Q” is true if one of or both P or Q are true. “P implies Q” is true if P is false or Q is true (or both).

October 3, 2001CSE 373, Autumn Proof by Induction 1.Formulate a statement P(n) that depends on n. 2.Prove P(1). (Basis Step) 3.Prove that for any n  1, if P(m) for all 1  m  n, then P(n+1). (Induction Step) (The red statement is called the induction hypothesis.)

October 3, 2001CSE 373, Autumn Proof by induction Why does it work? We don’t actually prove, for example, P(503). P(1)P(2)P(3)P(4)P(503)

October 3, 2001CSE 373, Autumn Proof that 1.P(N) is 2.P(1): 3.Suppose P(m) is true for all 1  m  N, N  1.

October 3, 2001CSE 373, Autumn P(N) implies P(N+1)

October 3, 2001CSE 373, Autumn log N < N For all integers N > 0, log N < N. P(N) is log N < N. P(1): log 1 = 0 < 1. Suppose P(m) is true for all 1  m  N, N  1. log (N+1)  log (N+N) = log 2N = (log N) + 1 < N + 1(ind. hyp.)

October 3, 2001CSE 373, Autumn Proof by Contradiction Assume the theorem is false and show that that assumption leads to a known falsehood. This shows that the original assumption was false. The only way the whole line of reasoning is true is if is false.

October 3, 2001CSE 373, Autumn Proof by Counterexample To show a general statement to be false, you need only exhibit one specific instance of the statement to be false. “For all N > 1, N > N 2 ” is false. For N=5, 5 < 5 2.

October 3, 2001CSE 373, Autumn Recursion A recursive function is one that calls itself. n! = n (n-1) (n-2) … 1 int factorial (const int n) { if (n == 1) return 1; else return (n * factorial(n-1)); }

October 3, 2001CSE 373, Autumn Anatomy of a Recursive Function Base case: does not use recursion. if (n == 1) return 1; Making progress: the recursive call needs to get “closer” to a base case. else return (n * factorial(n-1));

October 3, 2001CSE 373, Autumn Recursion and Induction Prove that factorial(n) returns n! P(n) is P(1): factorial(1) follows the if part of the if statement and returns 1 = 1! So, P(1) is true. Suppose P(m) is true for all 1  m  n, n  1. Then factorial(n+1) follows the else part of the if statement and returns (n+1)*factorial(n). So, factorial(n+1) returns (n+1)*n! = (n+1)!  P(n+1) is true.

October 3, 2001CSE 373, Autumn Iterative factorial int factorial_iterative(const int n) { int i; int product = 1; for (i = 1; i <= n; i++) product *= i; return product; } How do we prove that this function computes factorial correctly?

October 3, 2001CSE 373, Autumn Loop invariants Loop invariant: a statement that is true after each iteration of a loop. After the kth iteration of the loop (before i++ ), i=k and product = k! If the loop invariant is true, then after the nth iteration, the loop will end with i=n and the function will return product = n! Exercise: Prove that factorial_iterative(n) returns n!