Recent chats

How do I compose two functions without mixing up the order?

Quick answer

In f(g(x)), apply g first, then feed its result into f. In g(f(x)), apply f first, then feed its result into g. The function written inside the parentheses is the first one you evaluate. For example, if f(x)=x² and g(x)=x+2, then f(g(x))=(x+2)², while g(f(x))=x²+2; these are different expressions.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I keep confusing the order in f(g(x)). Which function do I do first?

Geez

Read the expression from the inside out. In f(g(x)), start with the inner function g: work out g(x), then put that result wherever the input appears in f. The notation means “f applied to the output of g,” or (f∘g)(x)=f(g(x)). [S1]

A useful cue is to treat g(x) as one temporary input. Find it first; then use that whole result as the input to f. Don’t read the letters from left to right as the order of action.

Follow-up question

Can you show both orders with the same functions so I can see what changes?

Geez

Let f(x)=x² and g(x)=x+2. For f(g(x)), substitute the entire expression x+2 into f’s input. Since f squares its input, f(g(x))=(x+2)².

For g(f(x)), substitute x² into g’s input. Since g adds 2 to its input, g(f(x))=x²+2. These are the two compositions illustrated in the textbook example. [S1]

Compare the parentheses: in (x+2)², the whole sum is squared; in x²+2, only x is squared before 2 is added. So switching the order generally changes the result. [S1]

Follow-up question

What if I want to check the difference using a particular input?

Geez

Use x=3 and evaluate each composition in its own order.

  1. For f(g(3)), do the inside first: g(3)=3+2=5. Then apply f: f(5)=5²=25.
  2. For g(f(3)), start inside with f: f(3)=3²=9. Then apply g: g(9)=9+2=11.

The results, 25 and 11, differ. This numerical check can help catch a mistaken order, but keep the symbolic expressions too: they show how the compositions work for any input where they are defined.

Follow-up question

Is there anything else I should check before I call my answer finished?

Geez

Check both the substitution and whether it is allowed. The output of the inner function must be in the domain of the outer function for the composition to be defined. [S1] In this example, the functions are given by expressions that accept the real-number inputs used here, so x=3 works for both orders. The source explains the domain requirement, but it does not establish the domains for every possible function; use the domains stated in your particular problem.

A reusable layout is:

  1. Name the requested order: f(g(x)) or g(f(x)).
  2. Evaluate the inner function.
  3. Substitute its complete output into the outer function, using parentheses where needed.
  4. Simplify, then check the domain and, if useful, test one input.

For this pair, the finished comparison is f(g(x))=(x+2)² versus g(f(x))=x²+2. Keeping the inner result grouped until substitution is complete helps prevent the common error of adding 2 after squaring when the requested order is f(g(x)).

A practical checklist

  • Circle the inner function in the requested composition.

  • Evaluate the inner function before using the outer one.

  • Substitute the complete inner output, keeping necessary parentheses.

  • Simplify and compare the two orders separately if both are requested.

  • Check that the inner output is allowed by the outer function’s domain.

A few more useful answers

Does f(g(x)) mean multiply f by g?

No. It means apply g to x, then use that output as the input to f. The composition symbol is also written (f∘g)(x). [S1]

Can the two orders give the same answer?

They can for some functions or inputs, but they generally give different results. Compute each order separately rather than assuming they match. [S1]

Why do I need parentheses after substitution?

Parentheses show that the entire inner output is being used as the outer function’s input. For example, squaring x+2 gives (x+2)², not x²+2.

Sources

References used for this guide.

  1. [S1] OpenStax Algebra and Trigonometry 2e, Section 3.4: Composition of Functions
    openstax.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work