Definition: A discrete function f: A \to B maps each element from a discrete domain A to exactly one element in a discrete codomain B.
Browse / Discrete Functions Essentials
Discrete Functions Essentials
An essential guide to discrete functions for students of computer science, mathematics, and engineering. This cheat sheet covers core definitions, types of functions, sequences, special functions, and asymptotic growth, providing clear examples and key insights.
Foundational Concepts
FUNCTION BASICS
|
Notation:
|
One-to-One (Injective): Every distinct element in the domain maps to a distinct element in the codomain.
|
Example: f: \mathbb{Z} \to \mathbb{Z}, f(x) = x+1.
Non-example: g: \mathbb{Z} \to \mathbb{Z}, g(x) = x^2.
|
Onto (Surjective): Every element in the codomain is the image of at least one element in the domain.
|
Example: f: \mathbb{Z} \to \mathbb{Z}, f(x) = x-3.
Non-example: g: \mathbb{Z} \to \mathbb{N}_0, g(x) = |x|.
|
Bijective (One-to-One Correspondence): A function that is both one-to-one and onto.
|
Example: f: \mathbb{Z} \to \mathbb{Z}, f(x) = x+5.
Importance: Bijective functions have inverse functions. |
Function Composition: (g \circ f)(x) = g(f(x)). Applies f first, then g.
|
Example: f(x) = x+1, g(x) = x^2.
|
Key Insight: Understanding if a function is one-to-one, onto, or bijective is crucial for inverse functions, counting arguments (cardinality), and cryptographic applications. |
|
SEQUENCES & RECURSIVE FUNCTIONS
Sequence Definition: An ordered list of elements. Can be finite or infinite.
|
Arithmetic Sequence: Each term is found by adding a constant (common difference d) to the previous term.
|
Example (Arithmetic): Sequence: 2, 5, 8, 11, \dots
|
Geometric Sequence: Each term is found by multiplying the previous term by a constant (common ratio r).
|
Example (Geometric): Sequence: 3, 6, 12, 24, \dots
|
Recurrence Relation: Defines a term in a sequence based on one or more preceding terms.
|
Fibonacci Sequence: A classic example of a recurrence relation.
|
Solving Recurrence Relations (Brief):
|
Iteration vs. Recursion (Programming Context):
|
|
Tail Recursion: A special form where the recursive call is the last operation. Can often be optimized by compilers into iteration. |
Common Pitfall: Forgetting base cases in recurrence relations or recursive functions leads to infinite loops or incorrect results. |
Special Functions & Asymptotic Analysis
PIECEWISE & STEP FUNCTIONS
Piecewise Function: Defined by multiple sub-functions, each applied to a different interval of the domain.
|
Example:
|
Floor Function (Greatest Integer Function): \lfloor x \rfloor
|
Examples:
|
Ceiling Function (Least Integer Function): \lceil x \rceil
|
Examples:
|
Properties of Floor/Ceiling:
|
Applications: Used in computer science for array indexing, memory allocation, and time complexity analysis. |
Key Insight: Floor and ceiling functions are crucial for discretizing continuous values, which is fundamental in many computational algorithms where only integer quantities are meaningful (e.g., number of blocks, number of iterations). |
|
MODULAR ARITHMETIC FUNCTIONS
Modulo Operator (mod): a \pmod n
|
Function: f(x) = x \pmod n
|
Examples:
|
Note on Negative Numbers: Different programming languages might handle negative numbers differently for the |
Congruence Relation: a \equiv b \pmod n
|
Example:
|
Applications in Computer Science:
|
Example (Hashing): If a hash table has 10 buckets, and |
Common Pitfall: Forgetting that modulo results are always non-negative in pure mathematics, unlike some programming language implementations where |
|
GROWTH OF FUNCTIONS
Asymptotic Analysis: Studies the behavior of functions as their input (usually n) approaches infinity.
|
Big-O Notation (O(g(n))): Upper Bound
|
Examples of Big-O:
|
Other Notations:
|
Growth Rate Hierarchy (from slowest to fastest):
|
Visualizing Growth:
|
Rules for Big-O:
|
Example (Rule Application):
|
Practical Implications: An algorithm with O(n) complexity is generally preferred over O(n^2) for large inputs, and O(n^2) over O(2^n). |
Key Insight: Asymptotic notation provides a high-level, language-independent way to compare the efficiency of algorithms, focusing on how their performance scales with increasing input size. |