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

Topic 4 Functions

Uploaded by

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

Topic 4 Functions

Uploaded by

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

BACHELOR OF BUSINESS COMPUTING

BUC1114: COMPUTING MATHEMATICS


Topic 4: Functions
Topic Objectives
The objectives of this topic include:

1. Understand the concept of functions and their properties.


2. Explore the concepts of domain and range and their significance.
3. Differentiate between one-to-one and onto functions.
4. Introduce the concept of function inverses and composition.
5. Explore the concept of one-to-one correspondence and cardinality of
sets.
6. Describe applications of functions in Computing
Learning outcomes:
By the end of this lecture, students should be able to:

1. Define a function, domain and range, inverse of a function, one-to-one


and onto functions one-to-one correspondence
2. Identify the domain and range of a function and restrictions on domain.
3. Recognize various types of functions.
4. Understand the conditions for a function to have an inverse.
5. Explore composition of functions.
6. Understand the concept of cardinality.
7. Describe applications of functions in computing

Topic Outline:

i. Functions;
ii. Domain and Range
iii. One-to-One and Onto Functions
iv. Inverses and Composition of functions
v. One-to-One Correspondence and Cardinality
vi. Applications of Functions in Computing

Timings:

Total hours: 4 hours

i. Lectures: 2 hours
ii. Tutorials: 2 hours

Private Study: 3 hours


Functions:
A function is a relation between a set of inputs (called the domain) and a set
of possible outputs (called the codomain) with the property that each input is
related to exactly one output. In other words, a function assigns each
element of the domain to exactly one element of the codomain.
Example: Consider a function f:R→R defined by f(x)=2x+1. Here, the domain
is all real numbers, and the codomain is also all real numbers. For any real
number x, the function assigns the value 2x+1.
Domain and Range:
 Domain: The set of all possible input values for which a function is
defined. It is often denoted as dom(f).
Example: For f(x)=√ x, the domain is dom(f)=[0,∞) because the square root
of a negative number is not defined in real numbers.
 Range: The set of all possible output values that a function can
produce. It is often denoted as range(f).
Example: For f(x)=x2, the range is range(f)=[0,∞) because any real number
squared is non-negative.
One-to-One (Injective) and Onto (Surjective):
 One-to-One (Injective): A function where each distinct element in
the domain maps to a distinct element in the codomain. No two
different inputs produce the same output.
Example: The function f(x)=3x is injective because if f(x1)=f(x2), then x1=x2.
 Onto (Surjective): A function where every element in the codomain
is mapped to by at least one element in the domain. The range is equal
to the codomain.
Example: The function g(x)=ex is surjective because every positive real
number is obtained as g(x) for some x.
Inverses and Composition:
 Inverse Function: If a function f:A→B is one-to-one, it has an inverse
function f−1:B→A, such that f(f−1(x))=x for all x in the range of f and
f−1(f(x))=x for all x in the domain of f−1.
Example: If f(x)=2x, then f−1(x)=x/2.
 Composition of Functions: Given two functions f:A→B and g:B→C,
the composition of g and f, denoted by g∘f, is a new function from A to
C defined by (g∘f)(x)=g(f(x)).
Example: If f(x)=2x and g(x)=x2, then (g∘f)(x)=g(f(x))=(2x)2=4x2.
One-to-One Correspondence and Cardinality:
 One-to-One Correspondence: Two sets have a one-to-one
correspondence if there exists a bijective function between them. In
other words, each element in one set corresponds to exactly one
element in the other set.
Example: The set of natural numbers has a one-to-one correspondence with
the set of even natural numbers via the function f(x)=2x.
 Cardinality of a Set: The cardinality of a set is the measure of the
"number of elements" in the set. If two sets have the same cardinality,
they are said to be equipollent.
Example: The sets A={1,2,3} and B={a,b,c} have the same cardinality (3),
and there exists a one-to-one correspondence between them (e.g.,
f(1)=a,f(2)=b,f(3)=c).
Applications of Functions in Computing
1. Input Validation:
 Functions are commonly used to validate input data. For example, a
function can check whether a user-provided email address is in the
correct format or if a password meets the required complexity criteria.
 Example: A function validateEmail(email) might return true if the
email is valid and false otherwise.
2. Data Transformation and Processing:
 Functions are used to transform and process data. They take input
data, perform operations, and produce output data.
 Example: A function encryptData(data, key) might take some data
and a cryptographic key, perform encryption, and return the encrypted
data.
3. Signal Processing:
 In audio and image processing, functions are used to manipulate
signals. Operations like filtering, compression, and enhancement are
often implemented using functions.
 Example: A function applyFilter(signal, filter) might apply a specific
filter to an audio signal.
4. Graphics and Visualization:
 Functions play a crucial role in computer graphics and visualization.
They are used to represent shapes, colors, and transformations.
 Example: A function drawCircle(center, radius) might be used to
draw a circle on a computer screen.
5. Sorting and Searching:
 Functions are employed in algorithms for sorting and searching data.
Sorting functions arrange data in a specified order, and searching
functions find specific elements efficiently.
 Example: The quicksort algorithm utilizes a partitioning function to sort
an array.
6. Mathematical Modeling:
 Functions are used to model real-world phenomena in computational
simulations. They help represent relationships between different
variables.
 Example: A function simulatePopulationGrowth(time) might model
the growth of a population over time based on certain parameters.
7. User Interface Interactions:
 Functions handle user interactions in graphical user interfaces (GUIs).
When a button is clicked or a key is pressed, a function is often called
to respond to the event.
 Example: A function handleButtonClick(event) might be triggered
when a user clicks a button on a website.
8. Machine Learning and Artificial Intelligence:
 Functions are central to machine learning models. In training, a
function (the model) learns to map input data to output predictions.
 Example: In a neural network, each layer involves a function that
transforms input data into a more abstract representation.
9. Networking and Communication:
 Functions are used in networking protocols for tasks such as data
encoding, decoding, and error checking.
 Example: A function encodeData(data) might be used to encode
information before transmitting it over a network.
10. Algorithm Design: - Functionality: Functions are fundamental in algorithm
design. Algorithms are often expressed as a series of functions that perform
specific tasks. - Example: A searching algorithm might involve a function
binarySearch(array, target) to efficiently locate a target element in a
sorted array

Exercises:
1. If g(x)=x2 and h(x)=√ x, find
a. Inverse of g(x) and h(x)
b. g∘h and h∘g
2. Given f(x)=2x+3, find the domain of f for x={-3, -2, 0,1, 2, 3, 5}.
Explain if f(x) is one-to-one or onto.

You might also like