Chapter 6 General Functions and Growth Functions

Similar presentations


Presentation on theme: "Chapter 6 General Functions and Growth Functions"— Presentation transcript:

1 Chapter 6 General Functions and Growth Functions
Discrete Mathematics: A Concept-based Approach

2 Introduction Every relation involves sets and combination of the elements of the sets. One can map the elements of one set to the other. This mapping is also called function. All the functions are relations, but every relation is not a function. In general every program is viewed as a function. Input to the program is a set and output of the program as another set. In mathematics, a function is considered a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly one output. Discrete Mathematics: A Concept-based Approach

3 In modern mathematics, a function is defined by its set of inputs, called the domain of the function and a set of the outputs, called co-domain or range of the function. The pictorial representation of a set of all pairs of inputs and outputs is called its graph. In case of the function f(x) = x2, the domain and co domain are the real numbers, and the ordered pairs are of the form (x, x2). The function notation is also used in non-numeral situations, as given in the following illustrations (i) and (ii). i) Consider a set of employees in a firm. Now, we shall associate each employee of a firm to the salary obtained. This association is denoted by the function f. If x- denotes an employee, then f(x) denotes the salary obtained by the employee. Discrete Mathematics: A Concept-based Approach

4 ii) Consider an electronics experiment to study the effect of temperature on a semiconductor, whose resistance decreases as temperature increases. Let x denote the temperature T and the resistance denotes the value of the function f(x). The resistance depends on temperature. iii) Consider a mechanical engineering experiment of load and bending moment of a metal rod. Let x denote load applied (w) and f(x) denotes bending moment , ( L/12 is constant for given set), where bending depends on the load applied. Discrete Mathematics: A Concept-based Approach

5 f = { (p, a) (q, a) (q, b) (r, b) }.
Example : Consider the sets A = {1, 2, 3, 4, 5} , B = { a, b, c, d, e }. Whether f is a function? f = { (1,a), (2,b), (3,b), (4,c), (5,c) } Solution: 1- is associated with a, 2- is associated with b, 3- associated with b, 4- is associated with c, 5- is associated with d. It is also denoted as f(1)= a, f(2) = b, f(3) = b, f(4) = c, f(5) = d. In this process, it should be noted that every element of A – is associated with a unique element of B and all elements of A are used. Hence it is a function. Example : Consider the sets A = {p, q, r}, and B = {a, b }. Let R be the relation from A to B. The function f is given as f = { (p, a) (q, a) (q, b) (r, b) }. Whether R – is a valid function from A to B? Solution: The function f = { (p, a), (q, a), (q, b),(r, b)}. The element q of A is related to two different elements a and b, of B, Hence, f is not a function. Discrete Mathematics: A Concept-based Approach

6 Different Types of Functions:
The functions are classified into two groups, namely, Algebraic functions and Transcendental functions. Algebraic functions: It consists of a finite number of terms, which contains integral or fractional powers of the independent variable (argument) x. The function is operated by the four basic arithmetic operators +, -, x, and ÷. A few sub-classes of algebraic functions are as follows. i)Polynomial function ii) Rational function iii)Absolute value function iv) Exponential Function Discrete Mathematics: A Concept-based Approach

7 Transcendental function: A function which is not algebraic is called a transcendental function. Trigonometric functions, inverse trigonometric functions, logarithmic functions, hyperbolic functions and inverse hyperbolic functions come under this category. Hashing functions: In computer science, we store large number of data and yet provide random access to data. The computer can retrieve a specific record without reading other records first. The computer can identify the memory locations of records in the form of non-negative integers and are called keys. A transformation that maps the set of keys to a set of addresses (of memory cells) is called a hashing function. Discrete Mathematics: A Concept-based Approach

8 Into function: A function f: A →B is called an into function, if some elements of co-domain are not images under the function f, as shown in Fig Let the sets be A= { 1,2,3,4,5} and: B= {a, b, c, d, e}. The function is defined as under f(1) = a, f(2) = b, f(3) = b, f(4) = c , and f(5) = d Discrete Mathematics: A Concept-based Approach

9 Onto function: A function f: A →B is called an onto function, if all the elements of Co-domain are images under the function. Consider the relation on the two sets A = { 1, 2, 3, 4, 5 } and, B = {a, b, c, d}, is as shown in Fig. Discrete Mathematics: A Concept-based Approach

10 A function f: A →B is called a one-one function, if
different elements of domain have different images. That is x1 ≠ x2 , => f(x1) ≠ f(x2). The one-to-one function is also called Injective function. It is to note that if there exist more than one member of A, say x1 , x2 such that x1 = x2, then we have f(x1) = f(x2). Example : Consider the function y = x2 with the domain as the set of real numbers. Show that the function is not one-one. Solution: Consider x1=1 and x2 = -1. It is clear that x1 ≠ x2, but f(x1) = f(x2)=1. Therefore, the function is not one-to-one. Discrete Mathematics: A Concept-based Approach

11 One-One and onto: A function f: A →B is said to be one-to-one and onto, if it is both one-one and onto function. It is also called Bijective function. Inverse function: The inverse of a function exists only if the function is bijective, also called one-one and onto. If f: A →B is a bijection, then the inverse function exists f-1: A →B. It is also true that the inverse of every element of B is a single element of A. f-1: A →B. is also a bijection. Discrete Mathematics: A Concept-based Approach

12 The function f: A →B is defined by f(1) = a, f(2) = b,
f(3) = c f(4)=d, and A = { 1,2,3,4 } , B= { a, b, c, d }. The inverse Function f-1: A →B is defined by f-1(a) = 1, f-1(b) = 2, f-1(c) = 3, and f-1(d) = 4. The inverse of the function exists, which is shown in Fig. Discrete Mathematics: A Concept-based Approach

13 Example :As a simple example, if f converts a temperature in degrees Celsius C to degrees Fahrenheit F, the function converting degrees Fahrenheit to degrees Celsius would be a suitable f −1. . It’s inverse function converts degree Fahrenheit to Degree Celsius. Then its inverse function converts degrees Fahrenheit to degree Celsius. Since For every C. Such an inverse function exists if and only if f is bijective Discrete Mathematics: A Concept-based Approach

14 B, C and the functions f: A →B and g: B →C The composition or product
Composite functions: It is also called function of a function. Consider three non-empty sets A, B, C and the functions f: A →B and g: B →C The composition or product of these functions is defined as the function (g ◦ f ). g ◦ f : A →C with (g ◦ f)(x) = g[ f(x)] , for all x A. Discrete Mathematics: A Concept-based Approach

15 A composite function g(f(x)) can be visualized as the combination of two "machines". The first takes input x and outputs f(x). The second takes f(x) and outputs g(f(x)). The composition of two functions takes the output of one function as the input to the second function. More specifically, the composition of f with a function g: B→ C is the function. defined by Discrete Mathematics: A Concept-based Approach

16 Illustration: If f and g are treated as relations, then the composition of f and g denoted by and the composition of the functions g and f is denoted by Suppose that a airplanes elevation at time t is given by the function h(t), and that the oxygen concentration at elevation x is given by the function c(x). then describes the oxygen concentration around the plane at time t. Discrete Mathematics: A Concept-based Approach

17 In science, engineering and technology, one frequently
Growth functions In science, engineering and technology, one frequently comes across the asymptotic behavior of functions. It is necessary to estimate the growth of a function in terms of another, usually simpler function and also the limiting behavior of a function, when argument tends towards a particular value or infinity. Discrete Mathematics: A Concept-based Approach

18 Big-O notation: Big-O notation, also called upper bound, is a member of a larger family of notations called Landau notation or Bachmann–Landau notation, named after Edmund Landau and Paul Bachmann or asymptotic notation. In computer science. Big-O notation is used to classify algorithms based on how they respond to the changes in the input size. The algorithms are analyzed in terms of processing time or working space requirements. In analytic number theory, it is used to estimate the "error committed", while replacing the asymptotic size or asymptotic mean size of an arithmetic function, by the value, or the mean value. Discrete Mathematics: A Concept-based Approach

19 Big-O notation is also used to estimate the growth of a function in terms of another, usually simpler, function. The functions used in the estimation often include, log(n), n, n log(n), n2, 2n, and n!. In computer science, it is useful in the analysis of the complexity of algorithms, the number of effective operations an algorithm uses as its input grows. In mathematics, it is used to characterize the residual term of a truncated infinite series, especially an asymptotic series. Discrete Mathematics: A Concept-based Approach

20 Definition: A function f(x) is said to be of the order O(g(x)) if and only if there exists constants C and k, such that for every In principle, O(g(x)) is a set defined accordingly. From theoretical point of view, we the following subset relation Discrete Mathematics: A Concept-based Approach

21 Example 6.31 Give a big–O estimate for these functions. i) 3n + n3+4
ii) n + 3n2. iii)Log10 2n n2. Solution: a) Since 3n + n3 +4 ≤ 3n3 +n3 +4 n3 = 8 n3 for n>1. Therefore, 3n+ n3 + 4 = O (n3) b) We have n ≤ n + n n= n .n = n2 Hence, n + 3 n2 ≤ n2 +3n2 = 4 n2 . Discrete Mathematics: A Concept-based Approach

22 c) Discrete Mathematics: A Concept-based Approach

23 Other notations: There are other notations used in the analysis of algorithms, namely, big omega (Ω) and big-theta (Θ). The Ω indicates lower bound and Θ indicates tight bound. Ω-notation: Just same as O-notation, it provides an asymptotic upper bound on a function. Ω -notation gives an asymptotic lower bound. For a given function g(n), we denote by Ω(g(n)). Ω(g(n))= {f(n): there exists positive constants C and k such that 0≤Cg(n)≤f(n), for all n>k }. In other words, a function is of order Ω(g(n)) if and only if there exists a constant (C > 0) and a constant k, such that for every (n > k), Big-theta (Θ) notation: For any two functions f(n) and g(n), we have f(n) = Θ(g(n)) if f(n) = O(g(n)) and f(n) = Ω(g(n)). Discrete Mathematics: A Concept-based Approach

24 The following fig gives the graphical representations of the aforesaid different notations.
Discrete Mathematics: A Concept-based Approach

25 Applications While studying the complexity of an algorithm, we are Concerned with the increase in the number of operations required by the algorithm as the size of the data Increases. We then try to Compare the values of this function, for large n, to the values of some known function, such as a power function, exponential function, or logarithm function. Thus, the growth of functions refers to the relative size of the values of two functions for large values of the independent variable. Discrete Mathematics: A Concept-based Approach

26 That is, we are concerned with how the running time of an algorithm increases with the size of the input in the limit, as the size of the input increases without bound. Usually, an algorithm that is asymptotically more efficient will be the best choice for all but very small inputs. This is one area wherein experience with the concept of a limit from calculus is of great help. Most algebra and calculus texts use log x to denote log10 x (or, perhaps, loge x), but in computer science base 2 is used more prevalently. So we shall use log x to denote log2 x. Discrete Mathematics: A Concept-based Approach

27 Efficiency considerations
Sorting Sorting is an important concept in computer science. It provides a systematic arrangement of elements in a given record or a file. Telephone directory is an example of sorted data and it is called lexicographic ordering, which is one way of alphabetical ordering. Efficiency considerations Many well established sorting methods are available in the literature. The important fact is that the programmer must be able to identify the several interconnected and sometimes conflicting efficiency considerations to make the best choice of sorting techniques. The most important considerations are listed under. Time spent by programmer in coding a particular program. The amount of machine time required for running the program The amount of space required for the program. Discrete Mathematics: A Concept-based Approach

28 Total number of comparisons
Selection sort The technique consists of selecting a data element and placing it in proper position and repeating the same till all the data elements get placed in their respective positions except the last one. The last data element gets automatically placed when the remaining (n – 1) data elements are placed in order. The initial n-element priority queue is reduced by one element after each selection. The entire array is sorted after n-1 iterations. The first pass makes (n – 1) comparisons, the second pass makes (n – 2) comparisons and so on. Total number of comparisons It is of the order O(n2). The method is faster than the bubble sort. A little additional storage is required. There is no improvement if the input data is completely sorted or unsorted. Discrete Mathematics: A Concept-based Approach

29 Summary Every function is a relation but vice versa need not be true. Every program is given concept to be function. Computer science applications in terms of growth functions are given with fair examples. The analysis of algorithms is dealt with examples on sorting of data. The content of this chapter serves as basics to the course on analysis and design of algorithms Discrete Mathematics: A Concept-based Approach


Download ppt "Chapter 6 General Functions and Growth Functions"

Similar presentations


Ads by Google