Skip to content

Function Composition and Operations

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.

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:

(fg)(x)=f(g(x))(f \circ g)(x) = f(g(x))

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.

Let f(x) = 2x + 3 and g(x) = x² - 1.

Function operations:

(f+g)(x)=(2x+3)+(x21)=x2+2x+2(f + g)(x) = (2x + 3) + (x^2 - 1) = x^2 + 2x + 2 (fg)(x)=(2x+3)(x21)=2x3+3x22x3(f \cdot g)(x) = (2x + 3)(x^2 - 1) = 2x^3 + 3x^2 - 2x - 3

Composition (f ∘ g):

Apply g first, then f:

(fg)(x)=f(g(x))=f(x21)=2(x21)+3=2x2+1(f \circ g)(x) = f(g(x)) = f(x^2 - 1) = 2(x^2 - 1) + 3 = 2x^2 + 1

Composition (g ∘ f):

Now the other way around. Apply f first, then g:

(gf)(x)=g(f(x))=g(2x+3)=(2x+3)21=4x2+12x+8(g \circ f)(x) = g(f(x)) = g(2x + 3) = (2x + 3)^2 - 1 = 4x^2 + 12x + 8

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):

g(2)=221=3,thenf(3)=2(3)+3=9g(2) = 2^2 - 1 = 3, \quad \text{then} \quad f(3) = 2(3) + 3 = 9

So (f ∘ g)(2) = 9. You can verify: 2(2²) + 1 = 2(4) + 1 = 9. ✓

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.

$(f + g)(x)$ means:
If $f(x) = 2x$ and $g(x) = x + 3$, what is $(f \circ g)(x)$?
In $(f \circ g)(x)$, which function is applied first?
When computing $(f / g)(x)$, you must ensure:
If $f(x) = x^2$ and $g(x) = 3x - 1$, then $(f \circ g)(2)$ equals: