math tutorial lecture 2 some of these slides are courtesy of d. plaisted, unc and m. nicolescu, unr

33
Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Upload: alexandra-collins

Post on 17-Jan-2018

230 views

Category:

Documents


0 download

DESCRIPTION

Easy enough to calculate: a b = a × a × a … × a So there are ‘b’ lots of ‘a’ What is 4 3? 4 × 4 × 4 = 64 Exponentials – A quick explanation b

TRANSCRIPT

Page 1: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Math Tutorial

Lecture 2

Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Page 2: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Exponentials – What are they?

• Simply: a number (base) raised to a power (exponent).

Page 3: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

• Simply: a number (base) raised to a power (exponent).

• Easy enough to calculate:

• ab = a × a × a … × a • So there are ‘b’ lots of ‘a’• What is 43?

• 4 × 4 × 4 = 64

Exponentials – A quick explanation

b

Page 4: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Exponentials in Computer Science

• Have you ever noticed the following numbers popping up in your computer science studies?

• 1, 2, 4, 8, 16, 32, 64, 128…1024…• What do they all have in common?• They are all powers of 2!!

Page 5: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Exponentials in Computer Science

• The powers of 2 should be (very) familiar to you by now.

• All the computers you have been using work in binary bits (at the lowest level)…

• 2 values: 0/1, true/false etc• all ‘data sizes’ must be expressed in powers of

2.

Page 6: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Exponentials in Computer Science

• 1 kilobyte ≠ 1000 bytes (‘standard’ use of kilo)• 1 kilobyte = 1024 bytes• Because…• 29 = 512• 210 = 1024• 211 = 2048• So 210 is the closest we can get to 1000

Page 7: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Working with Exponentials

• First, some easy exponentials to remember:

• a0 = 1

• a1 = a

Page 8: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Exponentials

• Useful Identities:

nmnm

mnnm

aaa

aaa

a

)(

11

Page 9: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms

• This is because log(arithm)s are just ‘reversed’ exponentials

• E.g. if 24 = 16• log216 = 4

– base is 2• Logarithms ‘map’ large numbers onto smaller

numbers

Page 10: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms - Bases

• There are several common bases:– 10: very common base, Richter scale etc.– e: used by a lot of scientists– 2: very common in computer science. WHY?

Page 11: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms – An example

• Imagine US open: 8 players left.• It is a knockout tournament, so every time that 2 players

play the losing player is eliminated from the tournament and the winning plays goes on to the next round.

• How many rounds must be played to determine an overall winner?

Page 12: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms – An example

• Imagine US open: 8 players left.• It is a knockout tournament, so every time that 2 players

play the losing player is eliminated from the tournament and the winning plays goes on to the next round.

• How many rounds must be played to determine an overall winner?

• What stage: semi-final? quarterfinal? 1/8? 1/16?

Page 13: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms – An example

Round 0: 8 players

Round 1: 4 players

Round 2: 2 players

Round 3: 1 player

3 rounds needed!

Page 14: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms – Example explained

• 3 rounds are needed to determine the winner of 8 teams, competing 2 at a time (i.e. one-on-one)

• This can be easily calculated using logs.• 2 teams play at a time, so the base is 2. (i.e. 2x = 8, so

we need to use log2)• So, log2 8 = ….• 3

Page 15: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms• In algorithm analysis we often use the notation

“log n” without specifying the base

nnnn

eloglnloglg 2

yxlog

Binary logarithm

Natural logarithm )log(logloglog)(loglog

nnnn kk

xy logxylog yx loglog

yxlog yx loglog

xalog xb ba loglog

abx logxba log

Page 16: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Logarithms and exponentials – Bases

• If the base of a logarithm is changed from one constant to another, the value is altered by a constant factor.– Ex: log10 n * log210 = log2 n.– Base of logarithm is not an issue in asymptotic notation.

• Exponentials with different bases differ by a exponential factor (not a constant factor).– Ex: 2n = (2/3)n*3n.

Page 17: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Some Simple Summation Formulas• Arithmetic series:

• Geometric series:

– Special case: x < 1:

• Harmonic series:

• Other important formulas:

2)1( nn

n

k

nk1

...21

1111

xxxn

nn

k

k xxxx ...1 2

0

x11

0k

kx

nln

n

k nk1

1...2111

n

k

k1

lg nn lg

1

11

pn

p

n

k

pppp nk1

...21

Page 18: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Limit• Def (informal): a limit is the intended height of a function

x

f(x)

3

x

g(x)4

Page 19: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Parabola• Different x values have different height (f(x) value)• Function changes its height for x within the x domain

f(x) = x2

f(1) = 1

f(2) = 4

4)(2lim

xfx

f(x)

When x is getting close to the value of 2the function f(x) getting close to 4

Page 20: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

x

f(x)

2

-2 2)(lim00

2282*62)2(

286)(

2

2

2

xf

f

xxxxf

x

f(2) is not defined but limit for f(2) exists

Limit: Formal Definition

Karl Weierstrass formally defined a limit as follows (epsilon-delta definition):

Let f be a real-valued function defined on an open interval of real numbers containing c (except possibly at c) and let L be a real number. Then

means that

for each real ε > 0 there exists a real δ > 0 such that for all x with 0 < |x − c| < δ, we have |f(x) − L| < ε.

Lxfcx

)(lim

Page 21: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

c

xc

Whenever a point x is within δ units of c, f(x) is within ε units of L

Page 22: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

When does a Limit Exist?

)(lim)(lim)(lim222

xfxfifexistsxfxxx

x

f(x)

2

Right-hand limit(limit from above)

Left-hand limit(limit from below)

5.1)(lim

3)(lim

2

2

xf

xf

x

x

Page 23: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

x

f(x)

2

x

f(x)

2

Limit does not exist for x=2, but exists for other x’s (for example, for x=1)

Limit exists for x=2 even if f(x) is not defined for x=2

Page 24: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

How to Find/Evaluate a Limit. 1

• Substitution

31

30*210)(lim

321)(

2

0

2

xf

xxxf

x

Page 25: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

How to Find/Evaluate a Limit. 2

• Factoring

242)(lim

42

)2)(4(2

86)(

2

2

xf

xxxx

xxxxf

x

Page 26: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

How to Find/Evaluate a Limit. 3

• Conjugate method

81

41lim)(lim

)4(*)16(16

44*

164)(

?)(lim16

4)(

1616

16

xxf

xxx

xx

xxxf

xfxxxf

xx

x

Page 27: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Limits and Infinity (lim and ∞)

)(lim

)(lim

4

4

xf

xf

x

x

Non-zero number divided by 0 vertical asymptote

Asymptote cannot be reached

Page 28: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Limits and Infinity (lim and ∞)

)(lim

)(lim

4

4

xf

xf

x

x

Non-zero number divided by 0 vertical asymptote

Asymptote cannot be reached

x=-4 is a vertical asymptote

Page 29: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Limits and Infinity (lim and ∞)

3)(lim

3)(lim

xf

xf

x

x

y=3 is a horizontal asymptote

Page 30: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Limit at ∞• x is getting infinitely large limit at ∞• To calculate a limit at infinity, compare the degrees in the top and

bottom of the fraction (in general case, the top and the bottom of the fraction)

277534)(

276542)(

276544)(

)()()(

3

23

35

23

2

23

xxxxxf

xxxxxxf

xxxxxf

xbxaxf

74)(lim

0)(lim

)(lim

xf

xf

xf

x

x

x

Degree a(x) > degree b(x) There is no horizontal asymptote

Degree a(x) < degree b(x) Horizontal asymptote: y=0

Compare the degree of the nominator a(x) and the degree of the denominator b(x)

Degree a(x) = degree b(x).The ratio of the coefficiencies of the highest terms

Page 31: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

Limit and ∞• Limit equals ∞ function increases infinitely (∞ is not

number)• Vertical asymptote• Horizontal asymptote• L’Hopital’s Rule

Page 32: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

32

Monotonicity

• f(n) is – monotonically increasing if m n f(m) f(n).– monotonically decreasing if m n f(m) f(n).– strictly increasing if m < n f(m) < f(n).– strictly decreasing if m > n f(m) > f(n).

Page 33: Math Tutorial Lecture 2 Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR

33

Exponentials

• Useful Identities:

• Exponentials and polynomials

nmnm

mnnm

aaa

aaa

a

)(

11

)(

0lim

nb

n

b

n

aonan