Functions

Prerequisites

Functions

Introduction

• A function is mapping between two sets:
• The first set (denoted by X) is called the domain.
• The second set (denoted by Y) is called the codomain.
• Each mapping can be represented as an ordered pair, e.g. (a, 1). The set of all ordered pairs for the entire function is called the graph of the function, and is given the name G.
• For each element x in X, there exists a unique y in Y.
• X is called the 'argument', 'input', or 'preimage'
• Y is called the 'value', 'ouput', or 'image'
• In the above example, not all elements of Y were mapped to from X. The subset of Y that has mappings from X is called the range.
• This is also called the image of the function, and is denoted:

Functional Notation

• One common way to denote functions is using the functional notation.

LaTeX:\mathbf{y} = f(\mathbf{x})
• This is pronounced 'F of X'
• It is commonly used in areas of Mathematics which do not have a basis in set theory (such as calculus).

Arrow Notation

• Another way to denote functions is using arrow notation.

LaTeX:f\colon \mathbf{X} \to \mathbf Y
• This is pronounced 'the function f from set X to set Y.
• It is commonly used in areas of Mathematics which have a basis in set theory.

code (Python)

def f(x):
graph = {
'a': 1,
'b': 3,
'c': 1
}

return graph.get(x)

y = f('a')
print(y)