Definition
A function f from A to B, written f:A→B, is a relation where each element of A is related to exactly one element of B.
- Domain: A (input set)
- Codomain: B (output set)
- Range/Image: {f(a)∣a∈A}⊆B (actual outputs)
Notation
- f(a)=b means f maps a to b
- a↦f(a) describes the mapping
Types of Functions
Injective (One-to-One)
Different inputs give different outputs:
∀a1,a2∈A:f(a1)=f(a2)→a1=a2
Equivalently: ∀a1,a2∈A:a1=a2→f(a1)=f(a2)
Example: f(x)=2x on R is injective.
Non-example: f(x)=x2 on R is not injective (f(−1)=f(1)).
Surjective (Onto)
Every element in the codomain is mapped to:
∀b∈B:∃a∈A:f(a)=b
Equivalently: range(f)=B
Example: f(x)=x3 from R to R is surjective.
Non-example: f(x)=x2 from R to R is not surjective (−1 is not in range).
Bijective (One-to-One Correspondence)
Both injective AND surjective.
f:A→B is bijective⟺∣A∣=∣B∣ and f is injective
Example: f(x)=2x+1 from R to R is bijective.
Cardinality Conditions
For finite sets A and B with ∣A∣=m and ∣B∣=n:
| Condition | Possible if |
|---|
| f:A→B injective | m≤n |
| f:A→B surjective | m≥n |
| f:A→B bijective | m=n |
Counting Functions
| Type | Count |
|---|
| All functions A→B | nm |
| Injective functions | n(n−1)(n−2)⋯(n−m+1)=(n−m)!n! |
| Bijective functions | n! (when m=n) |
Function Composition
If f:A→B and g:B→C, then g∘f:A→C:
(g∘f)(a)=g(f(a))
Properties
- Associative: (h∘g)∘f=h∘(g∘f)
- NOT commutative: g∘f=f∘g in general
- f∘g injective ⇒ g injective
- f∘g surjective ⇒ f surjective
- f,g bijective ⇒ g∘f bijective
Inverse Functions
If f:A→B is bijective, its inverse f−1:B→A satisfies:
f−1(f(a))=a for all a∈A
f(f−1(b))=b for all b∈B
Properties
- (f−1)−1=f
- (g∘f)−1=f−1∘g−1
- f∘f−1=IB and f−1∘f=IA
Identity Function
IA:A→A,IA(a)=a
For any f:A→B:
f∘IA=f=IB∘f
Important Functions
Floor and Ceiling
⌊x⌋=largest integer ≤x
⌈x⌉=smallest integer ≥x
Properties:
- ⌊x⌋≤x<⌊x⌋+1
- ⌈x⌉−1<x≤⌈x⌉
- ⌊x⌋=⌈x⌉ iff x∈Z
- ⌊−x⌋=−⌈x⌉
Modulo Function
amodn=a−n⌊a/n⌋
The remainder when a is divided by n.
Function Growth
Big-O Notation
f(n)=O(g(n)) if there exist constants c>0 and n0 such that:
∣f(n)∣≤c⋅∣g(n)∣ for all n≥n0
Common Growth Rates
O(1)<O(logn)<O(n)<O(nlogn)<O(n2)<O(n3)<O(2n)<O(n!)
Other Notations
- f(n)=Ω(g(n)): f grows at least as fast as g
- f(n)=Θ(g(n)): f grows at the same rate as g
- f(n)=o(g(n)): f grows strictly slower than g
Cardinality of Infinite Sets
Two sets have the same cardinality if there exists a bijection between them.
- Countably infinite: Same cardinality as N (e.g., Z, Q)
- Uncountable: Larger than N (e.g., R, P(N))
∣N∣=∣Z∣=∣Q∣=ℵ0
∣R∣=∣P(N)∣=2ℵ0=c