Lecture 03- Functions
Lecture 03- Functions
BSc(Software Engineering)
Geethika Senarathne
Functions
Functions
A function is defined as a relation between a set of inputs having
one output each.
Simply a function is a relationship between inputs where each input is
related to exactly one output.
The general representation of a function is y = f(x).
2
Function name 𝑓 𝑥 =𝑥 What to output
Input
Example
Eg:
f(x) = x2 + x -1
X Y
f(0) = 0 + 0 -1 = -1
f(1) = 1 + 1 -1 = 1
f(2) = 2 + 2 – 1 = 3 0 -1
F(3) = 9 + 3 – 1 =11
1 1
2 3
3 11
Special Rules for Function
• It must work for every possible input value. (Every element in X is
related to some element in Y. But some elements of Y might not
be related to at all, which is fine.)
• And it has only one relationship for each input value. (It will not
give back 2 or more results for the same input.)
Exercise
1. Which of the following relations are functions? Find the domain and range
of the function.
a) 𝑦 = 𝑥2 + 4
b) 𝑥 = 𝑦2 − 3
c) 𝑦 = |𝑥 + 3|
d) 𝑦 = 𝑥3 − 7
e) F(x) = 3x2 – 1
2. Given f(x) = 2x - 1, what is f(5)?
3. Given f(x) = 3x2 - 6, what is f(4)?
4. Given f(x) = |𝑥 - 8|, what is f(2)?
Exercise
5. Draw the graph for the following functions.
a) 𝑦 = 2x+1
b) 𝑦 = 𝑥2 -1
c) 𝑦 = |𝑥 + 3|
Terms Related to Function
If x=3 : f(𝑥) = 3 + 3 = 6
If x=0: f(𝑥) = 0 + 3 = 3
If x=-3: f(x) = −3 + 3 = 0
If x=-4: f(x) = −4 + 3 = −1
The numbers less than 3 will result in the square root of a negative
number, which is an imaginary number.
Domain : x≥ -3
Example 02
What is the range of the function 𝑓(𝑥) = 2𝑥2 + 3?
The range is all possible y-values for the function. The y-values will begin
at three and increase infinitely.
Range : y ≥ 3
Exercise
1. What is the domain of the following functions?
a) b) c)
a) b)
Types of Function - Based on
Mapping
Types of Functions
▪ Injective Function
Injective function is defined by f: A → B such that every element of
set A is connected to a distinct element in set B. Injective function is
also called an one-to-one function. Here every element of the
domain has a distinct image or co-domain element for the given
function. But there can be B without a matching with A.
Types of Functions
▪ Surjective Function
Every codomain element is related to the domain element. No
element of codomain is left without being mapped. For a function
defined by f: A → B, such that every element in set B has a pre-
image in set A.
Types of Functions
▪ Bijective Function
A function that is both a Injective and Subjective function is called a
Bijective function. Here every element of the domain is connected to
a distinct element in the codomain and every element of the
codomain has a pre-image. Also in other words every element of set
A is connected to a distinct element in set B, and there is not a single
element in set B which has been left out.
Exercise
1. Which of the following relations are functions? Find the domain and range
of the function.
a) f = {(1, 3), (1, 5), (2, 3), (2, 5)}
b) f = {(1, 1), (5, 5), (8, 8), (3, 3),(6,6)}
c) f(x) = 2x +1
d) f = {(2, 1), (5, 1), (8, 1), (11, 1)}
e) F(x) = 3x2 – 1
2. Check whether the following functions are injective, subjective or bijective.
a) If A = {1, 5, 8, 9} and B {2, 4} And f={(1, 2), (5, 4), (8, 2), (9, 4)}.
b) If A = {1, 2, 3} and B = {a, b, c, d} and f = {(1, a),(2, b),(3, c)}
c) If A = {5,6,7,8} and B = {1,3,5} and f = {(5,3),(6,1),(7,3),(8,5)}
Types of Function - Based on
Degree
▪ Identity Function
The identity function has the same domain and range.
The identity function equation is f(x) = x, or y = x.
Its ordered pairs are of the form {(1, 1), (2, 2), (3, 3), (4, 4).....(n, n)}.
The graph of the identity function is a straight line that is equally
inclined to the coordinate axes and is passing through the origin.
▪ Constant Function
A constant function is an important form of a many-to-one function.
In a constant function, all the domain elements have a single image.
The constant function is of the form f(x) = K, where K is a real
number. For the different values of the domain (x value), the same
range value of K is obtained for a constant function.
▪ Linear Function
The domain and range of a linear function is the set of all real
numbers, and it has a straight-line graph.
Eg: y = x + 2, y = 3x, y = 2x – 1
The identity function of y = x can also be considered a linear function.
Graphically the linear function can be represented by the equation of
a line y = mx + c,
where m is the slope of the line and c is the y-intercept of the line.
▪ Quadratic Function
A quadratic function has a second-degree quadratic equation and it
has a graph in the form of a curve. The general form of the quadratic
function is
f(x) = ax2 + bx + c, where a ≠ 0 and a, b, c are constant and x is a
variable.
▪ Cubic Function
A cubic function has an equation of degree three. The general form
of a cubic function is
f(x) = ax3 + bx2 + cx + d, where a ≠ 0 and a, b, c, and d are real
numbers & x is a variable.
The graph of a cubic function is more curved than the quadratic
function. An example of a cubic function is f(x) = 8x3 + 5x2 + 3.
▪ Polynomial Function
The general form of a polynomial function is
f(x) = anxn + an-1xn-1 + ..... ax + b.
Here n is a nonnegative integer and x is a variable.
Based on the highest power (exponent) of the polynomial function,
the functions can be classified as a quadratic function, cubic function,
etc.
Inverse Functions
An inverse function or an anti function is defined as a function, which
can reverse into another function.
f(x) = y = 2x + 3
x= y-3
2
f-1 = y-3
2
Example
Let f(x) = x2 + 1. Find f-1(10).
Let f-1(10) = x.
⇒ f(x) = 10
⇒ x2 + 1 = 10
⇒ x = ±3