Functions and Mappings

The term map or mapping is often used as a synonym for function, but tends to lack a formal definition. Many authors use it as a more general version of a function, including correspondences and cases where not every element of the 'domain' is assigned an element of the 'codomain' (hence, not a function).
A function from a set X to a set Y assigns to each element in X an element in Y. The set X is called the domain and the set Y the codomain of the function. The value of the function f at an element in its domain x \in X is denoted as f(x)and called the image of x under f. 
== Definition ==
A function, its domain, and its codomain are declared by f: X \to Y. Alternatively, this is denoted as x \mapsto f(x), ‘x maps into f(x)‘ (note that this leaves the domain and codomain unspecified). There are two important aspects to this definition:
# For every single x \in X, the function must assign an element y \in Y. 
# The function assigns a single/unique element in Y to x \in XNote, this does not mean two elements in the domain can not map to the same element in the codomain. Just that a single element in the domain maps to a single element in the codomain (which would be a correspondence).
Formally, this translates to \forall x \in X, \exists! y \in Y ~\text{s.t.}~ f(x) = y. The first part of the definition means that if not every element in X is mapped to Y it is not a function (!). The second part means that an argument can not have a non-singleton set as its image, which distinguishes it from a correspondence. 
== Domain, Codomain, Image, and Range ==
Given a function f: X \to Y:
* Domain: is the set X of inputs/arguments that the function accepts.
* Codomain: is the set Y into which all of the output of the function is constrained to fall.
* Range: is the set of all outputs from the function. Hence, is it is a subset of the codomain, f(X):= \{y \in Y ~|~ y = f(x),~ x \in X\} \subset Y.
* Image: of X' \subseteq X under the function is the set of outputs for a given set of inputs. So, f(X') := \{ y \in Y ~|~ y = f(x),~ x \in X' \}.
For example, if f: \mathbb{R} \to \mathbb{R} where f(x) = x^2 then the output/image of the function is never a negative number, while these are included in \mathbb{R}. Hence, the domain is \mathbb{R}, the codomain is \mathbb{R}, and the range/image is \mathbb{R}_+.
There is often confusion between the codomain, range and image. The former two are often used interchangeably. In addition, the image of a function without specifying a subset is often used to refer implicitly to the domain as the subset, making it mean the same as the range in the above definition. However, more properly we think about the image of a function as its value.
== Injection, Surjection, and Bijection ==
These are different classes of functions classified by how inputs/arguments are mapped to outputs/images. Given a function f: X \to Y:
*Surjective Function (a.k.a. onto): each element of the codomain is mapped to by at least one element of the domain. That is, f(X) = Y, the range and codomain are the same \forall y \in Y, ~\exists x \in X ~\text{s.t.}~ f(x) = y. 
* Injective Function (a.k.a. one-to-one): each element of the codomain is mapped to by at most one element of the domain. That is, f(x) = f(x') \implies x = x', ~\forall x, x' \in X.
* Bijective Function: a function that is both surjective and injective. Each element of the codomain is mapped to by exactly one element of the domain. That is, \forall y \in Y, \exists! x \in X ~\text{s.t.}~ f(x) = y.
 	Surjective	Non-Surjective
Injective 	 	
Non-Injective	 	
== Inverse Function ==
Given a function f: X \to Y, it is sometimes possible to define the inverse function, f^{-1}: Y \to X, where f^{-1} (b) := \{ a \in A ~|~ f(a) = b \}. Informally, the inverse of a function undoes the operation of the function. Since the inverse is a function, it must be that \forall y \in Y, ~\exists! x \in X ~\text{s.t.}~ f^{-1}(y) = x. 
A function f: X \to Y is invertible if there exists a function g: Y \to X such that: g(f(x)) = x, ~\forall x \in X, and f(g(y)) = y, ~\forall y \in Y. 
Some properties of inverse functions include: (INCLUDE PROOFS OF THESE, proof of iff bijective is in my math notes)
* A function is invertible if and only if it is bijective.
**Proof: 
***Invertible implies bijective: by contradiction, shows that if invertible and not bijective, then contradiction. Note that \neg \text{bijective} \iff \neg\text{injective}~\text{or}~\neg\text{surjective}. (1) If not injective, \exists y \in Y ~\text{s.t.}~ f(x) = f(x') while x \neq x'. Then, g(y) = \{x, x'\} hence it is not a function. (2) If not surjective, \exists y \in Y ~\text{s.t.}~ g(y) = \varnothing. Since it does not map to anything, it is not a function. Only (1) or (2) is needed to see that if the inverse function g(\cdot) exists, it is not possible that f(\cdot) is not bijective.
***Bijective implies invertible: by the definition of a bijection, we have \forall y \in Y,~ \exists! x \in X ~\text{s.t.}~ f(x) = y. Let g(y) := \{x \in X ~|~ f(x) = y \}. Then, f(\bar{x}) = \bar{y},~ g(\bar{y}) = \bar{x} \implies g(f(\bar{x})) = g(\bar{y})= \bar{x} ~\text{and}~ f(g(\bar{y})) = f(\bar{x}) = \bar{y} , which is the definition of invertibility. 
* If the inverse of a function exists, it is unique.
**Proof: by definition: g \circ f = I_X = g' \circ f and f \circ g = I_Y = f \circ g' where I is the identity function. Then, g = g \circ I_Y = g \circ (f \circ g') = (g \circ f) \circ g' = I_X \circ g' = g' .
* (f^{-1})^{-1} = f
**Proof: a function g(\cdot) is the inverse of f^{-1} when g \circ f^{-1} = I_Y , where g = (f^{-1})^{-1} . Since the inverse is unique, g = f \implies f = (f^{-1})^{-1} .
== Function Composition ==
Given two functions f: X \to Y and g: Y \to Z such that the domain of the latter is the codomain of the former, their composition is the function f \circ g : X \to Z defined by:(f \circ g)(x) = f(g(x)).
== Graph of a Function ==
A function is uniquely represented by the set of all pairs (x, f(x)), called the graph of the function. When the domain and codomain are sets of real numbers, each such pair may be thought of as the Cartesian coordinates of a point in the plane, giving the familiar visual representation of the graph of a function.