Functions
Functions
COMP4001
Functions
Functions
Learning Outcomes
Propositional
Functions Logic
Functionality
A function is a relation associating each member of
one set with a unique member of another set.
Propositional
Functions Logic
✓ function is a relation associating each member of one set
with a unique member of another set.
Propositional
Functions Logic
Functionality
Eg:
Let X be a set of people Sally, Peter, Anne, and
Richard
Propositional
Functions Logic
Functionality
Returning to our function of favourite colour (f),
Peter X and Peter’s favourite colour is Brown 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)
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
Propositional
Functions Logic
A function is a relation associating each member of
one set with a unique member of another set.
Propositional
Functions Logic
A function is a relation associating each member of
one set with a unique member of another set.
Propositional
Functions Logic
A function is a relation associating each member of
one set with a unique member of another set.
Propositional
Functions Logic
Functionality
Example
Consider a function g which maps a real number into
its square, we can write this as:
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
Propositional
Functions Logic
Functionality
We could define the same function using t as the
variable:
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
Propositional
Functions Logic
Functionality
Here we applied g first and then f. We use the
following notation to represent this:
fg or f(g(x))
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
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
Propositional
Functions Logic
Question and Answer Session
Q&A
Propositional
Functions Logic