Efficiency of Algorithms - H-SC
Download
Report
Transcript Efficiency of Algorithms - H-SC
Real-Valued Functions
of a Real Variable and
Their Graphs
Lecture 43
Section 9.1
Wed, Apr 18, 2007
Functions
We will consider real-valued functions that
are of interest in studying the efficiency of
algorithms.
Power functions
Logarithmic functions
Exponential functions
Power Functions
A power function is a function of the form
f(x) = xa
for some real number a.
We are interested in power functions where
a 0.
The Constant Function f(x) =
1
2
1.5
1
0.5
2
4
6
8
10
The Linear Function f(x) = x
10
8
6
4
2
2
4
6
8
10
The Quadratic Function f(x)
= x2
100
80
60
40
20
2
4
6
8
10
The Cubic Function f(x) = x3
600
500
400
300
200
100
2
4
6
8
10
Power Functions xa, a 1
The higher the power of x, the faster the
function grows.
xa
grows faster than xb if a > b.
The Square-Root Function
3
2.5
2
1.5
1
0.5
2
4
6
8
10
The Cube-Root Function
2
1.5
1
0.5
2
4
6
8
10
The Fourth-Root Function
1.75
1.5
1.25
1
0.75
0.5
0.25
2
4
6
8
10
Power Functions xa, 0 < a <
1
The lower the power of x (i.e., the higher
the root), the more slowly the function
grows.
xa
grows more slowly than xb if a < b.
This is the same rule as before, stated in
the inverse.
Power Functions
x3
4
x2
3
x
2
1
x
0.5
1
1.5
2
Multiples of Functions
15
x2
12.5
10
3x
2x
7.5
x
5
2.5
1
2
3
4
Multiples of Functions
Notice that x2 eventually exceeds any
constant multiple of x.
Generally, if f(x) grows faster than cg(x), for
any real number c, then f(x) grows
“significantly” faster than g(x).
In other words, we think of g(x) and cg(x)
as growing at “about the same rate.”
Logarithmic Functions
A logarithmic function is a function of the
form
f(x) = logb x
where b > 1.
The function logb x may be computed as
(ln x)/(ln b).
The Logarithmic Function
f(x) = log2 x
6
4
2
10
-2
20
30
40
50
60
Growth of the Logarithmic
Function
The logarithmic functions grow more and
more slowly as x gets larger and larger.
f(x) = log2 x vs. g(x) = x1/n
x1/2
log2 x
4
x1/3
2
5
-2
10
15
20
25
30
Logarithmic Functions vs.
Power Functions
The logarithmic functions grow more slowly
than any power function xa, 0 < a < 1.
f(x) = x vs. g(x) = x log2 x
x log2 x
4
3
x
2
1
0.5
1
1.5
2
2.5
3
f(x) vs. f(x) log2 x
The growth rate of log x is between the
growth rates of 1 and x.
Therefore, the growth rate of f(x) log x is
between the growth rates of f(x) and x f(x).
f(x) vs. f(x) log2 x
x2 log2 x
50
x2
40
x log2 x
30
20
x
10
2
4
6
8
Multiplication of Functions
If f(x) grows faster than g(x), then f(x)h(x)
grows faster than g(x)h(x), for all positivevalued functions h(x).
If f(x) grows faster than g(x), and g(x)
grows faster than h(x), then f(x) grows
faster than h(x).
Exponential Functions
An exponential function is a function of the
form
f(x) = ax,
where a > 0.
We are interested in power functions where
a 1.
The Exponential Function
f(x) = 2x
15
12.5
10
7.5
5
2.5
1
2
3
4
The Exponential Function
f(x) = 2x
4x
80
3x
60
40
2x
20
1
2
3
4
Growth of the Exponential
Function
The larger the base, the faster the function
grows
ax grows faster then bx, if a > b > 1.
f(x) = 2x vs. Power Functions
(Small Values of x)
5
4
3
2x
2
1
0.5
1
1.5
2
f(x) = 2x vs. Power Functions
(Large Values of x)
3500
2x
3000
2500
x3
2000
1500
1000
500
5
10
15
20
Growth of the Exponential
Function
Every exponential function grows faster
than every power function.
ax grows faster than xb, for all a > 1, b > 0.
Rates of Growth of
Functions
The first derivative of a function gives its
rate of change, or rate of growth.
Rates of Growth of Power
Functions
is increasing, if a 1,
d a
a 1
x ax is constant,if a 1,
dx
is decreasing, if 0 a 1.
Rates of Growth of
Logarithmic Functions
d
1
log b x
is decreasing , if b 1.
dx
x ln b
Rates of Growth of
Exponential Functions
d x
a a x ln a
dx