https://slides.com/georgelee/ics141-sets-functions/live
A Function f is a mapping between two sets X and Y such that if x ∈ X and y ∈ Y, then f(x) maps to exactly one element of Y.
A Partial Function is a mapping between two sets where
∃x where x ∈ X, but f(x) ∉ Y.
Let f be a function from A to B. A is the Domain of the function f and B is the Codomain.
Let a ∈ A and b ∈ B and f(a) = b. Then b is the Image of a and a is the Preimage of b.
The Range of f is the set of all images of elements of A.
Consider the function with the signature:
public bool isPositive(int x)
Domains and Codomains can be considered "types"
What about dynamic languages?
function isPositive(x)
A function f is one-to-one, or an injunction if and only if
f(a) = f(b) implies that a = b for all a and b in the domain.
Examples
f(x) = x's full name (injective)
g(x) = x's class standing (not injective)
A function f from A to B is onto, or surjective, if and only if for every element b ∈ B there is an element a ∈ A such that f(a) = b.
Examples
f(x) = x's name (where the domain is people in this class and the codomain is the class roster)
g(x) = x * x (not onto if the codomain is all real numbers)
A function f from A to B is a one to one correspondence, or bijective, if and only if the function is both one to one and onto.
Examples
f(x) = x's name (where the domain is people in this class and the codomain is the class roster)
g(x) = x + 1
A function f from A to B has an inverse if it is a bijection. The function is denoted as f (y). The inverse of a function f is a mapping from B to A.
Examples
f(x) = x + 1, f (y) = y - 1
-1
-1
Let g be a function from A to B and f be a function from B to C. Then the composition of f and g is (f ○ g)(x) = f(g(x))
See: http://pearl.ics.hawaii.edu/~sugihara/course/ics141/notes/Functions.html#SpecialFunctions