if n is even Suppose p is false n 2 = n + 1 if n is odd Show - - PowerPoint PPT Presentation

if n is even
SMART_READER_LITE
LIVE PREVIEW

if n is even Suppose p is false n 2 = n + 1 if n is odd Show - - PowerPoint PPT Presentation

Floor and Ceiling CSE 20 Discrete Math Ceiling(x): ! x " The least-integer greater than or equal to x Formal definition: the unique integer n such that n -1 < x n Floor(x): # x $ The greatest-integer less than or equal to


slide-1
SLIDE 1

CSE 20—Discrete Math

Summer, 2006 July 13 (Day 4) Methods of Proof Number Theory Instructor: Neil Rhodes Floor and Ceiling

Ceiling(x): !x"

The least-integer greater than or equal to x Formal definition: the unique integer n such that n-1 < x n

Floor(x): #x$

The greatest-integer less than or equal to x Formal definition: the unique integer n such that n x < n+1

Graph:

2

Floor and Ceiling

!x" = x ↔ x is an integer ↔ #x$= x

For real x, integer n:

  • #x$= n ↔ x-1 < n x
  • !x" = n ↔ x n < x+1
  • !x+n" = !x" +n
  • #x$ = -!-x"
  • !x"=-#-x$

3

Usage

You’re guessing a number between 1 and 1000

Each answer is “too high”, “too low”, or “you got it” What is the maximum number of guesses required to guess the number?

4

slide-2
SLIDE 2

Proof of Ceiling/Floor Properties

!x" = n ↔ x n < x+1 #x$ = -!-x"

5

Disproof of Ceiling/Floor Properties

#x+y$ = #x$+#y$

6

Theorems with Ceiling

7

n 2

  • =

n

2

if n is even

n+1 2

if n is odd

Proof by Contradiction

To Prove p

Suppose p is false … Show a contradiction: q and ~q Therefore, our assumption (that p was false) is false, and hence that p is

true.

8

slide-3
SLIDE 3

Proof by Contradiction

Every integer is either odd or even, but not both

9

Proof by Contradiction

The product of an irrational and a non-zero rational is irrational.

10

Proof by Contraposition

To prove ∀x∈D, P(x)Q(x)

Rewrite (mentally) as ∀x∈D, ~Q(x)~P(x) Prove contrapositive directly (use generalizing from generic particular)

– Suppose x is an element of D such that Q(x) is false – Show that P(x) is false

Example: If the square of an integer, n, is even, then n is even

11

Differences between the Two

Proof by contraposition

Any such proof can be rewritten as a proof by contradiction

– Assume P(x) and ~Q(x). Show ~P(x), a contradiction

Proof by contradiction

More powerful. Can’t necessarily be rewritten as a proof by contraposition Can show any contradiction

12

slide-4
SLIDE 4

Proof by Contradiction

2 is irrational.

Proof: Suppose that 2 is rational But that is a contradiction.

13

There are an Infinite Number of Primes

Proof:

Suppose the set of primes is finite. But that’s a contradiction.

14

List all the primes in this finite set: P1, P2…,Pn. Construct the number m=p1•p2•…•Pn + 1. Since m is bigger than any pi, m is not prime remainder of m/pi is 1 (by QRT), so pi doesn’t divide m for any i. But, due to Prime Factorization theorem, m has prime factors (since m > 1). So m has some prime factor not equal to any pi, so the finite set of primes is missing a prime.

gcd, lcm

Greatest Common Divisor (GCD)

GCD(m, n) is the largest integer k that divides integers m and n

– k | m and k | n

GCD(m, n) is a linear combination (with integer coefficients) of m and n

– ∃i, j ∈ Z: gcd(m, n) = im + jn

To calculate GCD(m, n)

– Compute prime factorization of m and n – gcd(m, n) = common prime factors (and powers) of m and n

Euclid’s algorithm

– int gcd(m, n) – if (n == 0) return m

else return gcd(n, m mod n)

Least Common Multiple (LCM)

LCM(m, n) is the smallest integer k such that integers m and n divide k

– m | k and n | k

To calculate LCM(m , n)

– Compute prime factorizations of m and n – lcm(m, n) = union of prime factors (and powers) of m and n

15

Computing GCD

Calculating GCD of 24 120

Prime factorization Euclid’s algorithm

16

134 % 24 = 14 134 = 5•24 + 14 24 % 14 = 10 24 = 1•14 + 10 14 % 10 = 4 14 = 1•10 + 4 10 % 4 = 2 10 = 2•4 + 2 4 % 2 = 0 4 = 2•2 + 0 gcd = 2

slide-5
SLIDE 5

GCD as Linear Combination

Given m, n, GCD(m, n), find integer i, j such that

GCD(m, n) = im + jn Use Euclid’s algorithm Go backwards

17

134 % 24 = 14 134 = 5•24 + 14 24 % 14 = 10 24 = 1•14 + 10 14 % 10 = 4 14 = 1•10 + 4 10 % 4 = 2 10 = 2•4 + 2 4 % 2 = 0 4 = 2•2 + 0 2 = 10-2•4 2 = 10-2•(14-10) = 3•10-2•14 2 = 3•(24-1•14) - 2•14 = -5•14 + 3•24 2 = -5(134-5•24) +3•24 = 28•24-5•134

Why does Euclid’s Algorithm Work?

GCD(r, 0) = r (r a positive integer)

18

Why does Euclid’s Algorithm Work?

GCD(m, n) = GCD(n, m mod n)

Prove GCD(m, n) GCD(n, m mod n) Prove GCD(m, n) GCD(n, m mod n)

19