0% found this document useful (0 votes)
9 views

Ex 2.3 Functions

Uploaded by

hafsa mubeen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Ex 2.3 Functions

Uploaded by

hafsa mubeen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Discrete Structures

Sec 2.3 Functions


Function
7
● DEFINITION: Let A and B to be nonempty sets. A
function f from A to B is an assignment of exactly one
element of B to each element of A. We write f(a) = b
if b is the unique element of B assigned by the
function f to the element a of A. If f is a function from
A to B, we write f: A → B.
●Functions are sometimes
also called mappings or
transformations.
Not Function
Functions
•If f:AB, we say that A is the domain of f and B is the codomain of f.

•If f(a) = b, we say that b is the image of a and a is the pre-image of b.

•The range of f:AB is the set of all images of elements of A.

•We say that f:AB maps A to B.


Functions
• What are the domain, codomain, and range of the function that assigns
grades to students
Solution:
domain: {Adams, Chou, Goodfriend, Rodriguez, Stevens}
codomain: {A, B, C, D, F}
range: {A, B, C, F}
Functions
•If the domain of our function f is large, it is convenient to
specify f with a formula, e.g.:

•f:RR
•f(x) = 2x

•This leads to:


•f(1) = 2
•f(3) = 6
•f(-3) = -6
•…
Functions

•f:ZZ
•f(x) = x2
Example
• What is the domain and codomain of the function
int floor(float real){…}?
Solution:
domain: the set of real numbers
codomain: the set of integer numbers
Functions
DEFINITION 2
If f is a function from A to B, we say that A is the domain of f and B is the
codomain of f. If f(a) = b, we say that b is the image of a and a is a preimage
of b. The range of f is the set of all images of elements of A. Also, if f is a
function from A to B, we say that f maps A to B.

• 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 and codomain, and
map elements of their common domain to the same elements in their
common codomain. If we change either the domain or the codomain of a
function, we obtain a different function. If we change the mapping of
elements, we also obtain a different function.
Functions
DEFINITION 3
If 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)
(f1 f2 ) (x) = f1(x) f2 (x)
Example
• 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 ?
Solution:
(f1 + f2 )(x) = f1(x) + f2 (x) = x2 + (x – x2) = x
(f1 f2 ) (x) = f1(x) f2 (x) = x2(x – x2) = x3 – x4
Example
•f1(x) = 3x, f2(x) = x + 5
•(f1 + f2)(x) = f1(x) + f2(x) = 3x + x + 5 = 4x + 5
•(f1f2)(x) = f1(x) f2(x) = 3x (x + 5) = 3x2 + 15x
Functions
•Let us look at the following well-known function:

•What is the image of S = {1, 5} ?


•f(S) = {a, b}

•What is the image of S = {1, 8} ?


•f(S) = {b}
One-to-One Functions
DEFINITION 5
A function 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. A function is said to be an injection
if it is one-to-one.

• ab(a ≠ b → f(a) ≠ f(b)) (If it’s a different element, it


should map to a different value.)
Example
• Determine whether the function f from {a,b,c,d} to {1,2,3,4,5} with
f(a) = 4, f(b) = 5, f(c) = 1 and f(d) = 3 is one-to-one.
a 1
b 2
c 3
d 4
5

Solution: Yes.
Example
•f:RR
•f(x) = 3x
•One-to-one ?
Onto Functions
DEFINITION 7
A function f from A to B is called onto, or surjective, if and only
if for every element b B there is an element a A with f(a) =
b. A function f is called a surjection if it is onto.

● A function f is onto if ∀y∃x(f (x) = y),


where the domain for x is the domain of
the function and the domain for y is the
codomain of the function.
Example

• Let f be the function from {a,b,c,d} to {1,2,3} defined


by f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3. Is f an onto
function?
a 1
b 2
c 3
d
Solution: Yes.
Functions
DEFINITION 8
The function f is a one-to-one correspondence or a bijection, if
it is both one-to-one and onto.
a. One-to-one, b. Onto, c. One-to-one, d. neither d. Not a
Not onto not one-to-one and onto function
a 1 a a 1 a 1 1
b 2 b 1 b 2 b 2 a 2
c 3 c 2 c 3 c 3 b 3
4 d 3 d 4 d 4 c 4
Bijective Function
• Let f : Z → Z be such that f (x) = x + 1. Is f is bijection or one-to-one
correspondence.
Inversion

•An interesting property of


bijections is that they have an
inverse function.

•The inverse function of the


bijection f:AB is the function f-
1
:BA with
•f-1(b) = a whenever f(a) = b.
Inversion

Example: The inverse function f-1 is


given by:
f-1(A) = 1
f(1) = A f-1(B) = 2
f(2) = B f-1(H) = 3
f(3) = H f-1(L) = 4
f(4) = L f-1(N) = 5
f(5) =N Inversion is only possible for
bijections
Clearly, f is bijective. (= invertible functions)
Composition
DEFINITION 1
Let g be a function from the set A to the set B and let f be
a function from the set B to the set C. The composition of
the functions f and g , denoted by f ᵒ g , is defined by
(f ᵒ g) (a)= f(g(a))
This means that
• first, function g is applied to element aA, mapping
it onto an element of B,
• then, function f is applied to this element of B,
mapping it onto an element of C.
• Therefore, the composite function maps from A to C.
Example

•f(x) = 7x – 4, g(x) = 3x,


•f:RR, g:RR

•(fg)(5) = f(g(5)) = f(15) = 105 – 4 = 101


Graphs

•The graph of a function f:AB is the set of ordered


pairs {(a, b) | aA and f(a) = b}.

•The graph is a subset of


AB that can be used to
visualize f in a two-
dimensional coordinate
system.
Floor and Ceiling Functions

•The floor and ceiling functions map the real numbers


onto the integers (RZ).

•The floor function assigns to rR the largest zZ with z


 r, denoted by r.

•Examples: 2.3 = 2, 2 = 2, 0.5 = 0, -3.5 = -4

•The ceiling function assigns to rR the smallest zZ


with z  r, denoted by r.

•Examples: 2.3 = 3, 2 = 2, 0.5 = 1, -3.5 = -3

You might also like