Module #6: Orders of Growth

Slides:



Advertisements
Similar presentations
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 22 By Herbert I. Gross and Richard A. Medeiros next.
Advertisements

Chapter 3 Growth of Functions
The Growth of Functions
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
1 Analysis of Algorithms & Orders of Growth Rosen 6 th ed., §
Real-Valued Functions of a Real Variable and Their Graphs Lecture 43 Section 9.1 Wed, Apr 18, 2007.
Introduction to Algorithms Jiafen Liu Sept
Mathematics Review and Asymptotic Notation
The Growth of Functions Rosen 2.2 Basic Rules of Logarithms log z (xy) log z (x/y) log z (x y ) If x = y If x < y log z (-|x|) is undefined = log z (x)
Real-Valued Functions of a Real Variable and Their Graphs Lecture 38 Section 9.1 Mon, Mar 28, 2005.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
O -Notation April 23, 2003 Prepared by Doug Hogan CSE 260.
資訊科學數學 9 : Integers, Algorithms & Orders 陳光琦助理教授 (Kuang-Chi Chen)
4.1 CompSci 102© Michael Frank Today’s topics AlgorithmsAlgorithms – –Algorithm review – –Orders of Growth Reading: Sections Reading: Sections.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
Module #5 - Algorithms 1 Module #5: Algorithms Rosen 5 th ed., §2.1 ~31 slides, ~1 lecture.
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Analysis of Algorithms & Recurrence Relations. Recursive Algorithms Definition –An algorithm that calls itself Components of a recursive algorithm 1.Base.
Lecture 7. Asymptotic definitions for the analysis of algorithms 1.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Data Structures & Algorithm CS-102 Lecture 12 Asymptotic Analysis Lecturer: Syeda Nazia Ashraf 1.
Jessie Zhao Course page: 1.
The Relation Induced by a Partition
The Growth of Functions: Selected Exercises
3 DERIVATIVES.
Chapter 2 Sets and Functions.
Relations, Functions, and Matrices
2.7 Combining Functions.
Introduction to Algorithms
Analysis of Algorithms & Orders of Growth
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015.
Algorithms Algorithm Analysis.
Today’s topics Algorithms Reading: Sections Upcoming
Assignment 2 Tze calculations.
The Growth of Functions
The Growth of Functions
Rosen 5th ed., §2.7 ~18 slides, ~1 lecture
Review 2.
Rosen 5th ed., §3.2 ~9 slides, ~½ lecture
Transformations of Functions
Asymptotic Growth Rate
Orders of Growth Rosen 5th ed., §2.2.
Analysis of Algorithms
5 INTEGRALS.
Functions.
Rosen 5th ed., §3.2 ~9 slides, ~½ lecture
College Algebra Fifth Edition
CSE 373: Data Structures & Algorithms
Introduction to Algorithms
Functions Rosen 6th ed., §2.3.
Discrete Mathematics and its Applications
Logical Entailment Computational Logic Lecture 3
Introduction to Economic Growth
The Exponential Function and Logarithms
AS-Level Maths: Core 2 for Edexcel
Discrete Mathematics and its Applications
Copyright © Cengage Learning. All rights reserved.
Discrete Mathematics and its Applications
Copyright © Cengage Learning. All rights reserved.
Algorithms Chapter 3 With Question/Answer Animations.
이산수학(Discrete Mathematics)  함수의 증가 (Growth of Functions)
Rosen 5th ed., §2.7 ~18 slides, ~1 lecture
이산수학(Discrete Mathematics)  함수의 증가 (Growth of Functions)
CS 2604 Data Structures and File Management
2.2 함수의 증가 (Growth of Functions)
이산수학(Discrete Mathematics)  함수의 증가 (Growth of Functions)
이산수학(Discrete Mathematics)  함수의 증가 (Growth of Functions)
Algorithm Course Dr. Aref Rashad
Presentation transcript:

Module #6: Orders of Growth Rosen 5th ed., §2.2 ~22 slides, ~1 lecture 2019-01-03 (c)2001-2003, Michael P. Frank

Orders of Growth (§1.8) For functions over numbers, we often need to know a rough measure of how fast a function grows. If f(x) is faster growing than g(x), then f(x) always eventually becomes larger than g(x) in the limit (for large enough values of x). Useful in engineering for showing that one design scales better or worse than another. 2019-01-03 (c)2001-2003, Michael P. Frank

Orders of Growth - Motivation Suppose you are designing a web site to process user data (e.g., financial records). Suppose database program A takes fA(n)=30n+8 microseconds to process any n records, while program B takes fB(n)=n2+1 microseconds to process the n records. Which program do you choose, knowing you’ll want to support millions of users? A 2019-01-03 (c)2001-2003, Michael P. Frank

Visualizing Orders of Growth On a graph, as you go to the right, a faster growing function eventually becomes larger... fA(n)=30n+8 Value of function  fB(n)=n2+1 Increasing n  2019-01-03 (c)2001-2003, Michael P. Frank

Concept of order of growth We say fA(n)=30n+8 is order n, or O(n). It is, at most, roughly proportional to n. fB(n)=n2+1 is order n2, or O(n2). It is roughly proportional to n2. Any O(n2) function is faster-growing than any O(n) function. For large numbers of user records, the O(n2) function will always take more time. 2019-01-03 (c)2001-2003, Michael P. Frank

Definition: O(g), at most order g Let g be any function RR. Define “at most order g”, written O(g), to be: {f:RR | c,k: x>k: f(x)  cg(x)}. “Beyond some point k, function f is at most a constant c times g (i.e., proportional to g).” “f is at most order g”, or “f is O(g)”, or “f=O(g)” all just mean that fO(g). Sometimes the phrase “at most” is omitted. 2019-01-03 (c)2001-2003, Michael P. Frank

Points about the definition Note that f is O(g) so long as any values of c and k exist that satisfy the definition. But: The particular c, k, values that make the statement true are not unique: Any larger value of c and/or k will also work. You are not required to find the smallest c and k values that work. (Indeed, in some cases, there may be no smallest values!) However, you should prove that the values you choose do work. 2019-01-03 (c)2001-2003, Michael P. Frank

“Big-O” Proof Examples Show that 30n+8 is O(n). Show c,k: n>k: 30n+8  cn. Let c=31, k=8. Assume n>k=8. Then cn = 31n = 30n + n > 30n+8, so 30n+8 < cn. Show that n2+1 is O(n2). Show c,k: n>k: n2+1  cn2. Let c=2, k=1. Assume n>1. Then cn2 = 2n2 = n2+n2 > n2+1, or n2+1< cn2. 2019-01-03 (c)2001-2003, Michael P. Frank

Big-O example, graphically Note 30n+8 isn’t less than n anywhere (n>0). It isn’t even less than 31n everywhere. But it is less than 31n everywhere to the right of n=8. cn = 31n n>k=8  30n+8 30n+8 O(n) Value of function  n Increasing n  2019-01-03 (c)2001-2003, Michael P. Frank

Useful Facts about Big O Big O, as a relation, is transitive: fO(g)  gO(h)  fO(h) O with constant multiples, roots, and logs...  f (in (1)) & constants a,bR, with b0, af, f 1-b, and (logb f)a are all O(f). Sums of functions: If gO(f) and hO(f), then g+hO(f). 2019-01-03 (c)2001-2003, Michael P. Frank

More Big-O facts c>0, O(cf)=O(f+c)=O(fc)=O(f) f1O(g1)  f2O(g2)  f1 f2 O(g1g2) f1+f2 O(g1+g2) = O(max(g1,g2)) = O(g1) if g2O(g1) (Very useful!) 2019-01-03 (c)2001-2003, Michael P. Frank

Orders of Growth (§1.8) - So Far For any g:RR, “at most order g”, O(g)  {f:RR | c,k x>k |f(x)|  |cg(x)|}. Often, one deals only with positive functions and can ignore absolute value symbols. “fO(g)” often written “f is O(g)” or “f=O(g)”. The latter form is an instance of a more general convention... 2019-01-03 (c)2001-2003, Michael P. Frank

Order-of-Growth Expressions “O(f)” when used as a term in an arithmetic expression means: “some function f such that fO(f)”. E.g.: “x2+O(x)” means “x2 plus some function that is O(x)”. Formally, you can think of any such expression as denoting a set of functions: “x2+O(x)” : {g | fO(x): g(x)= x2+f(x)} 2019-01-03 (c)2001-2003, Michael P. Frank

Order of Growth Equations Suppose E1 and E2 are order-of-growth expressions corresponding to the sets of functions S and T, respectively. Then the “equation” E1=E2 really means fS, gT : f=g or simply ST. Example: x2 + O(x) = O(x2) means fO(x): gO(x2): x2+f(x)=g(x) 2019-01-03 (c)2001-2003, Michael P. Frank

Useful Facts about Big O  f,g & constants a,bR, with b0, af = O(f); (e.g. 3x2 = O(x2)) f+O(f) = O(f); (e.g. x2+x = O(x2)) Also, if f=(1) (at least order 1), then: |f|1-b = O(f); (e.g. x1 = O(x)) (logb |f|)a = O(f). (e.g. log x = O(x)) g=O(fg) (e.g. x = O(x log x)) fg  O(g) (e.g. x log x  O(x)) a=O(f) (e.g. 3 = O(x)) 2019-01-03 (c)2001-2003, Michael P. Frank

Definition: (g), exactly order g If fO(g) and gO(f) then we say “g and f are of the same order” or “f is (exactly) order g” and write f(g). Another equivalent definition: (g)  {f:RR | c1c2k x>k: |c1g(x)||f(x)||c2g(x)| } “Everywhere beyond some point k, f(x) lies in between two multiples of g(x).” 2019-01-03 (c)2001-2003, Michael P. Frank

Rules for  Mostly like rules for O( ), except:  f,g>0 & constants a,bR, with b>0, af  (f), but  Same as with O. f  (fg) unless g=(1)  Unlike O. |f| 1-b  (f), and  Unlike with O. (logb |f|)c  (f).  Unlike with O. The functions in the latter two cases we say are strictly of lower order than (f). 2019-01-03 (c)2001-2003, Michael P. Frank

 example Determine whether: Quick solution: 2019-01-03 (c)2001-2003, Michael P. Frank

Other Order-of-Growth Relations (g) = {f | gO(f)} “The functions that are at least order g.” o(g) = {f | c>0 k x>k : |f(x)| < |cg(x)|} “The functions that are strictly lower order than g.” o(g)  O(g)  (g). (g) = {f | c>0 k x>k : |cg(x)| < |f(x)|} “The functions that are strictly higher order than g.” (g)  (g)  (g). 2019-01-03 (c)2001-2003, Michael P. Frank

Relations Between the Relations Subset relations between order-of-growth sets. RR O( f ) ( f ) • f o( f ) ( f ) ( f ) 2019-01-03 (c)2001-2003, Michael P. Frank

Why o(f)O(x)(x) A function that is O(x), but neither o(x) nor (x): 2019-01-03 (c)2001-2003, Michael P. Frank

Strict Ordering of Functions Temporarily let’s write fg to mean fo(g), f~g to mean f(g) Note that Let k>1. Then the following are true: 1  log log n  log n ~ logk n  logk n  n1/k  n  n log n  nk  kn  n!  nn … 2019-01-03 (c)2001-2003, Michael P. Frank

Review: Orders of Growth (§1.8) Definitions of order-of-growth sets, g:RR O(g)  {f |  c>0 k x>k |f(x)| < |cg(x)|} o(g)  {f | c>0 k x>k |f(x)| < |cg(x)|} (g)  {f | gO(f)} (g)  {f | go(f)} (g)  O(g)  (g) 2019-01-03 (c)2001-2003, Michael P. Frank