Quiz 2
Registry Synced

Functions and Their Types

3079 words
15 min read

Reading compass

Now · 🎯 Learning Objectives

Functions and Their Types

🎯 Learning Objectives

By the end of this topic, you will be able to:
  1. Distinguish a function from a general relation using the one-input-one-output rule
  2. Identify the domain, codomain, and range of a function
  3. Determine whether a function is injective, surjective, or bijective
  4. Apply the vertical line test to graphs
  5. Compute function values, including piecewise-defined functions
  6. Perform arithmetic operations on functions

📋 Prerequisites


📖 Core Content

3.1 Intuition: What Is a Function?

A function is a machine that takes an input and produces exactly one output. You put a number into the "square" machine, and it spits back its square. The machine is deterministic: same input always gives same output. Think of a vending machine: you press one button (input), and exactly one item comes out (output). If pressing B3 sometimes gives chips and sometimes gives chocolate, it's not a functioning machine!
💡 Why this matters: Functions are the building blocks of all mathematical modeling. In data science: every ML model is a function (features → prediction), every transformation (normalize, scale, log-transform) is a function, every database query (SQL SELECT) defines a function. (Diagram)

3.2 Formal Definition

3.2.1 Definition

Let AA and BB be non-empty sets. A function ff from AA to BB, written f:ABf: A \to B, is a relation fA×Bf \subseteq A \times B such that:
  1. Total: For every aAa \in A, there exists bBb \in B with (a,b)f(a, b) \in f.
  2. Single-valued: If (a,b1)f(a, b_1) \in f and (a,b2)f(a, b_2) \in f, then b1=b2b_1 = b_2. If (a,b)f(a, b) \in f, we write f(a)=bf(a) = b.
  • Domain: The set AA (all possible inputs)
  • Codomain: The set BB (all possible outputs, declared)
  • Range (Image): {f(a)aA}B\{f(a) \mid a \in A\} \subseteq B (actual outputs)
⚠️ Key point: All functions are relations, but not all relations are functions. A relation fails to be a function if some input has no output (not total) or some input has multiple outputs (not single-valued).

3.2.2 Worked Examples

Example 1.1 (Easy): Determine if f(x)=x2f(x) = x^2 is a function from R\mathbb{R} to R\mathbb{R}. Step 1 — Total: For every real xx, x2x^2 is a real number. ✓ Step 2 — Single-valued: Each xx maps to exactly one x2x^2. ✓ Domain: R\mathbb{R}, Codomain: R\mathbb{R}, Range: {yRy0}=[0,)\{y \in \mathbb{R} \mid y \geq 0\} = [0, \infty)
Yes, it’s a function. Range =[0,)\boxed{\text{Yes, it's a function. Range } = [0, \infty)}
Example 1.2 (Medium): Is y2=xy^2 = x a function y=f(x)y = f(x) from R\mathbb{R} to R\mathbb{R}? Step 1: For x=4x = 4, y2=4    y=2y^2 = 4 \implies y = 2 or y=2y = -2. This violates the single-valued condition — one input gives two outputs.
No — one input gives two outputs\boxed{\text{No — one input gives two outputs}}
Example 1.3 (Hard): Define f:ZZf: \mathbb{Z} \to \mathbb{Z} by f(n)=n/2f(n) = \lfloor n/2 \rfloor. Is this a function? Find its range. Step 1 — Total: Every integer nn divided by 2 has a floor. ✓ Step 2 — Single-valued: Floor gives exactly one integer. ✓ Range: For n=0n = 0, f(0)=0f(0) = 0; n=1n = 1, f(1)=0f(1) = 0; n=2n = 2, f(2)=1f(2) = 1; n=3n = 3, f(3)=1f(3) = 1; negative numbers follow similarly. Range = Z\mathbb{Z} (all integers appear: f(2k)=kf(2k) = k, f(2k+1)=kf(2k+1) = k).
Yes. Range =Z\boxed{\text{Yes. Range } = \mathbb{Z}}

3.3 Domain and Range

3.3.1 Finding Domain and Range

The domain of a function is the set of all valid inputs. The range is the set of all possible outputs. Recipe for domain:
  1. Look for "problem" operations: division by zero, square roots of negatives, log of non-positive
  2. Exclude values that cause these problems Recipe for range:
  3. Determine the set of outputs the function produces
  4. Use graphs, inequalities, or algebraic analysis

3.3.2 Worked Examples

Example 2.1: Find the domain of f(x)=1x3f(x) = \frac{1}{x-3}. Step 1: Problem: denominator x3=0x-3 = 0 → undefined Step 2: Exclude x=3x = 3 Domain: R{3}\mathbb{R} \setminus \{3\} or (,3)(3,)(-\infty, 3) \cup (3, \infty)
Domain =R{3}\boxed{\text{Domain } = \mathbb{R} \setminus \{3\}}
Example 2.2: Find the domain of g(x)=5xg(x) = \sqrt{5 - x}. Step 1: Problem: square root of negative → undefined Step 2: Need 5x0    x55 - x \geq 0 \implies x \leq 5 Domain: (,5](-\infty, 5]
Domain =(,5]\boxed{\text{Domain } = (-\infty, 5]}
Example 2.3: Find the domain and range of h(x)=1x2+1h(x) = \frac{1}{x^2 + 1}. Step 1 — Domain: Denominator x2+11>0x^2 + 1 \geq 1 > 0 for all real xx. No problems. Domain: R\mathbb{R} Step 2 — Range: x2+11x^2 + 1 \geq 1, so 1x2+11\frac{1}{x^2 + 1} \leq 1. Also always positive. 0<h(x)10 < h(x) \leq 1 Range: (0,1](0, 1]
Domain =R, Range =(0,1]\boxed{\text{Domain } = \mathbb{R},\ \text{Range } = (0, 1]}

3.4 Piecewise Functions

A piecewise function uses different rules for different parts of the domain. x^2 & \text{if } x < 0 \\ 2x + 1 & \text{if } x \geq 0 \end{cases}
**Example 3.1:** Compute $f(-2)$, $f(0)$, $f(3)$ for the function above. *Step 1:* $f(-2)$: Since $-2 < 0$, use $f(-2) = (-2)^2 = 4$ *Step 2:* $f(0)$: Since $0 \\geq 0$, use $f(0) = 2(0) + 1 = 1$ *Step 3:* $f(3)$: Since $3 \\geq 0$, use $f(3) = 2(3) + 1 = 7$ \\boxed{f(-2) = 4,\\ f(0) = 1,\\ f(3) = 7} \--- ### 3.5 Types of Functions #### 3.5.1 Injective (One-to-One) Functions **Intuition:** No two different inputs produce the same output. Like a fingerprint — each person has a unique one. **Definition:** $f: A \\to B$ is **injective** (one-to-one) if for all $a_1, a_2 \\in A$: a_1 \\neq a_2 \\implies f(a_1) \\neq f(a_2) Equivalently: $f(a_1) = f(a_2) \\implies a_1 = a_2$ **Horizontal Line Test:** A function is injective if every horizontal line intersects its graph at most once. \`\`\`mermaid graph LR subgraph "Injective (One-to-One)" A1\["1"\] --> B1\["a"\] A2\["2"\] --> B2\["b"\] A3\["3"\] --> B3\["c"\] end subgraph "Not Injective" C1\["1"\] --> D1\["a"\] C2\["2"\] --> D1\["a"\] C3\["3"\] --> D2\["b"\] end \`\`\` **Examples:** - $f(x) = 3x + 5$ → injective (linear with slope ≠ 0) - $f(x) = x^2$ → NOT injective (since $f(-2) = f(2) = 4$) - $f(x) = e^x$ → injective (strictly increasing) #### 3.5.2 Surjective (Onto) Functions **Intuition:** Every possible output value is actually achieved. The range equals the codomain. Like a stadium with no empty seats — every seat (codomain) has someone sitting in it (range). **Definition:** $f: A \\to B$ is **surjective** (onto) if for every $b \\in B$, there exists $a \\in A$ such that $f(a) = b$. **Equivalent:** $\\text{range}(f) = \\text{codomain}(f)$ **Examples:** - $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = 2x + 3$ → surjective (any $y = 2x + 3$ can be solved: $x = (y-3)/2$) - $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = x^2$ → NOT surjective (negative values never achieved) - $f: \\mathbb{R} \\to \\mathbb{R}^+$, $f(x) = e^x$ → surjective (range = $\\mathbb{R}^+$ = codomain) \`\`\`mermaid graph TD subgraph "Surjective (Onto)" SA\["Domain"\] --> SB\["Codomain = Range<br/>Every codomain value<br/>is hit"\] end subgraph "Not Surjective" NC\["Domain"\] --> ND\["Codomain<br/>Some codomain values<br/>never hit"\] end \`\`\` #### 3.5.3 Bijective Functions **Intuition:** The perfect pairing — each input maps to a unique output, and every output is hit. Like a dance where every person has a unique partner and nobody sits out. **Definition:** $f$ is **bijective** if it is **both** injective and surjective. **Properties of bijections:** - They have **inverses** - Domain and codomain have the same cardinality ($|A| = |B|$) - For finite sets, a function from $A$ to $B$ can be bijective only if $|A| = |B|$ #### 3.5.4 Worked Examples — Classifying Functions **Example 4.1:** Classify $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = 5x - 3$. *Injective:* If $f(a) = f(b)$, then $5a - 3 = 5b - 3 \\implies 5a = 5b \\implies a = b$. → **Injective** ✓ *Surjective:* For any $y \\in \\mathbb{R}$, solve $y = 5x - 3 \\implies x = \\frac{y+3}{5} \\in \\mathbb{R}$. → **Surjective** ✓ *Conclusion:* **Bijective** \\boxed{\\text{Bijective}} **Example 4.2:** Classify $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = x^3 - x$. *Injective:* $f(-1) = (-1)^3 - (-1) = -1 + 1 = 0$; $f(0) = 0$; $f(1) = 1 - 1 = 0$. So $f(-1) = f(0) = f(1) = 0$ but $-1 \\neq 0 \\neq 1$. → **Not injective** ✗ *Surjective:* For any $y \\in \\mathbb{R}$, $x^3 - x - y = 0$ has at least one real root (cubic always has a real root). → **Surjective** ✓ *Conclusion:* **Surjective only** \\boxed{\\text{Surjective}} **Example 4.3:** Classify $f: \\mathbb{N} \\to \\mathbb{N}$, $f(n) = n^2$. *Injective:* If $n_1^2 = n_2^2$, since $n_1, n_2 \\in \\mathbb{N}$, $n_1 = n_2$. → **Injective** ✓ *Surjective:* Is every natural number a perfect square? No — 2, 3, 5, 6, 7, 8, 10, ... are not squares. → **Not surjective** ✗ *Conclusion:* **Injective only** \\boxed{\\text{Injective (but not surjective)}} **Example 4.4 (Exam-style):** Let $f: \\mathbb{Z} \\to \\mathbb{Z}$ be defined by $f(n) = \\begin{cases} n/2 & \\text{if } n \\text{ is even} \\\\ (n-1)/2 & \\text{if } n \\text{ is odd} \\end{cases}$. Classify $f$. *Injective:* Check: $f(0) = 0$, $f(1) = 0$. $f(0) = f(1)$ but $0 \\neq 1$. → **Not injective** ✗ *Surjective:* For any $m \\in \\mathbb{Z}$, choose $n = 2m$ (even). Then $f(2m) = (2m)/2 = m$. → **Surjective** ✓ *Conclusion:* **Surjective only** \\boxed{\\text{Surjective}} \--- ### 3.6 Operations on Functions Functions can be combined arithmetically:
\begin{aligned} (f + g)(x) &= f(x) + g(x) \\ (f - g)(x) &= f(x) - g(x) \\ (f \cdot g)(x) &= f(x) \cdot g(x) \\ \left(\frac{f}{g}\right)(x) &= \frac{f(x)}{g(x)},\quad g(x) \neq 0 \end{aligned}
**Example 5.1:** Let $f(x) = x^2$, $g(x) = x + 1$. Find $(f+g)(3)$ and $(f/g)(2)$. *Step 1:* $(f+g)(3) = f(3) + g(3) = 9 + 4 = 13$ *Step 2:* $(f/g)(2) = f(2)/g(2) = 4/3$ \\boxed{(f+g)(3) = 13,\\ (f/g)(2) = \\frac{4}{3}} \--- ### 3.7 The Vertical Line Test **Intuition:** A simple visual check for whether a graph represents a function. **Vertical Line Test:** A graph represents a function if and only if **no vertical line** intersects the graph at more than one point. **Why:** A vertical line at $x = a$ tests the input $a$. If it hits two points, input $a$ maps to two outputs → not a function. \`\`\`mermaid graph LR subgraph "Function (Passes VLT)" A\["↑"\] B\[" "\] C\[" "\] A --> B B --> C end subgraph "Not a Function (Fails VLT)" D\["↑"\] E\[" "\] F\[" "\] D --> E D --> F end \`\`\` --- ## 📐 Key Formulas — Summary Table | Concept | Formula/Definition | When to Use | |:---|:---|:---| | Function definition | $\\forall a \\in A,\\ \\exists!\\ b \\in B:\\ f(a) = b$ | Checking if a relation is a function | | Domain | Set of all valid inputs | Before evaluating a function | | Range | $\\{f(a) \\mid a \\in A\\}$ | Determining possible outputs | | Injective | $f(a_1) = f(a_2) \\implies a_1 = a_2$ | One-to-one testing | | Surjective | $\\forall b \\in B,\\ \\exists a \\in A:\\ f(a) = b$ | Onto testing | | Bijective | Injective AND surjective | Function has inverse | | Horizontal line test | No horizontal line hits graph twice | Graphical injection test | | Vertical line test | No vertical line hits graph twice | Graphical function test | | Piecewise | $f(x) = \\begin{cases} \\text{rule}_1 & \\text{condition}_1 \\\\ \\text{rule}_2 & \\text{condition}_2 \\end{cases}$ | Multi-rule functions | | Sum of functions | $(f+g)(x) = f(x) + g(x)$ | Combining functions | --- ## ⚠️ Common Pitfalls ### Pitfall 1: Confusing One-to-One with Onto **Mistake:** Using the terms "one-to-one" (injective) and "onto" (surjective) interchangeably. **Why they're different:** - **Injective:** No two inputs share an output (unique mapping) - **Surjective:** Every possible output is achieved (complete coverage) **Example:** $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = e^x$ is injective but not surjective (never negative). $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = x^3 - x$ is surjective but not injective. ### Pitfall 2: Forgetting the Codomain When Testing Surjectivity **Mistake:** Saying $f(x) = x^2$ is surjective because its range is $\[0,\\infty)$ without checking the codomain. **Correct:** If $f: \\mathbb{R} \\to \\mathbb{R}$ and codomain is $\\mathbb{R}$, then $x^2$ is NOT surjective (negative numbers never hit). But if $f: \\mathbb{R} \\to \[0,\\infty)$, the SAME rule IS surjective. **How to catch:** Always check the declared codomain, not just what you think it should be. ### Pitfall 3: Assuming $f(x)$ and $g(x)$ Have Same Domain for Arithmetic **Mistake:** Computing $(f+g)(x)$ without considering domain restrictions. **Correct:** The domain of $(f+g)$, $(f-g)$, and $(f \\cdot g)$ is $D_f \\cap D_g$ (intersection of domains). For $(f/g)$, also exclude points where $g(x) = 0$. **Example:** $f(x) = \\sqrt{x}$, $g(x) = 1/(x-2)$. Domain of $f$: $\[0,\\infty)$. Domain of $g$: $\\mathbb{R} \\setminus \\{2\\}$. Domain of $(f+g) = \[0,\\infty) \\setminus \\{2\\}$. ### Pitfall 4: Thinking $f(a) = f(b)$ Always Implies $a = b$ **Mistake:** Assuming every function is injective. **Correct:** Only injective functions have this property. For general functions, $f(a) = f(b)$ can happen with $a \\neq b$. Example: $f(x) = x^2$, $f(2) = f(-2) = 4$. --- ## 📝 Practice Questions > **Q1: Is $f(x) = \\sqrt{x}$ a function from $\\mathbb{R}$ to $\\mathbb{R}$?** > > **Strategy Hint:** Check domain (principal square root is defined only for $x \\geq 0$). > > *Step 1:* For $x = -4$, $\\sqrt{-4}$ is not a real number. → Not total on $\\mathbb{R}$. > So $f: \\mathbb{R} \\to \\mathbb{R}$ is NOT a function (fails the "total" condition). > > If we restrict to $f: \[0,\\infty) \\to \\mathbb{R}$, it IS a function. > >
\boxed{\text{No — not defined for negative inputs}}
> **Q2: Find the domain of $f(x) = \\frac{2x+1}{x^2 - 4}$.** > > **Strategy Hint:** Denominator cannot be zero. > > *Step 1:* $x^2 - 4 = 0 \\implies x = 2$ or $x = -2$ > *Domain:* $\\mathbb{R} \\setminus \\{-2, 2\\}$ > >
\boxed{(-\infty, -2) \cup (-2, 2) \cup (2, \infty)}
> **Q3: Classify $f: \\mathbb{R} \\to \\mathbb{R}$, $f(x) = -2x + 7$.** > > **Strategy Hint:** Check both injective and surjective for a linear function. > > *Injective:* $f(a) = f(b) \\implies -2a + 7 = -2b + 7 \\implies a = b$. ✓ > *Surjective:* For any $y$, $x = (7 - y)/2 \\in \\mathbb{R}$. ✓ > >
\boxed{\text{Bijective}}
> **Q4: Does $f(x) = |x|$ pass the horizontal line test?** > > **Strategy Hint:** Consider the horizontal line $y = 1$. > > $f(-1) = 1$ and $f(1) = 1$. So the horizontal line $y=1$ hits the graph at two points → fails HLT → NOT injective. > >
\boxed{\text{No — not injective}}
> **Q5: Find the range of $f(x) = \\frac{3}{x^2 + 2}$.** > > **Strategy Hint:** The denominator is always positive, so $f(x) > 0$. Find max/min. > > *Step 1:* $x^2 + 2 \\geq 2$, so $\\frac{3}{x^2 + 2} \\leq \\frac{3}{2}$ > *Step 2:* As $x \\to \\infty$, $f(x) \\to 0$ (but never reaches 0) > *Range:* $(0, \\frac{3}{2}\]$ > >
\boxed{(0, \frac{3}{2}]}
> **Q6: For $f(x) = \\begin{cases} x+1 & x < 2 \\\\ 3x - 4 & x \\geq 2 \\end{cases}$, find $f(-1)$, $f(2)$, $f(5)$.** > > **Strategy Hint:** Check which rule applies for each input. > > *Step 1:* $f(-1)$: $-1 < 2$ → $f(-1) = -1 + 1 = 0$ > *Step 2:* $f(2)$: $2 \\geq 2$ → $f(2) = 3(2) - 4 = 2$ > *Step 3:* $f(5)$: $5 \\geq 2$ → $f(5) = 3(5) - 4 = 11$ > >
\boxed{f(-1) = 0,\ f(2) = 2,\ f(5) = 11}
> **Q7: Let $f(x) = x^2 - 1$, $g(x) = \\sqrt{x}$. Find $(f \\cdot g)(4)$.** > > **Strategy Hint:** Compute each function at 4, then multiply. > > *Step 1:* $f(4) = 16 - 1 = 15$ > *Step 2:* $g(4) = \\sqrt{4} = 2$ > *Step 3:* $(f\\cdot g)(4) = 15 \\times 2 = 30$ > >
\boxed{30}
> **Q8: Prove that $f: \\mathbb{R} \\to \\mathbb{R}$ given by $f(x) = x^3$ is bijective.** > > **Strategy Hint:** Show injective (strictly increasing) and surjective (solve for x). > > *Injective:* $f(a) = f(b) \\implies a^3 = b^3 \\implies a = b$ (since cube function is strictly increasing). ✓ > *Surjective:* For any $y \\in \\mathbb{R}$, let $x = \\sqrt\[3\]{y}$. Then $f(x) = (\\sqrt\[3\]{y})^3 = y$. ✓ > >
\boxed{\text{Bijective}}
> **Q9: Is $f: \\mathbb{N} \\to \\mathbb{N}$, $f(n) = n+1$ surjective?** > > **Strategy Hint:** Check if every natural number appears as an output. > > $f(n) = n+1$ gives outputs $\\{2,3,4,\\ldots\\}$. The number $1 \\in \\mathbb{N}$ never appears. → NOT surjective. > >
\boxed{\text{No — 1 is not in the range}}
> **Q10: Let $A = \\{1,2,3\\}$, $f: A \\to A$ be the function $f = \\{(1,2), (2,3), (3,1)\\}$. Classify $f$.** > > **Strategy Hint:** Check injective (all outputs distinct?) and surjective (all codomain values hit?). > > *Injective:* Outputs are $\\{2,3,1\\}$ — all distinct → Injective ✓ > *Surjective:* Codomain is $\\{1,2,3\\}$, range is $\\{1,2,3\\}$ → Surjective ✓ > >
\boxed{\text{Bijective}}
> **Q11: Find the domain of $f(x) = \\frac{1}{\\sqrt{9 - x^2}}$.** > > **Strategy Hint:** Two conditions: denominator ≠ 0 (true automatically if sqrt > 0) and sqrt argument ≥ 0. Since the sqrt is in denominator, we need $9 - x^2 > 0$. > > *Step 1:* $9 - x^2 > 0 \\implies x^2 < 9 \\implies -3 < x < 3$ > >
\boxed{(-3, 3)}
> **Q12: Can a function from a set of 3 elements to a set of 2 elements be injective?** > > **Strategy Hint:** Pigeonhole principle — 3 inputs must map to 2 outputs. > > If $|A| = 3$, $|B| = 2$, and $f: A \\to B$, by the pigeonhole principle, at least two elements of $A$ must map to the same element of $B$. Therefore $f$ cannot be injective. > >
\boxed{\text{No — pigeonhole principle}}$$ --- ## 🔗 Cross-References - Previous topic: [Relations](sets-relations) — functions are special relations - Next topic: [Coordinate Geometry](../week02/geom-coordinate-geometry.md) — plotting functions geometrically - Deep dive: [Exponential Functions](../week05/functions-exponential.md), [Composite & Inverse Functions](../week05/functions-composite-inverse.md) in Week 5 - Across courses: BSMA1002 Stats 1 (probability distributions are functions); BSMA1003 Maths 2 (linear transformations are functions) Join Discord Previous1.2 RelationsNext2.1 Coordinate Geometry
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.