edubun
English

Composition of functions

With f(x) = 2x + 1 and g(x) = 3 − x, f(g(x)) = 7 − 2x but g(f(x)) = 2 − 2x. The order changes the answer.

A discount and a coupon: which goes first?

Two ways to pay for a $50 item. The shop takes 10% off, d(x) = 0.9x, and you also hold a $5 coupon, c(x) = x − 5. Discount first, then coupon: c(d(50)) = 45 − 5 = 40 dollars. Coupon first, then discount: d(c(50)) = 0.9 × 45 = 40.50 dollars. Fifty cents apart. In both cases the output of one function went straight into the other. Only the order changed, and the order changed the bill.

Sit-ups to calories: the inside function acts first

Sometimes the output of one function is the input of the next. OpenStax describes a person doing sit-ups: s(t) is the number of sit-ups done in t minutes, and c(s) is the number of calories burned by s sit-ups. To get calories from minutes you first find the sit-ups, then the calories: c(s(t)). This chaining is called composition, written (c ∘ s)(t) = c(s(t)) and read "c composed with s". The function written last, on the inside, acts first.

f(g(1)): the input 1 goes through g first, giving 2, and then through f, giving 5.

f(g(x)) = 7 − 2x, but g(f(x)) = 2 − 2x

To evaluate f(g(1)) with f(x) = 2x + 1 and g(x) = 3 − x, work from the inside out. First g(1) = 3 − 1 = 2. Then f(2) = 2 × 2 + 1 = 5. To get a formula, substitute the whole of g(x) for x in f: f(g(x)) = 2(3 − x) + 1 = 6 − 2x + 1 = 7 − 2x. Check with x = 1: 7 − 2 = 5, the same as before. The other order is g(f(x)) = 3 − (2x + 1) = 2 − 2x, and g(f(1)) = g(3) = 0. The two compositions are different functions, so composition is not commutative.

f(g(2)) is not f(2) · g(2)

Do not confuse composition with multiplication. f(g(x)) means "put g(x) into f", while f(x)g(x) means "multiply the two outputs". With f(x) = x² and g(x) = x + 1, f(g(2)) = f(3) = 9, but f(2) · g(2) = 4 × 3 = 12. And the order matters again: g(f(2)) = g(4) = 5. Some pairs do give the same function both ways, such as f(x) = 4x and g(x) = x/2, where both orders give 2x, but that is the exception.

Look up the inside value first, and check the domain from the inside too

Composition works with tables too. If a table says g(2) = 5 and another says f(5) = 1, then f(g(2)) = f(5) = 1; you only need to look up the inner value first. Domains need one extra thought: x must be allowed in g, and g(x) must be allowed in f. With f(x) = 1/x and g(x) = x − 3, f(g(x)) = 1/(x − 3), which fails at x = 3 because g(3) = 0 cannot go into f. Going the other way, you can take a complicated function apart: h(x) = (x − 3)² is f(g(x)) with g(x) = x − 3 inside and f(x) = x² outside.

The lab shows both orders as two chains of machines. Choose f and g from the lists and change the input x. The top chain sends x through g and then f; the bottom chain sends it through f and then g. The panel writes out both compositions as formulas, so you can see whether the order matters for the pair you picked.

Loading

Drag to turn. Scroll or pinch to zoom.

f(x) = 2x + 1 and g(x) = 3 − x with input 1: f(g(1)) = 5 and g(f(1)) = 0. Try f = 4x with g = x/2 for a pair where both orders agree.
  1. With f(x) = 2x + 1 and g(x) = 3 − x, what is f(g(1))?
  2. With the same functions, what is g(f(1))?
  3. Which formula is f(g(x)) for f(x) = 2x + 1, g(x) = 3 − x?
    • 7 − 2x
    • 2 − 2x
    • −2x² + 5x + 3
    • 4 + x
  4. With f(x) = x² and g(x) = x + 1, what is f(g(2))?
  5. With f(x) = x² and g(x) = x + 1, what is g(f(2))?
  6. With f(x) = 4x and g(x) = x/2, what is (f ∘ g)(6)?
  7. In (f ∘ g)(x), which function acts first?
    • g
    • f
    • They act together
    • It depends on x
  8. h(x) = (x − 3)² is f(g(x)). Which pair works?
    • g(x) = x − 3, f(x) = x²
    • g(x) = x², f(x) = x − 3
    • g(x) = x, f(x) = x − 9
    • g(x) = 3x, f(x) = x²
  9. A table gives g(2) = 5, and another gives f(5) = 1. What is f(g(2))?
  10. With f(x) = 1/x and g(x) = x − 3, which x is left out of the domain of f(g(x))?
Common mistakes
  • With f(x) = x + 4 and g(x) = 3x, working out f(g(2)) as f(2) = 6, then g(6) = 18. That is g(f(2)). f(g(2)) starts inside: g(2) = 6, then f(6) = 10.
  • Writing f(g(x)) = (x + 4)(3x) for the same pair. That is the product f(x)g(x). Composition puts 3x where x was in f: f(g(x)) = 3x + 4.
  • With f(x) = x² + x and g(x) = x + 1, writing f(g(x)) = (x + 1)² + x. Both x's in f get replaced: (x + 1)² + (x + 1) = x² + 3x + 2.
Teacher's noteComposition is where the order of writing and the order of doing part ways: in f(g(x)), f is written first and acts second. Have students point at the inner brackets and say "g first, then f", and draw the two machines for the first few problems. Put numbers in before building formulas. A wrong formula is easy to catch when it disagrees with a value already worked out, as in the x = 1 check above.
Key points
  • (f ∘ g)(x) = f(g(x)): apply g first, then f.
  • Evaluate from the inside out; substitute all of g(x) for x to get a formula.
  • Composition is not commutative: f(g(x)) and g(f(x)) usually differ.
  • The domain needs x allowed in g and g(x) allowed in f.
Sources for this course (8)
  • Curriculum: 교육부 고시 제2022-33호 [별책 8] 수학과 교육과정 (ncic.re.kr/inv/org/download.do?year=2022&seq=10003559&orgType=ogi4, PDF read 2026-10-19: 중학교 1~3학년군 [9수02-06] 그래프 해석(증가와 감소), [9수02-14] 함수의 개념·함숫값, 용어 함수·함숫값·기울기·평행이동, 고려 사항 「한 양이 변함에 따라 다른 양이 하나씩 정해지는 두 양 사이의 대응 관계를 이용하여 도입」; 고등학교 공통수학2 [10공수2-01-06] 평행이동, [10공수2-01-07] 원점·x축·y축·직선 y = x에 대한 대칭이동, [10공수2-03-01] 함수의 개념(두 집합 사이의 대응 관계), [10공수2-03-02] 합성함수, [10공수2-03-03] 역함수, 용어 정의역·치역·공역·대응·일대일대응·일대일함수·합성함수·역함수, 기호 f: X → Y, g ∘ f, (g ∘ f)(x), y = g(f(x)), f⁻¹, y = f⁻¹(x), 교수·학습 용어 조건제시법; 미적분Ⅰ 용어 구간·닫힌구간·열린구간 [a, b], (a, b), 평균변화율, [12미적Ⅰ-02-07] 증가와 감소, 극댓값·극솟값)
  • Textbook: OpenStax, College Algebra 2e, 3.1 Functions and Function Notation (relation, domain and range of ordered pairs, {(1, 2), (2, 4), (3, 6), (4, 8), (5, 10)}, the odd/even relation that is not a function, coffee menu prices, vertical line test, horizontal line test, one-to-one: openstax.org/books/college-algebra-2e/pages/3-1-functions-and-function-notation)
  • Textbook: OpenStax, College Algebra 2e, 3.2 Domain and Range (no even root of a negative number, no division by 0, interval notation with brackets and parentheses, (0, 100] for "more than 0 and at most $100", {(2, 10), (3, 10), (4, 20), (5, 30), (6, 40)}: .../pages/3-2-domain-and-range)
  • Textbook: OpenStax, College Algebra 2e, 3.3 Rates of Change and Behavior of Graphs (average rate of change, increasing and decreasing intervals, local maxima and minima: .../pages/3-3-rates-of-change-and-behavior-of-graphs)
  • Textbook: OpenStax, College Algebra 2e, 3.4 Composition of Functions (f(g(x)); f(x) = 2x + 1 and g(x) = 3 − x give f(g(x)) = 7 − 2x and g(f(x)) = −2x + 2, so composition is not commutative; c(s) calories and s(t) sit-ups; f(x) = 1/x and g(x) = x − 3: .../pages/3-4-composition-of-functions)
  • Textbook: OpenStax, College Algebra 2e, 3.5 Transformation of Functions (g(x) = f(x) + k vertical shift, f(x − h) horizontal shift, −f(x) and f(−x) reflections, af(x) stretches and compressions, roof vent example S(t) = V(t) + 20 (open vent area in square feet plus 20): .../pages/3-5-transformation-of-functions)
  • Textbook: OpenStax, College Algebra 2e, 3.7 Inverse Functions (f⁻¹ is not an exponent and not 1/f, C = (5/9)(F − 32), 75 °F is about 24 °C, 26 °C is about 79 °F, x² restricted to [0, ∞), reflection about y = x: .../pages/3-7-inverse-functions)
  • History block only: MacTutor, University of St Andrews, The function concept (Leibniz, August 1673, the word "function"; Johann Bernoulli's letter of 2 September 1694; Euler, Introductio in analysin infinitorum 1748 and Institutiones calculi differentialis 1755; Dirichlet 1837; Goursat 1923 "y = f(x)": mathshistory.st-andrews.ac.uk/HistTopics/Functions)

Checked: 2026-10-18