3.2 The growth of functions Flashcards
The time required to solve a
problem depends on?
and how we can we find how time requires is affected by what it depends on?
- number of operations it uses
- The hardware and software used to run the program that implements the algorithm.
We can closely approximate the time required to solve a problem of size n by multiplying the previous time
required by a constant. For example, on a supercomputer, we might be able to solve a problem
of size n a million times faster than we can on a PC. However, this factor of one million will
not depend on n (except perhaps in some minor ways).
The growth of functions is often described using a special notation. Describe it:
Let f and g be functions from the set of integers or the set of real numbers to the set of real
numbers. We say that f(x) is O(g(x)) if there are constants C and k such that
|f(x)| ≤ C|g(x)|
whenever x > k. [This is read as “f(x) is big-oh of g(x).”]
Remark: Intuitively, the definition that f(x) is O(g(x)) says that f(x) grows slower than some
fixed multiple of g(x) as x grows without bound.
What are the constants C and k in the definition of big-O notation :
and their need in Big O:
They are witnesses to the relationship f(x) is O(g(x)).
To establish that f(x) is O(g(x)) we need only one pair of witnesses to
this relationship. That is, to show that f(x) is O(g(x)), we need find only one pair of constants C Assessment and k, the witnesses, such that |f(x)| ≤ C|g(x)| whenever x > k.
How many pair of witnesses to the relationship f(x) is O(g(x))?
Note that when there is one pair of witnesses to the relationship f(x) is O(g(x)), there are
infinitely many pairs of witnesses. To see this, note that if C and k are one pair of witnesses,
then any pair C′ and k′, where C < C′ and k < k′, is also a pair of witnesses, because
|f(x)| ≤ C|g(x)| ≤ C′|g(x)| whenever x > k′ > k
Big-O symbol is also called :
The big-O symbol is sometimes called
a Landau symbol after the German mathematician Edmund Landau.
WORKING WITH THE DEFINITION OF BIG-O NOTATION:
A useful approach for finding a pair of witnesses is to first select a value of k for which the size of |f(x)| can be readily
estimated when x > k and to see whether we can use this estimate to find a value of C for which
|f(x)| ≤ C|g(x)| for x > k.
See the figure 2, 220 page.
When are 2 functions of Same Order?
Note that in Example 1 we have two functions, f(x) = x2 + 2x + 1 and g(x) = x2, such that f(x) is O(g(x)) and g(x) is O(f(x))—the latter fact following from the inequality x2 ≤ x2 + 2x + 1, which holds for all nonnegative real numbers x. We say that two functions f(x) and g(x) that satisfy both of these big-O relationships are of the same order
Represent f(x) is O(g(x)) in math symbols:
The fact that f(x) is O(g(x)) is sometimes written f(x) = O(g(x)). However, the equals
sign in this notation does not represent a genuine equality. Rather, this notation tells us that an
inequality holds relating the values of the functions f and g for sufficiently large numbers in the
domains of these functions. However, it is acceptable to write f(x) ∈ O(g(x)) because O(g(x))
represents the set of functions that are O(g(x)).
When f(x) is O(g(x)), and h(x) is a function that has larger absolute values than g(x)
What are we allowed with Big O notation.
When f(x) is O(g(x)), and h(x) is a function that has larger absolute values than g(x) does
for sufficiently large values of x, it follows that f(x) is O(h(x)). In other words, the function g(x)
in the relationship f(x) is O(g(x)) can be replaced by a function with larger absolute values. To
see this, note that if
| f(x)| ≤ C|g(x)| if x > k,
and if |h(x)| > |g(x)| for all x > k, then
| f(x)| ≤ C|h(x)| if x > k.
Hence, f(x) is O(h(x))
How to chose g function in Big O notation:
When big-O notation is used, the function g in the relationship f(x) is O(g(x)) is often chosen
to have the smallest growth rate of the functions belonging to a set of reference functions, such
as functions of the form xn, where n is a positive real number
how big-O notation is used to estimate the growth of functions?
Example 2 illustrates how big-O notation is used to estimate the growth of functions
Illustrate how to show that a big-O relationship does not hold:
Show that n2 is not O(n).
To show that n2 is not O(n), we must show that no pair of witnesses C and k exist such
that n2 ≤ Cn whenever n > k. We will use a proof by contradiction to show this.
Suppose that there are constants C and k for which n2 ≤ Cn whenever n > k. Observe that
when n > 0 we can divide both sides of the inequality n2 ≤ Cn by n to obtain the equivalent
inequality n ≤ C. However, no matter what C and k are, the inequality n ≤ C cannot hold for
all n with n > k. In particular, once we set a value of k, we see that when n is larger than the
maximum of k and C, it is not true that n ≤ C even though n > k. This contradiction shows that
n2 is not O(n).
Polynomials can often be used to estimate the growth of functions. Instead of analyzing the
growth of polynomials each time they occur, we would like a result that can always be used
to estimate the growth of a polynomial. Theorem?
Prove it:
Let f(x) = anx^n + an−1x^(n−1) + ⋯ + a1x + a0, where a0, a1, … , an−1, an are real numbers. Then f(x) is O(x^n).
It shows that the leading term of a polynomial dominates its growth by asserting that a polynomial of degree n or less is O(xn).
Give big-O estimates for the factorial function and the logarithm of the factorial function,
A big-O estimate for n! can be obtained by noting that each term in the product does
not exceed n. Hence,
n! = 1 ⋅ 2 ⋅ 3 ⋅⋯⋅ n
≤ n ⋅ n ⋅ n ⋅⋯⋅ n
= nn.
This inequality shows that n! is O(nn), taking C = 1 and k = 1 as witnesses. Taking logarithms
of both sides of the inequality established for n!, we obtain
log n! ≤ log nn = n log n.
This implies that log n! is O(n log n), again taking C = 1 and k = 1 as witnesses.
Frequently used functions in order:
1, log n, n, n log n, n2, 2n, n!
Using calculus it can be shown that each function in the list is smaller than the succeeding
function, in the sense that the ratio of a function and the succeeding function tends to zero as n
grows without bound.
Fig Page 223.
DOUBT:
using a scale for the values
of the functions that doubles for each successive marking on the graph. That is, the vertical scale
in this graph is logarithmic.