Function Composition Basics
What you'll learn: How to combine two functions by feeding one function's output directly into another function as input.
The Core Idea
Function composition is like a two-step machine process. Imagine you have two machines: one that doubles numbers, and another that adds 3. If you run a number through the first machine, then take that result and run it through the second machine, you've just composed two functions!
In mathematical notation, we write this as (f ∘ g)(x), which reads as "f composed with g at x" or simply "f of g of x." It means:
- First, evaluate g(x) — the "inner" function
- Then, take that result and plug it into f — the "outer" function
So (f ∘ g)(x) = f(g(x))
Understanding the Order
Order matters! Think of it like getting dressed: putting on socks then shoes is very different from shoes then socks.
Example
If f(x) = 2x (the "doubler") and g(x) = x + 3 (the "add-three-er"):
-
(f ∘ g)(5) means: First find g(5) = 5 + 3 = 8, then find f(8) = 2(8) = 16
-
(g ∘ f)(5) means: First find f(5) = 2(5) = 10, then find g(10) = 10 + 3 = 13
Notice how (f ∘ g)(5) ≠ (g ∘ f)(5)!
Reading the Notation
The notation (f ∘ g)(x) can be confusing at first. The function closest to x gets applied first. Think of it as working from the inside out, like nested parentheses.
Key Takeaway: Function composition (f ∘ g)(x) = f(g(x)) means apply g first, then apply f to that result — always work from the inside out, and order matters!