Chapter 1 made sets, pairs and relations precise. A
relation from to
is a subset of
(Definition 1.4.3), and among
the examples of Section 1.4 the graph of squaring
relates each real number to exactly one number, while
the unit circle relates to two numbers and
to none. This
chapter is about the first kind of relation. This
section gives it its name, function,
says when two functions are equal, uses functions to
make families, sequences and the set precise, and composes
them. The rest of the chapter asks what a function does
to its inputs and to its codomain (Section 2.2), builds
functions from pieces (Section 2.3), undoes them
(Section 2.4), and applies them to whole sets (Section
2.5).
What is a
function?
Everyone has used functions since school, and the
everyday definition is “a rule that assigns to each
input one output”. Look at the word “rule”. The rules
and
are different: one squares, the other adds,
squares, subtracts, and subtracts again. Yet on every
real number they give the same answer, and nobody would
call them different functions. Other functions have no
rule at all that one could write down. A table of
measured temperatures, one per day, assigns to each day
one number, and no formula produces it.
So the rule is not what matters. What matters is
which output goes with which input: the
set of input–output pairs. That set is a relation, and
Section 1.4 said exactly when two relations are the
same, namely when they contain the same pairs. So we
forget the rule and keep the pairs. One more piece of
data is needed, the set in which the outputs are
declared to lie; the reason is given
after the definition.
A function is its graph, with a declared
target.
Definition
2.1.1 (Function)
Let and be sets. A
function from to , written , is
given by a relation , the
graph of , such that together with the set , the
codomain of . Formally, is the pair . The set is the
domain of . For , the unique with is written
, the
value of at . We write for , and for the
whole function when its domain and codomain are
clear.
In symbols, the condition on the graph is where, as with the bounded quantifiers of Logic and Proof, Definition 5.1.1,
abbreviates .
The whole definition is the quantifier pattern . By Logic and Proof, Definition 5.8.1,
“” is
an existence claim and a uniqueness claim, and by Logic and Proof, Proposition 5.8.1
the uniqueness claim may be stated without reference to
the witness; so the condition on the graph is two
clauses:
- (Fn1) (existence) for every there is
at least one with : every input
has an output;
- (Fn2) (uniqueness) for every and all , if and , then
: no
input has two outputs.
In words: the graph is a set of input–output pairs,
with inputs from
and outputs from ;
(Fn1) says no input is left without an output, and (Fn2)
says no input is given two. The codomain is where outputs are
allowed to lie. It need not consist of outputs: can be
declared as a function from to , although no output
is negative. The set of outputs that actually occur is
the range of , which Section 2.5 will call the image of and write . The domain needs no
slot of its own in the pair : by (Fn1) every
occurs as a
first coordinate in , and since ,
nothing else does. So the graph determines the
domain.
The notation is well
defined. Writing “the with ” is
legitimate only if there is one, and only one. Clause
(Fn1) supplies one, and clause (Fn2) says that any two
are equal; together they license the article “the”. This
gives the equivalence that every argument with functions
uses: For : by the
choice of , and
if then
by
substituting equals (, Logic and Proof, Definition 5.7.1).
For :
both and
lie in
, so by (Fn2). Two
consequences follow at once. Equal inputs give equal
outputs: if , then . And every value lies in the codomain:
for
every .
Functions given by formulas. Most
functions in this book are introduced by a formula: “let
, ”. This means the function whose graph is
. Clause (Fn2) holds for any such graph:
if and
, then
. So for
a formula only (Fn1) needs checking, and it says: for
each in the
domain, the formula makes sense and its
value lies in the codomain. For on both are clear. For
“, ” the formula makes no sense at , and (Fn1) fails
there; for “, ” the value must be checked to lie in , which it
does, since squares are nonnegative.
A function whose domain is a product is a
function of two variables. Its inputs
are pairs, and we write rather than . Addition from
to
is an
example.
Example
(First functions)
Check (Fn1) and (Fn2), and find the range, for each
of the following.
(a) with graph .
(b) The
identity function ,
, for a
set .
(c) A
constant function , , for a fixed
.
(d) The
indicator function of a subset :
Solution.
(a) The graph is
a subset of . Each of , , occurs as a first
coordinate (Fn1), and each occurs exactly once, so no
input has two outputs (Fn2). So is a function, with
, , . Its range is
, the whole
codomain. A function on a small finite set is often
given this way, by listing its values; no formula is
needed.
(b) The graph is
the diagonal .
For each , the
pair is in
it (Fn1); and if is in it, then for some
, and the
characteristic property (Definition 1.4.1) gives (Fn2). The
range is .
(c) The graph is
. For
each , is in it (Fn1); if
is in it,
then by
the membership test for pairs in a
product (Definition 1.4.2), so (Fn2). If has an element, the
range is . If
, the
range is .
(d) The graph is
.
For (Fn1), let . By excluded middle (Logic and Proof, Proposition 2.5.3),
or ; in the first
case is in
the graph, in the second and is. For (Fn2), the
two cases cannot both hold, so never receives both
and , and each case gives
only one pair with first coordinate . The range is if has an element and
has
an element; it is if and has an element, if and has an element, and
if . This is
the first function of the chapter whose existence clause
needs excluded middle: the definition by cases is a
function only because every falls into one of the
cases.
The next example collects relations that fail to be
functions. Each failure is one clause, and it pays to
say which.
Example
(Relations that are not functions)
(a) Is the unit
circle the graph of a
function ?
(b) “Send a
fraction to its
numerator .” Is
this a function from to ? As a relation it is
Solution.
(a) No, and both
clauses fail, at different points. Clause (Fn2) fails at
: both and lie in , and . Clause (Fn1)
fails at : a
pair
would need , and no real square is negative. Restricting
the inputs to repairs (Fn1) but not (Fn2); keeping only
the upper half, , repairs (Fn2) as well, and gives the
function , .
(b) No. Clause
(Fn1) holds: every rational number is for some and . But
(Fn2) fails, because a rational number has many ways of
being written as a fraction. Since , both and lie in
, and . The “rule” gives
an output that depends on how the input is
written, not on the input. A function may not
do that, since its value is attached to the input
itself. This is why definitions of the form “write as …, then send it to
…” must be checked for
well-definedness, a check that returns
in Chapter 5 for functions defined on classes. Here the
repair is to fix the way of writing: let be the least with
(such
exist, by the
first sentence, so there is a least one by
well-ordering, proved in Chapter 3; a least element is
unique), and send
to . This is a
function.
↺Second readingWhy
each clause, and why a codomain
Why this definition. Each clause has
a job, and dropping one lets in the failures of Example (Relations that are not functions).
Without (Fn1), a “function” could be undefined at some
inputs, like at
; then would not name
anything, and statements “for every ” about would lose their
meaning. Without (Fn2), would not name
one thing, and in part (b)
would be both and
. The graph
replaces the rule because two rules can describe one
function, and sets are compared by their elements.
Why is the codomain part of the data? A relation is a
set, so if a function were only its graph, two functions
with the same graph would be equal (Definition 1.2.1), whatever
target was declared. The graph of as a
function is the same set as its graph as a function
. But these should be different
functions, because the second reaches every point of its
target and the first does not: this is the property
called surjectivity in Section 2.2, and Example (Squaring, three ways)
there shows it changing with the codomain. Recording the
codomain in the pair keeps the two apart. Many books take the
same convention, some without saying so.
Warning. A formula is not yet a
function. “The function ” names no function
until a domain and a codomain are given, and the domain
must be chosen so that (Fn1) holds: is a
function , and there is no function given by this
formula. Likewise makes sense on
and not
on . When you
meet “let ”, ask first where lives and where is meant to lie.
Quick check. Which of these
relations on are graphs of functions : , , ? For each that is not, name the clause that
fails.
Solution. The first is a function:
the constant function with value . The second fails (Fn1)
at , which has no
output. The third fails (Fn2) at , which has the two
outputs and .
When are
two functions equal?
A function is a pair , so two functions are equal when their
graphs are equal and their codomains are equal. In
practice we compare functions by their values, and the
next result says that this is the same test.
Proposition
2.1.1 (Equality of Functions)
Let and be functions. Then if and only if
, , and for every
.
Idea. Write and . The
characteristic property of pairs splits into “same graph”
and “same codomain”. Two graphs are equal when they have
the same elements, and by an element of
a graph is a pair ; so “same graph” is “same inputs, same
outputs”.
Proof. Write and , as
in Definition 2.1.1.
Suppose . By
the characteristic property of pairs (Definition 1.4.1), and . The domain is
determined by the graph, as the set of first coordinates
of its elements, so . Let . By , ,
so ,
and for
gives .
Suppose ,
, and
for
every . We
show . Let . Since , with and . By , , so by the
hypothesis, and then by for . The same argument with
and exchanged gives , so
by Proposition 1.2.1. Since also
, the
characteristic property gives , that is, .
So to show two functions equal, check three things:
the same domain, the same codomain, and the same value
at an arbitrary point. To show them different, one
witness suffices: a point where the values differ, or a
difference in domain or codomain.
Example
(Equal and unequal functions)
Decide which of these functions are equal.
(a) ,
and .
(b) ,
and
.
(c) and , both given by
.
Solution.
(a) Equal. The
domains are both and the codomains
both . For every
real , . By Proposition 2.1.1, : two rules, one
function.
(b) Equal. Same
domain and codomain, and for every real , : the
number is
nonnegative and its square is , and is by
definition the nonnegative number with square , which is unique by
Logic and Proof, Theorem 2.4.5.
(c) Not equal.
They have the same domain, the same values, and even the
same graph; but their codomains and are different
sets ( is in one
and not the other), so by Proposition 2.1.1 .
Restriction. A function can be cut
down to a smaller domain. For and
, the
restriction of to is the function whose graph is : the pairs of whose input lies in
. The squaring
function restricted to is of part (c). The bar
in is one of
the uses of a vertical bar that the book’s
colon-for-set-builder convention keeps free.
Families,
sequences, and the set of all functions
Section 1.3 used families of sets and
described them informally, as “a set for each index ”. We can now say
exactly what a family is, once its members are known to
lie in some set. A family of subsets of indexed by is a function
,
, with
the power set as the
codomain the definition asks for. More generally, if
is a set whose
elements are sets, a family of members of indexed by is a function . A codomain must
be named, because there is no set of all sets (Theorem 1.2.4). The value of
a family at is
written rather
than , and the
family is written , in parentheses because it is indexed. A
family is not the same thing as its set of values : the
family with has two indices and one value.
In the same way, a sequence of real
numbers is a function ,
, with
the value at
written . The
sequence is
the function , and its set of values is .
Sequences are the main object of Analysis on the
Real Line.
Finally, all functions from to form a set, written
↺Second readingWhere
comes
from
It is a set by the working rules of Section 1.2:
every function is a pair with , so is the subset of
cut out by the condition of Definition 2.1.1, and
this product is a set by (W2), (W4), and (W5), so is a set by
specification (W1).
The letters are in this order because, for finite
sets, has elements when has and has , as the next example
suggests; counting is the business of Section 4.1. The
set
of all sequences of zeros and ones, indexed from , plays a leading role
in Chapter 4.
Example
(All functions between two small sets)
List the elements of , and say which are indicator
functions of subsets of .
Solution. A function is determined by its two values and (Proposition 2.1.1), and
each may be or
. So there are
four:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Every one of them is an indicator function: for . The four subsets of and the four
functions correspond one to one.
The correspondence at the end of the example, between
subsets of and
functions , holds for every set : send to
and to . So counting the
subsets of a finite set and counting the functions from
it to are
one problem, which Section 4.1 solves.
A game with five strings. A string
of five symbols
or , such as , is a function
: its value at is its -th symbol. One player
lists five strings, say , , , , ; the other must
write a string not on the list. Searching all always works, but is
there a rule that builds a missing string from
any list of five in five steps? Try
one. Chapter 4 comes back to this game.
Quick check. Which string is the
indicator function of ? What is the
value at of the
string ?
Solution. The indicator of has value at and and value elsewhere, so it is the
string . The
value of at
is its second
symbol, .
The empty set gives the degenerate cases, and they
are worth settling now, since they are the test cases of
many later statements.
Proposition
2.1.2 (Functions and the Empty Set)
(a) For every set
there is exactly
one function from to : the pair , called
the empty function.
(b) If is nonempty (it has an
element), there is no function from to .
↺Second readingThe
empty function, proved
Proof.
- (a)
Existence. The empty relation satisfies , since is a subset of
every set (Section 1.2). The condition of Definition 2.1.1 reads
“for every , if
,
then there is exactly one with ”. For each the hypothesis is false,
so the implication holds (Logic and Proof, Proposition 2.1.2).
So
is a function from to .
Uniqueness. Let be any function
from to
. Its graph
satisfies , by the
mirror-image law of Proposition 1.4.1. So an
element of would
be an element of ; has no elements, and
by Proposition 1.2.3. Hence
.
- (b) Let , and suppose
were a function. By (Fn1) there would
be
with ; but has no
elements. So there is no such function .
In the notation : the set has exactly
one element for every , including ; and
whenever is
nonempty. The empty function returns
in Section 2.4 as the witness that a hypothesis there
cannot be dropped.
Quick check. How many elements do
and
have?
Solution. The set has
exactly one element, the empty function , by
Proposition 2.1.2 (a).
The set has
none, by Proposition 2.1.2 (b),
since has the
element .
Composition
Two functions can be applied one after the other when
the outputs of the first are inputs of the second.
Temperature in degrees Celsius, as a function of the
day, followed by the conversion to degrees Fahrenheit,
gives temperature in Fahrenheit as a function of the
day.
Definition
2.1.2 (Composition)
Let and be functions, the codomain of being the domain of
. Their
composite is the function read “
after ”.
This is a function by the remark on formulas: for
, the value
lies in , the domain of , so makes sense, and
it lies in . Its
graph is . The order of the
letters is the order of the formula , which is the
reverse of the order in which the
functions act:
acts first.
Example
(The order of composition matters)
Let , and . Compute and , and decide whether they are equal.
Solution. By Definition 2.1.2, and . At the values are
and , so by Proposition 2.1.1 .
In words: “add one, then double” is not “double, then
add one”. (In fact the two composites differ at every
, since ; one
point already suffices.)
The next example composes two functions that look as
if they cancel each other, and finds that they do so in
one order only.
Example
(Square root after squaring, and squaring after square
root)
Let , , and , . Which of
and are defined?
Compute them, and compare each with an identity
function.
Solution. The composite . It is
defined, since the codomain of is the domain of (Definition 2.1.2). It is
a function with by Example (Equal and unequal functions)
(b). It is not : its value at
is , and .
The composite . It is defined as well, since the
codomain of
is the domain of
. It is a function
with because is by definition
a number whose square is . The functions and have
the same domain, the same codomain and the same value at
every point, so by Proposition 2.1.1.
So one order gives an identity function and the other
does not. Applying and then returns every input;
applying and then
loses the sign.
So undoes , but does not undo .
↺Second readingComposites
defined in one order only
Composition can also fail to be defined in one order
only. For and , the composite is defined, and is not: ’s outputs are real
numbers, and
accepts only and
.
Composition is not commutative, but it is
associative, and the identity functions do nothing.
Proposition
2.1.3 (Composition Is Associative)
Let , , and be functions. Then and .
Proof. Both sides of the first
equation are functions from to , by Definition 2.1.2. For
, applying
Definition 2.1.2 twice
on each side gives So the two functions agree at every point, and
they are equal by Proposition 2.1.1.
Likewise and are functions from to with values and
,
so both equal .
Because of associativity, we write without
brackets: every way of bracketing gives the same
function, .
The identity functions play for composition the part
that the number
plays for multiplication: by the second statement of Proposition 2.1.3,
composing with an identity changes nothing. The analogy
stops at division. A number can be cancelled
from ; a
function can be
cancelled from only under a condition on . And in Example (Square root after squaring, and squaring after square root),
although : one composite of two
functions can be an identity while the other is not.
Quick check. Find with
, for
and
.
Solution. The function turns into , and is recovered as . So put . Check: for every , so by Proposition 2.1.1.
Quick check. For ,
and
,
compute and .
Solution.
and . The values agree at this point, but the
functions are different: at , and
.
Agreement at one point proves nothing about equality;
disagreement at one point proves inequality.
Exercises
A. Check your
understanding
Exercise
(A1)
- (a) Let and let
be
given by ,
, . Write the graph
of , and list the
values of
and .
- (b) Which of the
formulas , , define a function ? For each
that does not, name a point where (Fn1) fails.
- (c) Are ,
and
,
equal? Are , and , equal?
- (d) How many
elements do and have?
Name them.
Solution.
(a) The graph is
. For : , , , so sends every point to . Then sends every point to : it is the
constant function with value , and equal to .
(b) The formula
defines
a function : , so the denominator is never . The formula does not: at
it asks for
, and no
real number has square (it fails at every
). The
formula
does not: it fails at and at , where the denominator
is .
(c) Yes: both
have domain and codomain , and for
every integer , so
by Proposition 2.1.1. Yes
again: and , so
and agree at both
points of their common domain; two rules, one
function.
(d) The set has
exactly one element, the constant function with value
(Example (First functions)
(c)). A function must send each of , , to , so any two such
functions agree at every point and are equal by Proposition 2.1.1. The
set has no
element: a function would need a value at (Proposition 2.1.2
(b)).
B. Practice
Exercise
(B1: Composites of real functions)
Let , and .
- (a) Compute and .
- (b) Find every with .
- (c) Find a function
with , and check it.
Solution.
(a) By Definition 2.1.2, and .
(b) The equation
is equivalent to . Its
discriminant is , so by the quadratic formula
These two numbers are the only points where
the composites agree.
(c) The function
turns into , and is recovered as . So put Check: for every , and and
both go from to
, so by Proposition 2.1.1.
Exercise
(B2: A map of the plane)
Let , .
- (a) Show that for all .
- (b) Find a function
with , and check that also .
(Hint: solve , for
and .)
Solution.
(a) .
(b) Part (a)
suggests halving after applying . Put Then , and
Each computation compares two pairs coordinate
by coordinate (Definition 1.4.1). All four
functions go from to , so
and by Proposition 2.1.1.
Exercise
(B3: Families and their values)
- (a) Write the family
,
,
as a function, naming a codomain.
- (b) Give two
different families and of
subsets of with
the same set of values .
- (c) Is a
function ? A function ?
Solution.
(a) The function
, . Each value is a subset of
, so it lies in
.
(b) Let for even
and for odd . Every is even or odd,
and not both (Theorem 1.1.2), so each receives exactly one
value and (Fn1), (Fn2) hold. Let and for . Both families
have the set of values . They differ at the index
: and . So they are
different functions (Proposition 2.1.1) with
the same values.
(c) Yes: for each
, , so
. No: , since
the elements of
are numbers and no number is a set (the working
convention of Section 1.2). So (Fn1) fails for the
codomain : the
only candidate value at does not lie in
it.
C. Going deeper
Exercise
(C1: Functions equal to their own square)
In this exercise, a function with
is
called idempotent.
- (a) Let be
idempotent. Show that for every in the range of .
- (b) Show that on
is idempotent,
and that is not.
- (c) Find all
idempotent functions .
Solution.
(a) Let be in the range of
: for some . Then
(b) For every
real , , so ; the two functions and agree everywhere and are equal
by Proposition 2.1.1. For
: ,
while , so
.
(c) A function
is determined by its two values (Proposition 2.1.1), so
there are four: the identity, the constant function with
value , the
constant function with value , and the swap with , . The
identity is idempotent by Proposition 2.1.3. A
constant function
with value gives
. The swap is not: , and . So there are three idempotent
functions.
Exercise
(C2: Find the error)
“Claim: if and ,
then .
Proof: Let . Then . Cancelling the outer functions on both
sides, .
So .”
Find the first wrong step, and show that the claim is
false.
Solution. The first two steps are
correct: is the hypothesis at
the point . The
wrong step is “cancelling the outer functions”. The two
sides apply different outer functions,
on the left and
on the right, and
nothing licenses passing from an equation to .
The claim is false. Let and . Then and , so by
Proposition 2.1.1. But
, so .
Marking scheme. (10 points) - 3:
locates the step “cancelling the outer functions” as the
first wrong one. - 3: says why it fails: the outer
functions on the two sides are different, so from one cannot
conclude . -
4: a counterexample with both claims checked: the two
composites are equal, and and differ at a named
point.
Fatal errors (0 for the step): blaming the step ; a
counterexample in which .