# Functions

## Quick

The set of inputs accepted by the function. Given a function \[ f: X \rightarrow Y \] The domain of \(f\) is \(X\). In modern mathematical language, the domain is part of the definition of a function rather than a property of it.

The set \(Y\) is called the codomain: the set to which all outputs must belong.

The set of specific outputs the function assigns to elements of \(X\) is called its range or image. The image of \(f\) is a subset of \(Y\).

Any function can be restricted to a subset of its domain. The restriction of \(f:X\rightarrow Y\) to \(A\), where \(A \subseteq X\) is written as \(f|_A:A \rightarrow Y\)

↦ maps an element of one set to an element of another set; → maps a set to a set.

## Definitions

Let A and B be nonempty sets. A function \(f\) from A to B,denoted \(f:A \to B\) is an assignment of each element of A to exactly one element of B. We write \(f(a) = b\) if b is exactly one element of B assigned by the function f to the element a of A.

Functions can also be called mappings or transformations.

A function \(f:A \to B\) can also be defined as a subset of \(A /times B\) ( a relation). This subset is also restricted to be a realation where no two elements of the relation have the same first element.

Specifically a function f from A to B contains one and only one ordered pair (a,b) for every element \(a \in A\). \[ \forall x \left[x \in A \to \exists y[y \in B \wedge (x,y) \in f]\right] \] and \[ \forall x, y_1, y_2 [[(x, y_1) \in f \wedge (x,y_2) \in f]\to y_1 = y_2] \]

Given function \(f:A \to B\) :

- We say f maps A to B or f is a mapping from A to B.
- A is called the domain of f
- B is called the codomain of f
- if f(a) = b,
- then b is called the image of a under f
- a is called the preimage of b

- The range of f is the set of all images of points in A under f. We denote it by f(A).
- Two functions are equal when they have the same domain, the same codomain and map each element of the domain to the same element of the codomain.

### Representing

Functions may be specified in different ways:

- Explicent state of the assignment
- A formula - $f(x) = x+1
- A computer program

### Injections

A function f is said to be one-to-one or injective, if and only if f(a) = f(b) implies that a = b for all a and b in the domain f. A function is said to be an injection if it is one to one.

### Surjection

A function f from A to B is called onto or surjective, if and only if for every element \(b \in B\) there is an element \(a \in A\) with \(f(a) = b\).

### Bijections

A function is a one-to-one correspondence, or a bijection if it is both one to one and onto (surjective and injective).

Suppose that \(f:A \to B\)

- To show injective, show that if f(x) = f(y) for arbitray x, \(y\in A\) then x = y.
- To show that f is not injective: Find particular elements x, y \(\in\) B such that \(x \neq y\) and f(x) = f(y).
- To show that f is surjective: Consider an arbitrary element \(y \in B\) and find an element \(x \in A\) such that f(x) = y.
- To show that f is not surjective: Find a particular \(y \in B\) such that \(f(x) \neq y\) for all \(x \in A\).

### Inverse functions

Let \(f\) be a bijection from A to B. Then the inverse of \(f\), denoted by \(f^{-1}\) is the function from B to A defined as \(f^{-1}(y) = x\) if \(f(x) = y\).

No inverse exists unless f is a bijection. {:courses:spring_21:fund_discrete_math:start:pasted:20210219-143705.png}}

### Composition

Let \(f: B \to C, g:A \to B\). The composition of f with g denoted \(f \circ g\) is the function from A to C defined by $f ˆ g(x) = f(g(x)).

## References

- Wikipedia - function notation
- Wikipedia - Codomain
- Wikipedia - Domain of a function
- What does the function f: x ↦ y mean?
- Definition and Notation - Applied Discrete Structures