• Practice
  • About 15 min
  • 5 practice questions

Composition with piecewise, modulus and greatest-integer functions

Compose functions defined in pieces by splitting the domain, evaluate compositions with |x| and [x] in the correct order, and avoid the trap of swapping f ∘ g and g ∘ f.

If something looks wrong, please tell us.

Composition is easy when both functions have one formula and tricky when one of them has pieces. The method does not change: apply the inner function first, then the outer. When the inner function is piecewise, or the outer function is, you must decide which piece the inner value falls in. This lesson shows how to do that cleanly and how to avoid errors with modulus and greatest-integer functions.

Point by point

For a single input, work step by step: find the inner value, then decide which rule of the outer function applies to that value, and then compute. Do not combine the rules until you have done this for a number.

Worked example 1: a piecewise outer function

Let f(x) = 2x for x < 1 and f(x) = x + 1 for x ≥ 1, and let g(x) = x². Find (f ∘ g)(−3) and (g ∘ f)(2). First, g(−3) = 9, and since 9 ≥ 1, f(9) = 10. So (f ∘ g)(−3) = 10. Next, f(2) = 3 (because 2 ≥ 1), and g(3) = 9, so (g ∘ f)(2) = 9. Note that (g ∘ f)(−3) = g(−6) = 36 is a different number from (f ∘ g)(−3), which shows that order matters.

The whole formula

To write f ∘ g as a formula, find where g(x) < 1 and where g(x) ≥ 1. Here x² < 1 exactly when |x| < 1. So (f ∘ g)(x) = 2x² for |x| < 1 and x² + 1 for |x| ≥ 1. Similarly (g ∘ f)(x) = (2x)² = 4x² for x < 1 and (x + 1)² for x ≥ 1. Check at x = 0.5: f ∘ g gives 2(0.25) = 0.5, directly f(0.25) = 0.5 ✓; g ∘ f gives 1, directly f(0.5) = 1 and g(1) = 1 ✓.

Compose point by point: inner first, then ask which piece of the outer function the inner value lies in. For a formula, solve the inequality that defines each piece for the inner function.

Worked example 2: modulus

Let f(x) = |x| and g(x) = x − 3. Then (g ∘ f)(−2) = g(|−2|) = g(2) = −1, while (f ∘ g)(−2) = |−2 − 3| = 5. As formulas, (g ∘ f)(x) = |x| − 3 and (f ∘ g)(x) = |x − 3|. The second has range [0, ∞) and the first has range [−3, ∞). Taking the modulus last always makes the result non-negative; taking it first does not.

Worked example 3: range of a composition

Let f(x) = |x| and g(x) = x² − 4. For f ∘ g, the output is |x² − 4|, which is never negative and equals 0 at x = ±2, so the range is [0, ∞). For g ∘ f, the output is |x|² − 4 = x² − 4, with range [−4, ∞). The same two functions, composed in different orders, have different ranges.

Greatest integer

With the greatest integer function the order is a classic trap. Let f(x) = [x] and g(x) = x². Then (f ∘ g)(−1.5) = [(−1.5)²] = [2.25] = 2. But (g ∘ f)(−1.5) = ([−1.5])² = (−2)² = 4. A negative number rounds down to a more negative integer, so [−1.5] = −2, not −1.

Key takeaways: compose a single input step by step; decide the piece after you know the inner value; to write a formula, turn each piece's condition into an inequality on the inner function. Check the order, f ∘ g versus g ∘ f, and check negative numbers when [x] is involved.

Check your understanding

  1. 1. Let f(x) = 2x for x < 1 and f(x) = x + 1 for x ≥ 1, and g(x) = x². What is (f ∘ g)(−3)?

    1. 36
    2. −6
    3. 9
    4. 10
    Show answer

    Answer: D. g(−3) = 9, and since 9 ≥ 1 we use x + 1, so f(9) = 10. The value 36 is g(f(−3)).

  2. 2. With the same f and g, what is (g ∘ f)(2)?

    1. 5
    2. 9
    3. 4
    4. 3
    Show answer

    Answer: B. f(2) = 2 + 1 = 3 (since 2 ≥ 1), and g(3) = 9.

  3. 3. What is [(−1.5)²], the greatest integer of the square of −1.5?

    1. 4
    2. −2
    3. 2
    4. 3
    Show answer

    Answer: C. (−1.5)² = 2.25, and the greatest integer not exceeding 2.25 is 2.

  4. 4. Let f(x) = |x| and g(x) = x − 3. What is (g ∘ f)(−2)?

    1. −1
    2. 5
    3. −5
    4. 1
    Show answer

    Answer: A. f(−2) = 2 and g(2) = 2 − 3 = −1. The value 5 belongs to (f ∘ g)(−2) = |−5|.

  5. 5. Let f(x) = |x| and g(x) = x² − 4. What is the range of f ∘ g?

    1. [−4, ∞)
    2. (0, ∞)
    3. [0, ∞)
    4. [4, ∞)
    Show answer

    Answer: C. (f ∘ g)(x) = |x² − 4|, which is never negative and equals 0 at x = ±2. Large x give large values, so the range is [0, ∞).

Privacy · Terms · Refunds · Delivery