Function Composition and Operations
What You’ll Learn
Section titled “What You’ll Learn”In this lesson you’ll learn how to perform arithmetic operations on functions and how to compose functions, feeding the output of one function into another.
The Concept
Section titled “The Concept”You already know how to add, subtract, multiply, and divide numbers. You can do the same things with functions.
Given two functions f(x) and g(x), you can create new functions:
- Sum: (f + g)(x) = f(x) + g(x)
- Difference: (f - g)(x) = f(x) - g(x)
- Product: (f · g)(x) = f(x) · g(x)
- Quotient: (f / g)(x) = f(x) / g(x), provided g(x) ≠ 0
These work exactly the way you’d expect. Evaluate each function separately, then combine the results.
The more interesting operation is composition. Composition means plugging one function into another:
Think of it as a pipeline: x goes into g, and whatever comes out goes straight into f. The notation reads right to left: in (f ∘ g), you do g first, then f.
One important thing: composition is not commutative. In general, f(g(x)) ≠ g(f(x)). The order matters.
Worked Example
Section titled “Worked Example”Let f(x) = 2x + 3 and g(x) = x² - 1.
Function operations:
Composition (f ∘ g):
Apply g first, then f:
Composition (g ∘ f):
Now the other way around. Apply f first, then g:
Notice that (f ∘ g)(x) = 2x² + 1 and (g ∘ f)(x) = 4x² + 12x + 8. Completely different results. Order matters.
Evaluating at a specific value:
Find (f ∘ g)(2):
So (f ∘ g)(2) = 9. You can verify: 2(2²) + 1 = 2(4) + 1 = 9. ✓
Real-World Application
Section titled “Real-World Application”Function composition and operations show up constantly:
- Economics: if C(x) is cost and R(x) is revenue, then P(x) = R(x) - C(x) is profit
- Physics: position, velocity, and acceleration are related through composition with derivatives
- Computer science: chaining functions is the foundation of functional programming
- Finance: compound interest is built by composing a growth function with itself repeatedly
- Data pipelines: cleaning data, then transforming it, then analyzing it is function composition
Example: a store offers a 20% discount, then charges 8% tax. If D(x) = 0.80x (discount) and T(x) = 1.08x (tax), the final price is T(D(x)) = 1.08(0.80x) = 0.864x. That’s composition in action.