3.growth of functions hsu, lih-hsing. computer theory lab. chapter 3p.2 3.1 asymptotic notation ...

21
3.Growth of Functions Hsu, Lih-Hsing

Post on 21-Dec-2015

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

3.Growth of Functions

Hsu, Lih-Hsing

Page 2: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.2

Computer Theory Lab.

3.1 Asymptotic notation

g(n) is an asymptotic tight bound for f(n). ``=’’ abuse

}all for

)()()(0 s.t. ,,|)({))((

0

21021

nn

ngcnfngcnccnfng

))(()( ngnf

Page 3: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.3

Computer Theory Lab.

The definition of required every member of be asymptotically nonnegative.

n 0

n

c 2g(n)

c 1g(n)

f(n)f n g n( ) ( ( ))

Page 4: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.4

Computer Theory Lab.

Example:

)(6

.7 2

3214

23

222

nn

n>ifn

nnn

f n an bn c a, b, c a>

f(n)= (n ).

( ) ,

2

2

0 constants, .

In general,

).(nP(n)

aananp

d

didi

ii

Then

.0ith constant w are where)( 0

Page 5: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.5

Computer Theory Lab.

asymptotic upper bound

} )()(0s.t.,|)({))(( 00 nnncgnfncnfngO

n 0

n

cg(n)

f(n)f n O g n( ) ( ( ))

Page 6: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.6

Computer Theory Lab.

asymptotic lower bound

} )()(0 s.t. ,|)({))(( 00 nnnfncgncnfng

n 0

n

cg(n)

f(n)f n g n( ) ( ( ))

Page 7: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.7

Computer Theory Lab.

Theorem 3.1. For any two functions f(n) and g(n),

if and only if and . f n g n( ) ( ( )) f n O g n( ) ( ( ))

f n g n( ) ( ( ))

Page 8: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.8

Computer Theory Lab.

o g n f n c n n n f n cg n( ( )) { ( )| , , ( ) ( )} 0 0 0

f n o g nf ng nn( ) ( ( )) lim( )( )

0

( ( )) { ( )| , , ( ) ( )}g n f n c n n n cg n f n 0 0 0

f n g nf ng nn( ) ( ( )) lim( )( )

Page 9: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.9

Computer Theory Lab.

Transitivity

Reflexivity

Symmetry

f n g n g n h n f n h n( ) ( ( )) ( ) ( ( )) ( ) ( ( )) f n O g n g n O h n f n O h n( ) ( ( )) ( ) ( ( )) ( ) ( ( )) f n g n g n h n f n h n( ) ( ( )) ( ) ( ( )) ( ) ( ( )) f n o g n g n o h n f n o h n( ) ( ( )) ( ) ( ( )) ( ) ( ( )) f n g n g n h n f n h n( ) ( ( )) ( ) ( ( )) ( ) ( ( ))

f n f n( ) ( ( ))f n O f n( ) ( ( ))f n f n( ) ( ( ))

f n g n g n f n( ) ( ( )) ( ) ( ( ))

Page 10: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.10

Computer Theory Lab.

Transpose symmetry f n O g n g n f n( ) ( ( )) ( ) ( ( )) f n o g n g n f n( ) ( ( )) ( ) ( ( ))

f n O g n a b( ) ( ( )) f n g n a b( ) ( ( )) f n g n a b( ) ( ( )) f n o g n a b( ) ( ( )) f n g n a b( ) ( ( ))

Page 11: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.11

Computer Theory Lab.

Trichotomy a < b, a = b, or a > b. e.g., n n n, sin1

n n0 2

Page 12: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.12

Computer Theory Lab.

2.2 Standard notations and common functions

Monotonicity: A function f is monotonically increasing if m

n implies f(m) f(n). A function f is monotonically decreasing if m

n implies f(m) f(n). A function f is strictly increasing if m < n implies

f(m) < f(n). A function f is strictly decreasing if m > n implie

s f(m) > f(n).

Page 13: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.13

Computer Theory Lab.

Floor and ceiling

x x x x x 1 1

n n n/ /2 2

n a b n ab/ / /

n a b n ab/ / /

bbaba /))1((/

bbaba /))1((/

Page 14: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.14

Computer Theory Lab.

Modular arithmetic For any integer a and any positive integer n, the

value a mod n is the remainder (or residue) of the quotient a/n :

a mod n =a -a/nn.

If(a mod n) = (b mod n). We write a b (mod n) and say that a is equivalent to b, modulo n.

We write a ≢ b (mod n) if a is not equivalent to b modulo n.

Page 15: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.15

Computer Theory Lab.

Polynomials v.s. Exponentials

Polynomials: A function is polynomial bounded if

. Exponentials:

Any positive exponential function grows faster than any polynomial.

P n a ni i

i

d( )

0 )1()( Onnf n o a ab n ( ) ( )1

xnn

x

i

ix

en

x

xx

xex

i

xe

)1(lim

1|| if 2

11

!2

0

Page 16: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.16

Computer Theory Lab.

Logarithms

A function f(n) is polylogarithmically bounded if

for any constant a > 0. Any positive polynomial function grows fast

er than any polylogarithmic function.

ln( ) ... | |12 3 4 5

12 3 4 5

x xx x x x

if x

xx

x x1

1

ln( )

nnf O )1(log)(

)(log ab non

Page 17: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.17

Computer Theory Lab.

Factorials Stirling’s approximation

))1

(1()(2!ne

nnn n

n o nn! ( )n n! ( ) 2

log( !) ( log )n n n

nn

ee

nnn

2!

where

nn n 12

1

112

1

Page 18: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.18

Computer Theory Lab.

Function iteration

.0))((

,0)( )1(

)(

ifinff

ifinnf i

i

For example, if , thennnf 2)( nnf ii 2)()(

Page 19: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.19

Computer Theory Lab.

The iterative logarithm function

nninin

in

n

)(i

)(i

iii

undefined. is lgor 0lg and 0 if undefined0lg and 0 if )lg(lg

0 if

)(lg

1

1

)1()1()(

lg ( ) min{ |lg }* ( )n i i 0 1

lg* 2 1lg* 4 2lg*16 3lg* 65536 4lg* 2 565536

Page 20: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.20

Computer Theory Lab.

Since the number of atoms in the observable universe is estimated to be about , which is much less than , we rarely encounter a value of n such that .

8010 655362

5lg* n

Page 21: 3.Growth of Functions Hsu, Lih-Hsing. Computer Theory Lab. Chapter 3P.2 3.1 Asymptotic notation  g(n) is an asymptotic tight bound for f(n). ``= ’’ abuse

Chapter 3 P.21

Computer Theory Lab.

Fibonacci numbers

...61803.02

51

...61803.12

51

5

1

0

21

1

0

ii

i

iii

F

FFF

F

F