+ All Categories
Home > Documents > Discrete Numeric Functions

Discrete Numeric Functions

Date post: 05-Jan-2016
Category:
Upload: thora
View: 56 times
Download: 0 times
Share this document with a friend
Description:
Discrete Numeric Functions. By A . Agarkar I.T. Department, S.C.O.E., Pune. Discrete Numeric Functions. Discrete numeric functions (or numeric functions ): The functions whose domain is the set of natural numbers and whose range is the set of real numbers - PowerPoint PPT Presentation
37
DISCRETE NUMERIC FUNCTIONS By A. A. Agarkar B. I.T. Department, C. S.C.O.E., Pune
Transcript
Page 1: Discrete Numeric Functions

DISCRETE NUMERIC

FUNCTIONSBy

A. A. Agarkar

B. I.T. Department,

C. S.C.O.E., Pune

Page 2: Discrete Numeric Functions

DISCRETE NUMERIC FUNCTIONS Discrete numeric functions(or numeric

functions): The functions whose domain is the set of natural numbers and whose range is the set of real numbers

The sum of two numeric functions is a numeric function whose value at r is equal to the sum of the values of the two numeric functions at r.

The product of two numeric functions is a numeric function whose value at r is equal to the product of the values of the two numeric functions at r.

Page 3: Discrete Numeric Functions

DISCRETE NUMERIC FUNCTIONS Let a be a numeric function and α be a real

number. The numeric function αa is called a scaled version of a with scaling factor α.

We use |a| to denote a numeric function whose value at r = ar if ar 0, = -ar otherwise.

Let a be a numeric function and i a positive integer. We use Sia to denote a numeric function such that its value at r is 0 for r = 0, 1, ..., i-1 and is ar-i for r ≧ i. And we use S-ia to denote a numeric function such that its value at r is ar+i for r ≧ 0.

Page 4: Discrete Numeric Functions

DISCRETE NUMERIC FUNCTIONS The accumulated sum of a numeric function

a is a numeric function whose value at r is equal to

The forward difference of a numeric function a is a numeric function, denoted Δa, whose value at r is equal to ar+1-ar.

The backward difference of a numeric function a is a numeric function, denoted,▽a, whose value is equal to a0 at 0 and is equal to ar- ar-1 at r≧1.

r

iia

0

Page 5: Discrete Numeric Functions

DISCRETE NUMERIC FUNCTIONS Let a and b be two numeric functions.

The convolution of a and b, denoted a*b, is a numeric function such that

r

i irbiarc0

Page 6: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS Let a and b be numeric functions. We

say that a asymptotically dominates b, or b is asymptotically dominated by a, if there exist positive constants k and m such that |br| ≦ mar for r≧k.

Intuitively, that a asymptotically dominates b means that a grows faster than b. Thus, for sufficiently large r, the absolute value of br does not exceed a fixed proportion of ar.

Page 7: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS asymptotically dominance1. For any numeric function a, |a|

asymptotically dominates a.2. If b is asymptotically dominated by a, then

for any constant α,αb is also asymptotically dominated by a.

3. If b is asymptotically dominated by a, then for any integer i, Sib is asymptotically dominated by Sia.

4. If b and c are asymptotically dominated by a, then for any constant α and β, αb+βc is also asymptotically dominated by a.

Page 8: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS5. If c is asymptotically dominated by b and b is

asymptotically dominated by a, then c is asymptotically dominated by a.

6. It is possible that a asymptotically dominates b, and b also asymptotically dominates a. For example, ar = r2 + r + 1, r 0 and br = 0.05r2 - r - 9, r 0.

7. It is possible that a does not asymptotically dominate b, nor does asymptotically dominate a. For example, ar =1 if r is even and ar = 0 otherwise; br = 0 if r is even and br = 1 otherwise.

8. It is possible that a and b asymptotically dominate c, while a dose not asymptotically dominate b, nor does b asymptotically dominate a.

Page 9: Discrete Numeric Functions

ASYMPTOTIC GROWTH RATE

Three notations used to compare orders of growth of an algorithm’s basic operation count O(g(n)): class of functions f(n) that grow no faster than

g(n) Ω(g(n)): class of functions f(n) that grow at least as fast

as g(n) Θ (g(n)): class of functions f(n) that grow at same rate

as g(n)

Page 10: Discrete Numeric Functions

O-NOTATION

Page 11: Discrete Numeric Functions

O-NOTATION

Formal definition A function t(n) is said to be in O(g(n)), denoted t(n) O(g(n)), if

t(n) is bounded above by some constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some nonnegative integer n0 such that

t(n) cg(n) for all n n0

Example: 10n2 O(n2) 10n2 + 2n O(n2) 100n + 5 O(n2) 5n+20 O(n)

Page 12: Discrete Numeric Functions

-NOTATION

Page 13: Discrete Numeric Functions

-NOTATION

Formal definition A function t(n) is said to be in (g(n)), denoted t(n) (g(n)), if

t(n) is bounded below by some constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some nonnegative integer n0 such that

t(n) cg(n) for all n n0

Exercises: prove the following using the above definition 10n2 (n2) 10n2 + 2n (n2) 10n3 (n2)

Page 14: Discrete Numeric Functions

-NOTATION

Page 15: Discrete Numeric Functions

-NOTATION

Formal definition A function t(n) is said to be in (g(n)), denoted t(n) (g(n)), if

t(n) is bounded both above and below by some positive constant multiples of g(n) for all large n, i.e., if there exist some positive constant c1 and c2 and some nonnegative integer n0 such that c2 g(n) t(n) c1 g(n) for all n n0

Exercises: prove the following using the above definition 10n2 (n2) 10n2 + 2n (n2) (1/2)n(n-1) (n2)

Page 16: Discrete Numeric Functions

(g(n)), functions that grow at least as fast as g(n)

(g(n)), functions that grow at the same rate as g(n)

O(g(n)), functions that grow no faster than g(n)

g(n)

>=

<=

=

Page 17: Discrete Numeric Functions

SOME PROPERTIES OF ASYMPTOTIC ORDER OF GROWTH1. f(n) O(f(n))

2. f(n) O(g(n)) iff g(n) (f(n))

3. If f (n) O(g (n)) and g(n) O(h(n)) , then f(n) O(h(n))

Note similarity with a ≤ b

4. If f1(n) O(g1(n)) and f2(n) O(g2(n)) , then f1(n) + f2(n) O(max{g1(n), g2(n)})

The analogous assertions are true for the -notation and -notation.

Page 18: Discrete Numeric Functions

SOME PROPERTIES OF ASYMPTOTIC ORDER OF GROWTH

If f1(n) O(g1(n)) and f2(n) O(g2(n)) , then f1(n) + f2(n) O(max{g1(n), g2(n)})

Implication: The algorithm’s overall efficiency will be determined by the part with a larger order of growth. For example,

5n2 + 3nlogn O(n2)

Page 19: Discrete Numeric Functions

ORDERS OF GROWTH OF SOME IMPORTANT FUNCTIONS

All logarithmic functions loga n belong to the same class (log n) no matter what the logarithm’s base a > 1 is.

All polynomials of the same degree k belong to the same class: aknk + ak-1nk-1 + … + a0 (nk).

Exponential functions an have different orders of growth for different a’s.

order log n < order n (>0) < order an < order n! < order nn

Page 20: Discrete Numeric Functions

BASIC EFFICIENCY CLASSES

1 constant

log n logarithmic

n linear

n log n n log n

n2 quadratic

n3 cubic

2n exponential

n! factorial

fast

slow

High time efficiency

low time efficiency

The time efficiencies of a large number of algorithms fall into only a few classes.

Page 21: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS For a given discrete numeric function a, let

O(a) denote the set of all numeric functions that are asymptotically dominated by a. O(a) is read “order a” or “big-oh of a”.

asymptotically domination again1. For any numeric function a, a is O(a).2. If b is O(a),then for any constant α, αb is

also O(a).3. If b is O(a), then for any integer i, Sib is

O(Sia).4. If both b and c are O(a),then for any

constant α and β, αb+βc is also O(a).

Page 22: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS5. If c is O(b) and b is O(a),then c is O(a).6. It is possible that a is O(b),then b is also

O(a).7. It is possible that a is not O(b) and b is

not also O(a).8. It is possible that c is both O(a) and

O(b),while a is not O(b) and b is not O(a). Example : Let a = a0 + a1r + a2r2 + ... +

anrn. a = O(rn). Example : O(1) O(log r) O(r) O(ri)

O(kr) O(r!).

Page 23: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS Let A and B be two sets of numeric

functions. We define

A+B={a + b|a A, b B}

αA={αa|a A }

A˙B={ab|a A, b B}

Page 24: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS1.If b is O(a), then O(b) is a subset of

O(a). Consequently, if b is O(a) and a is O(b), then sets O(a) and O(b) are equal.

2.For any a, O(a)+ O(a)= O(a).3.If b O(a), then O(a)+ O(b)= O(a).4.For any constant α,αO(a)= O(αa)= O(a).5.For any a and b, O(a) O(b)= O(ab).

Page 25: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS Example : Let a = 3r3 + 2r2+ r. a is

O(r3) or {3r3 } + O(r2) or {3r3 + 2 r2 } + O(r).

Note that {3r3 + 2 r2 } + O(r) {3r3 } + O(r2) O(r3).

Example : Let a = r + O(1/r) and b = We have ab =

)1( rOr

)(2/3

rOr

Page 26: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS For a given numeric function a, Let Ω(a)

denote the set of all numeric functions b such that there exist positive constants k and m with|br| ≧ mar for r ≧ k.

In other words, if b is in Ω(a), then b grows at least as fast as a.

Page 27: Discrete Numeric Functions

ASYMPTOTIC BEHAVIOR OF NUMERIC FUNCTIONS For a given numeric function a, Let θ(a)

denote the set of all numeric functions b such that there exist positive constants m, m’, and k with

mar ≦ |br| ≦ m’ar for r≧ k.

In other words, if b is in θ(a), then b grows as the same rate as a.

Page 28: Discrete Numeric Functions

GENERATING FUNCTIONS

Page 29: Discrete Numeric Functions

GENERATING FUNCTIONS For a numeric function (a0, a1, a2, ..., ar, ...),

we define an infinite seriesa0 + a1z + a2z2 + ... + arzr + ...

which is called the generating function of the numeric function a.

Example: For a numeric function (30, 31, 32, ..., 3r ...), we

define an infinite series

30 + 31 z + 32 z2 + ... + 3r zr + ... =(3)0 + (3z)1 + (3z)2 + … + (3z)r +…It can be written in closed form as

1/(1-3z)

Page 30: Discrete Numeric Functions

GENERATING FUNCTIONS Let a, b, and c be a numeric

functions and A(z), B(z),and C(z) be its generating functions, respectively.

1. b = α a,B(z) = αa0 + αa1z + αa2z2 + … + αarzr + …= αA(z)

Page 31: Discrete Numeric Functions

GENERATING FUNCTIONS2. c = a + b,C(z) = (a0 + b0) + (a1+ b1)z + (a2+ b2)z2 +

…= a0 + a1z + a2z2 + … + b0 + b1z +

b2z2 + …

= A(z) + B(z)

A(z) = (2+3z-6z2) / (1-2z)= 3z + 2 / (1-2z)= 21 + (22 + 3)z + 23z2 + … + 3r+1zr

+ …

Page 32: Discrete Numeric Functions

GENERATING FUNCTIONS3. br = αr ar,

B(z) = α0a0 + α1a1z + α2arz2 + … + αrarzr

+ …= a0 + a1(αz) + a2(αz)2 + … +

ar(αz)r + …

= A(αz)

4. c = ab,C(z) = a0b0 + a1b1z + a2b2z2 + … + arbrzr

+ …

Page 33: Discrete Numeric Functions

GENERATING FUNCTIONS5. b = Sia, i ≥ 0.

B(z) = 0 + 0z + … + 0zi-1

+ a0zi + a1zi+1 + a2zi+2 + … + arzi+r + …

= ziA(z)

6. b = S-ia, i ≤ 0.B(z) = ai + ai+1z + ai+2z2 + … + ai+rzr + …

= z-i(A(z) - a0 - a1z - a2z2 - … - ai-1zi-

1)

Page 34: Discrete Numeric Functions

GENERATING FUNCTIONS7. b = Δa = S-1a - a

B(z) = (1/z) (A(z) - a0) - A(z)

orB(z) = (a1 - a0)z0 + (a2 - a1)z1 + (a3 - a2)z2 + …

= (a1 + a2z + a3z2 + …) - (a0 + a1z + a2z2 + …)

= (1/z) (A(z) - a0) - A(z)

Page 35: Discrete Numeric Functions

GENERATING FUNCTIONS8. b = ∇a

B(z) = a0z0 + (a1 - a0)z1 + (a2 - a1)z2 + …

= (a0z0 + a1z1 + … ) - (a0z1 + a1z2 + …)

= A(z) - zA(z)

Page 36: Discrete Numeric Functions

GENERATING FUNCTIONS9. c = a * b,

cr = ∑ i=0 ai br-i

r

∴C(z) = (a0+a1z+…+arzr+…)(b0+b1z+…+brzr+…)

= A(z)B(z)

Page 37: Discrete Numeric Functions

Recommended