Handout #17
CS103
April 13, 2011
Robert Plummer
Introduction to Functions
As used in ordinary language, the word
function
indicates dependence of a varying quantity on another.
If I tell you that your grade in this class is a function of your overall average, you interpret this to mean
that I have a rule for translating a number in the range of 0 to 100 into a letter grade.
More generally,
suppose two sets of objects are given: set A and set B; and suppose that with each element of A there is
associated a particular element of B.
These three things: the two sets and the correspondence between
elements comprise a function.
Here is a first definition, based on this idea of mapping:
Definition
A
function
f is a mapping from a set D to a set T with the property that for each element d in D, f maps
d to a single element of T, denoted f(d).
Here D is called the
domain
of f, and T is called the
target
or
codomain
.
We write this as f: D
T. We also say that f(d) is the
image
of d under f, and we
call the set of all images the
range
R of f.
A mapping might fail to be a function if it is not defined at every element of the domain, or if it maps an
element of the domain to two or more elements in the range:
Consider the mappings shown in the diagram above. We note that examples
a
and
b
are both functions since
every element in the first set (the domain) maps to a single element in the second set (the codomain or
target). Note that it is fine for two elements in the domain to map to the same element in the codomain (as
is the case in
b
). We point out that example
c
is not
a function, since there is an element in the domain which
does not map to any element in the codomain. Also, example
d
is not
a function since there is an element in
the domain that maps to more than one element in the codomain.
One way to define a function is to provide a table that shows the mapping for each element of the domain.
For example, in a small class we might have
the set of students S = {Maria, Clara. Tom, Dick, Harry}
the set of possible grades G = {A, B, C, D, NP}
a
b
c
d
these are not functions
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2
One possible function f: S
G would be:
d
f(d)
Maria
A
Clara
B
Tom
C
Dick
A
Harry
B
The table completely defines the function by showing every mapping.
Note that all the possible grades
are not used, i.e., the range is not the same as the codomain.
It is still convenient to call this a function
from S to G in order to indicate the possibilities.
The following table does not define a function from S to G, because not every member of S is mapped to
a grade:
d
Maria
A
Clara
B
Tom
C
Dick
Harry
B
The following table does not define a function from S to G, because one member of S is mapped to two
grades:
d
Maria
A
Clara
B
Tom
C
Dick
A
Harry
B
Harry
NP
Another way to define a function to specify a rule
for how the function operates, rather than listing out the
mapping.
For example, using the common notations
N: the set of natural numbers {1, 2, 3, ...}
Z: the set of all integers {..., 2, 1, 0, 1, 2, ...}
we could define a function f : N
N with the rule f(a) = 2a.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 PLUMMER
 Harry B, Clara B, Maria A, Tom C

Click to edit the document details