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

Functions

Uploaded by

Salma Muzammil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Functions

Uploaded by

Salma Muzammil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Digital Technologies

COMP4001

Functions

Functions
Learning Outcomes

• On completion of this topic you should be


able to:
– Understand and use functions in problem
solving

Propositional
Functions Logic
Functionality
A function is a relation associating each member of
one set with a unique member of another set.

We can think of a computer program as a function


where there is a set of values on which the program
can run, and there is a corresponding set of outputs
that can be generated.

Propositional
Functions Logic
✓ function is a relation associating each member of one set
with a unique member of another set.

We can represent a function with an arrow diagram. By


convention the domain is shown on the left, the co-domain on
the right, and arrows are used to depict the mapping of
elements of the domain to elements of the co-domain:

Propositional
Functions Logic
Functionality
Eg:
Let X be a set of people Sally, Peter, Anne, and
Richard

Let Y be Blue, Brown, Green, Red, Yellow and


Orange.

Then one rule linking members of X to members of Y can be


obtained by associating each person’s favourite colour.
Hence one function can be “each person’s favourite colour”.

Propositional
Functions Logic
Functionality
Returning to our function of favourite colour (f),
Peter  X and Peter’s favourite colour is Brown  Y.

We could express this fact in function notation by


f(Peter) = Brown
where f is the name of the function

In general, a function f maps the elements of X into elements of


Y. This is represented in function notation by:

f:X Y

Propositional
Functions Logic
Functionality - General
If a  X then it maps to f(a)  Y under function f, which
is sometimes written as a  f(a)

f(a) is known as the image of a under f


(the value of f at a)

The set X is called the domain of f and Y is called the


co-domain of f.

The subset of Y that the set X maps to under f is


known as the range. In some instances the range is
the same as the co-domain and in others it is not.
Propositional
Functions Logic
Functionality
The domain = X = {Sally, Peter, Anne, Richard}

The co-domain = Y = {Blue, Brown, Green, Red,


Yellow, Orange}

The range = {Blue, Green, Brown}  Y

If we get the co-domain as {Blue, Green, Brown} then


the co-domain is equal to the range.

Propositional
Functions Logic
Functionality
The domain, co-domain (and indirectly the range) are
important parts of the definition of a function although
certain assumptions are often made when we deal
with maths functions.
The functions we deal with in mathematics and
computing are usually numerical functions where the
domain and co-domain are sets of numbers.
Unless otherwise stated we assume that the domain
for a formula based function is the set of real numbers
R (or the largest subset of R for which the formula has
meaning) and that the co-domain is R.
Propositional
Functions Logic
Functionality
A function cannot be one-many or many-many.

Means;
One value in X cannot map to many in Y but so many
of X can map to one value in Y

If any value of X maps to more than one value of Y


under f then f is NOT a function

Propositional
Functions Logic
A function is a relation associating each member of
one set with a unique member of another set.

one- one (one to one)


one- many (one to many)
If a function f is one-one then each - not a function
element in its range is associated with
exactly one element in its domain

Propositional
Functions Logic
A function is a relation associating each member of
one set with a unique member of another set.

many- one (many to one) many- many (many to many)


- not a function

Propositional
Functions Logic
A function is a relation associating each member of
one set with a unique member of another set.

one- one and many- one and


onto function onto function

When range = co-domain of a function we say function is an onto function.

Propositional
Functions Logic
Functionality
Example
Consider a function g which maps a real number into
its square, we can write this as:

Since any real number can be squared we can


assume that the domain and co-domain are both R.

Propositional
Functions Logic
Functionality

Propositional
Functions Logic
g(x) = x2
Domain(g) = R
Co-domain(g) = R
Range(g) = = non negative real numbers = [0,∞)

f(x) = x + 1
D(f) = R
Co-d(f) = R
R(f) = R

Propositional
Functions Logic
= non negative real numbers

= non negative real numbers

Propositional
Functions Logic
Functionality
We could define the same function using t as the
variable:

It is common to label the input to a function x (or


sometime t) but this is just a popular label in maths,
we could use anything.
It is also common to name a function f but other letters
can be used.

Propositional
Functions Logic
Functionality
Here the domain and co-domain are the entire set of
real numbers. But the range is the set of non negative
real numbers.

Propositional
Functions Logic
Functionality
Example
Let f(x) = x where x ≥ 0.
Note that x denotes the positive square root of x.
Find f(x) where x = 4, x = 100, and x = 6.25.

Propositional
Functions Logic
Functionality
Here we defined the domain to be the non negative
reals. Without entering a world of imaginary numbers
there is no square root of a negative number.
In this case the range is also non negative reals.

Propositional
Functions Logic
Functionality
Composition of Functions
Complicated functions can be built up by applying simple
functions in a particular order. Suppose

Propositional
Functions Logic
Composition of Functions

• f(x) = x + 1
• g(x) = x2

f(g(x))= f(x2) = x2 +1
g(f(x))= g(x+1) = (x+1)2

• Composition is not commutative

Propositional
Functions Logic
Functionality
Here we applied g first and then f. We use the
following notation to represent this:
fg or f(g(x))

The function f  g is called the composition of g and


f (note the change of order)
The function applied first appears on the right and the
function applied second appears on the left

We are able to find a single function that represents


fg
Propositional
Functions Logic
Functionality
Without the diagram we see that since f(x) = x + 1
then f(g(x)) = g(x) + 1 outer inner

and since g(x) = x2


then f(g(x)) = x2 + 1. f(g(x))

f(g(x))= g(x) +1 f(g(x))= f(x2)


= x2+1 = x2+1

Propositional
Functions Logic
Functionality

f(g(2)) = 22 + 1 = 4 + 1 = 5

f(g(-1)) = (-1)2 + 1 = 1 + 1 = 2

Propositional
Functions Logic
Functionality
We wish to find a formula for g  f (which represents do f first
and then g),
We understand that f(x) = x + 1 means that we should take the
input and add 1.
We also understand that g(x) = x2 means that we should take
the input and square it.
So if we perform f first then the input to g is x + 1 and the output
from g is (x + 1)2.
Hence, g  f = (x + 1)2.
g(f(x))= g(x+1)
= (x+1)2

Propositional
Functions Logic
Functionality
Without the diagram we see that since g(x) = x2
then g(f(x)) = (f(x))2
and since f(x) = x + 1
then g(f(x)) = (x + 1)2.

Propositional
Functions Logic
Functionality
We can check our result with x = 2 and x = -1, we
should get the same results as before:

g  f (2) = (2 + 1)2 = 32 = 9

g  f (-1) = (-1 + 1)2 = 02 = 0

Notice that in general f  g  g  f (as is the case here)


.
The order of applying functions is NOT commutative
Propositional
Functions Logic
Functionality
Inverse Functions
If a function f is one-one then each element in its range is associated with
exactly one element in its domain and if the range and co-domain are equal,
we can run these images in reverse.

The resulting function is called the inverse of f and is denoted by f -1.

If we denote by I the identity function which maps every element in the


domain onto itself, i.e. I(a) = a then we have: f  f -1 = I and f -1  f =
I

A many-one function DOES NOT have an inverse.

Propositional
Functions Logic
Functionality
Example
Suppose g(x) = 3x - 4 on the domain of real numbers.
g is one-one and its range is R.
We want to find g-1 so that g-1g = I, i.e. we want to find
g-1 so that applying g to any value in the domain and
then applying g-1 to the result will return the original
value.

Propositional
Functions Logic
Functionality

Propositional
Functions Logic
Propositional
Functions Logic
Functionality

Propositional
Functions Logic
Functionality
The domain of g-1 is the range of g and the
range of g-1 is the domain of g

In this example both domain and range of g is R, so


do g-1’s.

Propositional
Functions Logic
Question and Answer Session

Q&A

Propositional
Functions Logic

You might also like