What is a Function? What is a Function?
Introduction
A function
f
from a set
X
to a set
Y
takes all possible inputs
(x)
and assigns each of them a single output
(y)
. These inputs and outputs can be anything, including numbers, colors, lists, words, or even other functions.
Colors
The function
h
, takes three numbers, between 0 and 255, and ouputs a color.
h
does so applying the following rules:
The first number is the amount of red.
The second number is the amount of green.
The third number is the amount of blue.
h(r,g,b)=\text{color}
Remember that a function assigns one output to each input. Here, this means that an
(r,g,b)
input results in the same color every time.
Notation for this function:
X
: All possible combinations of three numbers between 0 and 255.
Y
: All possible colors.
h
: A function which takes each value of X
and assigns it a value from Y
. The statements below are the same:
\forall (r,g,b) \in X, \, \exists c \in Y, \, h((r,g,b)) = c
For all
(r,g,b)
in
X
, there exists
c
in
Y
such that
h((r,g,b))=c
.
Words
Example 1:
The function
l
takes a word and reverses it.
l
(brick) = kcirb l
(hello) = olleh l
(racecar) = racecar Note that an input can have itself as an output.
Example 2:
The function
m
takes a word and sorts the letters into alphabetical order.
m
(dragon) = adgnor m
(almost) = almost m
(conversation) = aceinnoorstv m
(conservation) = aceinnoorstv Note that two different inputs can be assigned the same output.
Example 3:
The function
n
takes a word and makes no changes.
n
(washington) = washington n
(dinosaur) = dinosaur n
(incorrectly) = incorrectly A function which takes the inputs and does not change them is called the identity function.
These functions,
l
,
m
, and
n
, all map from the same input set to the same output set. The input set
(X)
is all words. The output set
(Y)
is also all words.
(By "words", we mean any combination of letters, including gibberish.)
The Real Numbers
In Calculus, we will be working primarily with functions using real numbers as inputs and outputs.
For each point on this graph, the
x
-coordinate is the input and the
y
-coordinate is the output. Hover over the graph to see the value of the points.
f(x) = 2x
For this function,
f(2)=4
f(3.5)=7
f(-\pi)=-2 \pi
Notation:
f
is the function.
x
is the input.
2x
is the output.
f(x)
is also the output. These functions can also be written in the form:
y=2x
.
The function has no symbol.
x
is the input.
2x
is the output.
y
is also the output. We will use both forms of notation throughout this course. They each have their own advantages. They are also both present on the AP test.
Clarifications
The graph below,
j
, is not a valid function since the input
0
is assigned multiple outputs.
j(0)=-1
,
j(0)=-0.9
,
j(0)=0
,
j(0)=0.5
, etc.
The next graph,
k(x)=\sqrt{x}
, is not valid when mapping from the real numbers to the real numbers, since there are inputs which have no outputs.
k(-1)
,
k(-20)
, and
k(-0.3)
do not exist.
However,
k
is valid for a different mapping:
X
is the set of positive real numbers.
Y
is the set of all real numbers.
The identity function maps every input to itself.
For example,
r(x)=x
.
This function maps multiple inputs to the same outputs. That is allowed.
q(x)=x^2
.