You are on page 1of 40

Functions and Matrices

Discrete Mathematics
Functions
• The concept of a function is extremely important in mathematics and
computer science.
• Functions are also used to represent how long it takes a computer to
solve problems of a given size.
• In discrete mathematics functions are used in the definition of such
discrete structures as sequences and strings.
• Functions are sometimes also called mappings or transformations.
FUNCTION
A function is a relation that assigns each y-value with only one x-
value.
So, in order for the relation to be considered a function, there
cannot be any repeated values in the domain.

There are two ways to see if a relation is a function:


• Vertical Line Test
• Mappings
Vertical Line Test
In order to use the vertical line test,
must plot the points on a coordinate plane
first. It uses a vertical straightedge to see if
the relation is a function.
If a vertical line can be drawn
through each of data points, and each line
passes through exactly one point, then the
relation is a function.
Vertical Line Test
Vertical Line Test
Mappings
If the relation is not graphed, it is easier to use mapping,
• Draw two ovals in creating a mapping of a relation
• In one oval, list all the domain values
• In the other oval, list all the range values
• Draw a line connecting the pair of domain and range values
• If any domain value ‘maps’ to two different range values, the relation
is not a function
Mapping: Each x-value maps to only one y-value

Steps:
• Draw two ovals
• List domain
• List range
• Draw lines to connect

This is a function!
Mapping: Two x-values go to the same y-value

Notice that even


though there are two 2’s
in the range, the 2 is only
listed once

• This is still a function!


Mapping: One x-value maps to two y-values

This relation is not


a function because the -4
maps to the -1 and 0.

It is not a function
if one x-value maps to
two different y-values.
Functions
• If f:A→B, and f(a)=b then:
A is the domain of f.
B is the codomain of f.
b is the image of a under f
a is a pre-image of b under f
Function
Function
What are the functions f1 + f2 and f1f2?
Where: f1(x) = x2 and f2(x) = x − x2
( f1 + f2)(x) = f1(x) + f2(x)
= x2 + (x − x2 )
=x
and
( f1 f2)(x) = x2 (x − x2 )
= x3 − x4
Functions
One-to-One Function
• A function is one-to-one if each element in the co-domain has unique
pre-image
• A function f from A to B is called one-to-one if whenever f(a)=f(b) then
a=b. No element of B is the image of more than one element in A.
• In one-to-one function, given any y there is only one x that can be
paired with the given y
Functions
Examples of one-to-one functions
1. f(x) = x3
2. f(x) = 3x + 5
3. f(x) = sqrt(x)
Functions
Onto Function
• A function is onto if each element in the co-domain is an image of
some pre-image
• A function f:A→B is subjective (onto) if the image of f equals its range
• A function f from A to B is called onto if all b in B there is an a in A
such that f(a)=b. All elements in B are used.
Functions
Example of onto functions
1. f(x) = x-2
2. f(x) = 3x – 4
Functions
Bijective function
• Functions can be both one-to-one and onto
• A function f is a one-to-one correspondence or a bijection, or
reversible or invertible, if it is both one-to-one and onto
Functions
Example of bijective function
1. f:R→R defined by f(x)=2x-3
2. f(x) = x5
3. f(x) = x3
Functions
Inverse of a function
• Given any function, f, the inverse of the function f-1, is a relation that
is formed by interchanging each (x,y) of f to a (y,x) of f-1
• The function g would be denoted as f-1 and read as “f inverse”
Functions
• Let f be defined as the set of values given

• Let f-1 be defined as the set of values given


Functions
Functions
The graphs of functions
• Let f be a function from set A to the set B. The graph of the function is
the set of ordered {(a,b) | a Є A and f(a)=b}
• For example graph of x2
Functions
Floor function
• The floor function assigns to the real number x the largest integer
that is less than or equal to x. The value of the floor function at x is
denoted by └x┘
Functions
Example: Floor function, the largest integer ≤ x
1. └2.3┘ = 2
2. └2 ┘ = 2
3. └0.5┘ = 0
Functions
Ceiling function
• The ceiling function assigns to the real number x, the smallest integer
that is greater than or equal to x
• The value of the ceiling function at x is denoted by ┌x┐
Functions
Example: Ceiling function, the smallest integer ≥ x
1. ┌2.3┐ = 3
2. ┌2┐ = 2
3. ┌0.5┐ = 1
Matrix
• A matrix is a rectangular array of numbers.
• A matrix with m rows and n columns is called an m × n matrix.
• The plural of matrix is matrices.
• A matrix with the same number of rows as columns is called square.
• Two matrices are equal if they have the same number of rows and the
same number of columns and the corresponding entries in every
position are equal.
Matrix
• Row matrix – a matrix having only one row is called as row matrix or
row vector

• Column matrix – a matrix having only one column is called as column


matrix or column vector

• Square matrix – a matrix which number of rows and columns are


equal
Matrix
• Zero matrix – a matrix each of whose elements is zero, and also called
as null matrix

• Diagonal matrix – a square matrix with its all non diagonal elements
as zero

• Scalar matrix – it’s a diagonal matrix whose all elements are equal
Matrix
• Unit matrix – a scalar matrix whose all diagonal elements are equal to
unity, and also called as identity matrix

• Triangular matrix – if every element above or below the diagonal is


zero
Matrix
• Addition and subtraction
– two matrices may be
added or subtracted if
they are the same order
• Simply add or subtract
the corresponding
elements
Activity
Find A+B and A-B:
1.

2.
Matrix
Multiplication: Multiply a matrix by a single number.
Matrix
Multiplication: Multiply a matrix by another matrix.
Matrix
Multiplication: Multiply a matrix by another matrix.
Matrix
Multiplication: Multiply a matrix by another matrix.
Matrix
Multiplication: Multiplying a 1x3 by a 3x1
Matrix
Multiplication: Multiplying a 3x1 by a 1x3
Activity
The local shop sells 3 types of pies.
• Apple pies cost $3 each
• Cherry pies cost $4 each
• Blueberry pies cost $2 each
And this is how many they sold in 4 days:

You might also like