You are on page 1of 8

1

Function
(Govt. Jahanzeb College Saidu, (Discrete Maths)(By M. Iqbal Associate Prof.))

One of the most important concepts in mathematics is that of a function. The terms “map,”
“mapping,” “transformation,” and many others mean the same thing; the choice of which word
to use in a given situation is usually determined by tradition and the mathematical background of
the person using the term.

Function

Suppose we have two sets A and B such that to each element of a set A we assign a unique
element of a set B; the collection of such assignments is called a function from A into B. The set
A is called the domain of the function, and the set B is called the target set or codomain. Let f
denote a function from A into B. Then we write

f :A→B

which is read: “ f is a function from A into B,” or “ f takes (or maps) A into B.” If a ∈ A, then f (a)
(read: “ f of a”) denotes the unique element of B which f assigns to a; it is called the image of a
under f , or the value of f at a and a is a preimage of b. The set of all images of elements of A is
called the range of f . The image of f : A → B is denoted by Ran( f ), Im( f ) or f (A).
Frequently, a function can be expressed by means of a mathematical formula. For example,
consider the function which sends each real number into its square. We may describe this function
by writing f (x) = x2 or x 7−→ x2 or y = x2 . In the first notation, x is called a variable and the letter
f denotes the function. In the second notation, the barred arrow 7−→ is read “goes into.” In the
last notation, x is called the independent variable and y is called the dependent variable since the
value of y will depend on the value of x.
Example 1: (a) Consider the function f (x) = x3 , i.e. f assigns to each real number its cube.
Then the image of 2 is 8, and so we may write f (2) = 8.
(b) Figure 1 defines a function f from A = {a, b, c, d} into B = {r, s,t, u} in the obvious way. Here
f (a) = s, f (b) = u, f (c) = r, f (d) = s. The image of f is the set of image values, {r, s, u}. Note
that t does not belong to the image of f because t is not the image of any element under f .
Functions as Relations: A function f : A → B can also be defined in terms of a relation from A to
B. Recall that a relation from A to B is just a subset of A × B. A relation f from A to B (called the
graph of f ) that contains one, and only one, ordered pair (a, b) for every element a ∈ A, defines a
function f from A to B. This function is defined by the assignment f (a) = b, where (a, b) is the
unique ordered pair in the relation that has a as its first element.
The graph of f is defined by

Graph of f = {(a, b)|a ∈ A, f (a) = b}

From the definition, the graph of a function f from A to B is the subset o f A × B containing the
2

ordered pairs with the second entry equal to the element of B assigned by f to the first entry.
When we define a function we specify its domain, its codomain, and the mapping of elements of
the domain to elements in the codomain.
Two functions are equal when they have the same domain, have the same codomain, and map
elements of their common domain to the same elements in their common codomain. Note that if
we change either the domain or the codomain of a function, then we obtain a different function. If
we change the mapping of elements, then we also obtain a different function. Thus two functions
f : A → B and g : A → B are defined to be equal, written f = g, if f (a) = g(a) for every a ∈ A;
that is, if they have the same graph. Accordingly, we do not distinguish between a function and
its graph. Now, such a graph relation has the property that each a in A belongs to a unique ordered
pair (a, b) in the relation. On the other hand, any relation f from A to B that has this property
gives rise to a function f : A → B, where f (a) = b for each (a, b) in f . Consequently, one may
equivalently define a function as follows:
Definition: A function f : A → B is a relation from A to B (i.e. a subset of A × B) such that each
a ∈ A belongs to a unique ordered pair (a, b) in f .
Example: (a) Let f : A → B be the function defined in Example 1 (b). Then the graph of f is

{(a, s), (b, u), (c, r), (d, s)}

(b) Consider the following three relations on the set A = {1, 2, 3}:
f ={(1, 3), (2, 3), (3, 1)},
g = {(1, 2), (3, 1)},
h = {(1, 3), (2, 1), (1, 2), (3, 1)}
f is a function from A into A since each member of A appears as the first coordinate in exactly
one ordered pair in f ; here f (1) = 3, f (2) = 3 and f (3) = 1. g is not a function from A into A
since 2 ∈ A is not the first coordinate of any pair in g and so g does not assign any image to 2.
Also h is not a function from A into A since 1 ∈ A appears as the first coordinate of two distinct
ordered pairs in h, (1, 3) and (1, 2). If h is to be a function it cannot assign both 3 and 2 to the
element 1 ∈ A.
Q. Let W = {a, b, c, d}. Decide whether each set of ordered pairs is a function from W into W.
(a) {(b, a), (c, d), (d, a), (c, d)(a, d)}
(b) {(d, d), (c, a), (a, b), (d, b)}
(c) {(a, b), (b, b), (c, d), (d, b)}
(d) {(a, a), (b, a), (a, b), (c, d)}
Remark: Whenever a function is given by a formula in terms of a variable x, we assume, unless
it is otherwise stated, that the domain of the function is R (or the largest subset of R for which
the formula has meaning) and the codomain is R.
Q. Find the domain D of each of the following real-valued functions of a real variable:
1 2
(a) f (x) =x−2 (b) f (x) = x − 3x − 4

(c) f (x) = 25 − x2 (d) x2 where 0 ≤ x ≤ 2
3

Sol. When a real-valued function of a real variable is given by a formula f (x), then the domain
D consists of the largest subset of R for which f (x) has meaning and is real, unless otherwise
specified.
(a) f is not defined for x − 2 = 0, i.e., for x = 2; hence D = R\{2}.
(b) f is defined for every real number; hence D = R.
(c) f is not defined when 25 − x2 is negative; hence D = [−5, 5] = {x | − 5 ≤ x ≤ 5}.
(d) Here, the domain of f is explicitly given as D = {x | 0 ≤ x ≤ 2}.
Q. For any n ∈ N, let Dn = (0, n1 ), the open interval from 0 to 1n . Find:
(a) D3 ∪ D4 (b) D3 ∩ D20 (c) Ds ∩ Dt (d) Ds ∪ Dt .
1 1
Sol. (a) Since (0, 3) is a superset of (0, 4 ), so D3 ∪ D4 = D3 .
1 1
(b) Since (0, 20 ) is a subset of (0, 3 ), so D3 ∩ D20 = D20 .
(c) Let m = min(s, t), that is, the smaller of the two numbers s and t; then Dm is equal to Ds or Dt
contains the other as a subset. Hence Ds ∩ Dt = Dm .
(d) Let M = max(s, t), that is, the larger of the two numbers s and t; then Ds ∪ Dt = DM .
Q. For each n ∈ N, let Dn = {n, 2n, 3n, ...} = {multiples of n}.
D12 (iv) D3 ∪ D12 .
T T T
(a) Find: (i) D2 D7 (ii) D6 D8 (iii) D3
Definition. Let A be any set. The function from A into A which assigns to each element in A the
element itself is called the identity function on A and it is usually denoted by IA , or simply I. In
other words, for every a ∈ A,

IA (a) = a or I(a) = a.

Definition. Suppose S is a subset of A, that is, suppose S ⊆ A. The inclusion map or embedding
of S into A, denoted by i : S → A is the function such that, for every x ∈ S,

i(x) = x

Definition. The restriction of any function f : A → B, denoted by f |S is the function from S into
B such that, for any x ∈ S,

f |S(x) = f (x)

Definition: Some functions never assign the same value to two different domain elements.
A function f : A → B is said to be one-to-one (written 1 − 1) or injective if different elements in
the domain A have distinct images. Another way of saying the same thing is that f is said to be
one-to-one or injective, if and only if f (a) = f (b) implies that a = b for all a and b in the domain
of f .
Example. Determine whether the function f (x) = x2 from the set of integers to the set of integers
is one-to-one or not.
Sol: The function f (x) = x2 is not one-to-one because, for instance, f (1) = 1 = f (−1), but
1 6= −1.
Example. Determine whether the function f (x) = x + 1 from the set of real numbers to itself is
one-to-one.
4

Sol: The function f (x) = x + 1 is a one-to-one function. To demonstrate this, note that
x + 1 6= y + 1 when x 6= y.
Q. Determine if each function is one-to-one.
(a) To each person on the earth assign the number which corresponds to his age.
(b) To each book written by only one author assign the author.
(c) To each country in the world which has a prime minister assign its prime minister.
Q. Determine whether each of these functions from {a, b, c, d} to itself is one-to-one.
(a) f (a) = b, f (b) = a, f (c) = c, f (d) = d
(b) f (a) = b, f (b) = b, f (c) = d, f (d) = c
(c) f (a) = d, f (b) = b, f (c) = c, f (d) = d.
Definition: A function f : A → B is said to be an onto function or surjective function if each
element of B is the image of some element of A. In other words, f : A → B is onto if the image
of f is the entire codomain, i.e., if f (A) = B. In such a case we say that f is a function from A
onto B or that f maps A onto B.
Q. Give an example of a function that is
(a) one-to-one but not onto.
(b) onto but not one-to-one.
(c) both onto and one-to-one (but different from the identity function).
(d) neither one-to-one nor onto.
Definition: If f : A → B is one-to-one and onto, then f is called a bijective function or one-to-
one correspondence between A and B. This terminology comes from the fact that each element
of A will then correspond to a unique element of B and vice versa.
Q. Detennine whether each of these functions is a bijection from R to R.
(a) f (x) = −3x + 4 (b) f (x) = −3x2 + 7 (c) f (x) = 2x + 1 (d) f (x) = x2 + 1 (e) f (x) = x3
Q. Let functions f , g, h from V = {1, 2, 3, 4} into V be defined by: f (n) = 6 − n, g(n) = 3,
h = {(1, 2), (2, 3), (3, 4), (4, 1)}. Decide which functions are:
(a) one-to-one (b) onto(c) both (d) neither. ! !
1 2 3 4 5 6 1 2 3 4 5 6
Q. Consider permutations α = and β = in S6 .
2 5 6 1 3 4 6 4 3 1 2 5
Find: (a) α ◦ β (b) β ◦ α (c) α 2 (d) α −1 (e) β −1
Definition: A function f : A → B is invertible if its inverse relation f −1 is a function from B
to A. In general, the inverse relation f −1 may not be a function. The following theorem gives
simple criteria which tells us when it is.
Theorem: A function f : A → B is invertible if and only if f is both one-to-one and onto.
Example. Let f : Z → Z be such that f (x) = x + 1. Is f invertible, and if it is, what is its inverse?
Sol: The function f has an inverse because it is a one-to-one correspondence, as we have shown.
To reverse the correspondence, suppose that y is the image of x, so that y = x + 1. Then x = y − 1.
This means that y − 1 is the unique element of Z that is sent to y by f . Consequently, f −1 (y) =
y − 1.
5

Q. Let f : R → R be defined by f (x) = 3x−7. Find a formula for the inverse function f −1 : R → R.
Example. Let f be the function from R to R with f (x) = x2 . Is f invertible?
Sol: Because f (−2) = f (2) = 4, f is not one-to-one. If an inverse function were defined, it would
have to assign two elements to 4. Hence, f is not invertible.
Definition. Two real-valued functions with the same domain can be added and multiplied. Let f1
and f2 be functions from A to R. Then f1 + f2 and f1 f2 are also functions from A to R defined by

( f1 + f2 )(x) = f1 (x) + f2 (x) and ( f1 f2 )(x) = f1 (x) f2 (x)

Note that the functions f1 + f2 and f1 f2 have been defined by specifying their values at x in terms
of the values of f1 and f2 at x.
Example. Let f1 and f2 be functions from R to R such that f1 (x) = x2 and f2 (x) = x − x2 . What
are the functions f1 + f2 and f1 f2 ?
Sol: From the definition of the sum and product of functions, it follows that

( f1 + f2 )(x) = f1 (x) + f2 (x) = x2 + x − x2 = x

and ( f1 f2 )(x) = f1 (x) f2 (x) = x2 (x − x2 ) = x3 − x4 .

Q. Find f + g and f g, where f (x) = x2 + 1 and g(x) = x + 2, are functions from R to R.


Definition. Let f be a function from the set A to the set B and let g be a function from the
set B to the set C . The composition of the functions g and f , denoted by go f , is defined by
(go f )(a) = g( f (a)). In other words, go f is the function that assigns to the element a of A the
element assigned by g to f (a). That is, to find (go f )(a) we first apply the function f to a to
obtain f (a) and then we apply the function g to the result f (a) to obtain (go f )(a) = g( f (a)).
Example. Let f(x)=2x+1 and g(x)=3x+2. Find f og and go f .
Solution: Both the compositions f og and go f are defined. Moreover,
( f og)(x) = f (g(x)) = f (3x + 2) = 2(3x + 2) + 1 = 6x + 5
and (go f )(x) = g( f (x)) = g(2x + 1) = 3(2x + 1) + 2 = 6x + 5.
Note that here ( f og)(x) = (go f )(x).
Example. Let f and g be the defined by f (x) = 2x + 1 and g(x) = 3x2 . Find f og and go f ?
Sol: ( f og)(x) = f (g(x)) = f (3x2 ) = 2(3x2 ) + 1 = 6x2 + 1
and (go f )(x) = g( f (x)) = g(2x + 1) = 3(2x + 1)2 = 3(4x2 + 4x + 1) = 12x2 + 12x + 3.
Note that ( f og)(x) 6= (go f )(x). Thus in general f og 6= go f .
Q. Find f og and go f , where f (x) = x2 + 1 and g(x) = x + 2 are functions from R to R.
Q. Let f and g be the functions from the set of integers to the set of integers defined by
f (x) = 2x + 3 and g(x) = 3x + 2. Find the composition f og and go f ?
Q. Let V = {1, 2, 3, 4}. For the following functions f : V → V and g : V → V , find:
(a) f ◦ g (b) g ◦ f (c) f ◦ f where
f = {(1, 3), (2, 1), (3, 4), (4, 3)} and g = {(1, 2), (2, 3), (3, 1), (4, 1)}
6

Recursively defined function

A function is said to be recursively defined if the function definition refers to itself. In order for
the definition not to be circular, the function definition must have the following two properties:
(1) There must be certain arguments, called base values, for which the function does not refer to
itself.
(2) Each time the function does refer to itself, the argument of the function must be closer to a
base value.
A recursive function with these two properties is said to be well-defined. The following examples
should help clarify these ideas.
Factorial Function: The product of the positive integers from 1 to n, inclusive, is called “n
factorial” and is usually denoted by n!. That is,

n! = n(n − 1)(n − 2) · · · 3 · 2 · 1

It is also convenient to define 0! = 1, so that the function is defined for all nonnegative integers.
Thus:
0! = 1, 1! = 1, 2! = 2 · 1 = 2, 3! = 3 · 2 · 1 = 6, 4! = 4 · 3 · 2 · 1 = 24, 5! = 5 · 4 · 3 · 2 · 1 = 120,
6! = 6 · 5 · 4 · 3 · 2 · 1 = 720, And so on. Observe that 5! = 5 · 4! = 5 · 24 = 120 and 6! = 6 · 5! =
6 · 120 = 720. This is true for every positive integer n; that is,

n! = n · (n − 1)!

Accordingly, the factorial function may also be defined as follows:


Definition (Factorial Function): (a) If n = 0, then n! = 1.
(b) If n > 0, then n! = n · (n − 1)!
Observe that the above definition of n! is recursive, since it refers to itself when it uses (n − 1)!.
However:
(1) The value of n! is explicitly given when n = 0 (thus 0 is a base value).
(2) The value of n! for arbitrary n is defined in terms of a smaller value of n which is closer to
the base value 0. Accordingly, the definition is not circular, or, in other words, the function is
well-defined.
6! 30!
Q. Find: (a) 3! + 4! (b) 3!(3! + 2!) (c) 5! (d) 28! .
Fibonacci Sequence: The Fibonacci sequence (usually denoted by F0 , F1 , F2 , ...) is as follows:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

That is, F0 = 0 and F1 = 1 and each succeeding term is the sum of the two preceding terms. For
example, the next two terms of the sequence are 34 + 55 = 89 and 55 + 89 = 144
A formal definition of this function follows:
Definition (Fibonacci Sequence): (a) If n = 0, or n = 1, then Fn = n.
(b) If n > 1, then Fn = Fn−2 + Fn−1 .
This is another example of a recursive definition, since the definition refers to itself when it uses
7

Fn−2 and Fn−1 However:


(1) The base values are 0 and 1.
(2) The value of Fn is defined in terms of smaller values of n which are closer to the base values.
Accordingly, this function is well-defined.
Q. Let a and
 b be positive integers, and suppose Q is defined recursively as follows:
 0 if a < b
Q(a, b) =
 Q(a−b, b) + 1 if a ≥ b
Find: (a) Q(2, 5), Q(12, 5). (b) Q(5, 7), Q(7, 5), Q(20, 5) , Q(20, 7).
Sol. (a) Q(2, 5) = 0 since 2 < 5.
Q(12, 5) = Q(7, 5) + 1 = [Q(2, 5) + 1] + 1 = Q(2, 5) + 2 = 0 + 2 = 2.
(b) Do by same manner.
Q. Let a and
 b be integers. Find Q(2, 7), Q(5, 3) and Q(15, 2), where Q(a, b) is defined by:
 5 if a < b
Q(a, b) =
 Q(a−b, b + 2) + a if a ≥ b

Floor and Ceiling Functions

Let x be any real number. Then x lies between two integers called the floor and the ceiling of x.
Specifically,
bxc, called the floor of x, denotes the greatest integer that does not exceed x.
dxe, called the ceiling of x, denotes the least integer that is not less than x.
If x is itself an integer, then bxcj= dxe; otherwise bxc + 1 = dxe.
√ k
5 = 2, 12 = 0, − 12 = −1,
   
Example. b3.1c = 3, b7c = 7,
l√ m
5 = 3, 21 = 1, − 21 = 0,
   
d3.1e = 4, d7e = 7,
 1  1   1
= 2 + 1 = 23 = 2,
    1  5   1   3 
2+ 2 2· 2 = 2 · 3 = 2 = 1.
Q. Find: (a)b13.2c, b−0.17c, b34c, d13.2e, d−0.17e, d34e.
(b) 12 + 21 ,
     1  1   1   1  1   1   1  1   1  1
+ 12 ,

2 + 2 , 2 + 2 +2 , 2 + 2 +2 , 2 + 2
 1   1  1   1  5   1  5 
2 + 2 +2 , 2· 2 , 2· 2 .
Q. Draw the graph of floor and ceiling function, i.e. bxc and dxe.
Q. Prove or disprove that dx + ye = dxe + dye for all real numbers x and y.
Sol: Although this statement may appear reasonable, it is false. A counterexample is supplied by
x = 12 and y = 12 . With these values we find that 21 + 21 = d1e = 1, but 12 + 21 = 1 + 1 = 2.
     

Thus 12 + 12 6= 21 + 12
     

Similarly by taking x = 12 and y = 32 . We find that 21 + 23 = d2e = 2, but 21 + 32 = 1 + 2 = 3.


     

Thus 21 + 32 6= 21 + 32
     

Q. Prove or disprove that bx + yc = bxc + byc for all real numbers x and y.
Sol. A counterexample is supplied by x = 12 and y = 23 . With these values we find that
1 3

2 + 2 =
b2c = 2, but 12 + 32 = 0 + 1 = 1. Thus 21 + 32 6= 12 + 32 .
         

Q. Let n be an integer. Find L(1), L(13), L(20), L(21) and L(25) where L is defined by:
8

 0 if n = 1
L(n) =  n 
 L
2+ 1 if n > 1
Sol. L(1) = 0L(13) = L 13 + 1 = L (b6.5c) + 1 = L (6) + 1 = L 26 + 1 + 1 = L (b3c) + 2 =
   
2
L (3) + 2 = L 23 + 3 = L (1) + 3 = 0 + 3 = 3. Do the other on similar way.
 

Q. Let nbe an integer. Find L(1), L(13), L(20), L(21) and L(25) where L is defined by:
 0 if n = 1
L(n) =
 L n + 1 if n > 1
 
2

Integer and Absolute Value Functions

Let x be any real number. The integer value of x, written INT (x), converts x into an integer by
deleting (truncating) the fractional part of the number. Thus

INT (3.14) = 3, INT ( 5) = 2, INT (−8.5) = −8, INT (7) = 7

Observe that INT (x) = bxc or INT (x) = dxe according to whether x is positive or negative.
The absolute value of the real number x, written ABS(x) or |x|, is defined as the greater of x or
−x. Hence ABS(0) = 0, and, for x = 0, ABS(x) = x or ABS(x) = −x, depending on whether x is
positive or negative. Thus

| − 15| = 15, |7| = 7, | − 3.33| = 3.33, |4.44| = 4.44, | − 0.075| = 0.075

We note that |x| = | − x| and, for x 6= 0, |x| is positive.

You might also like